@evercam/ui 0.0.55-beta.11 → 0.0.55-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +295 -291
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/src/components/EVideoPlayer.vue.d.ts +9 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/style.css +1 -1
- package/dist/web-types.json +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
`),c=[],u=e?Oc(e.baseTime,e.timescale):0;let d="00:00.000",h=0,f=0,m,g=!0;o.oncue=function(y){const v=t[i];let T=t.ccOffset;const x=(h-u)/9e4;if(v!=null&&v.new&&(f!==void 0?T=t.ccOffset=v.start:mu(t,i,x)),x){if(!e){m=new Error("Missing initPTS for VTT MPEGTS");return}T=x-t.presentationOffset}const L=y.endTime-y.startTime,E=Ce((y.startTime+T-f)*9e4,r*9e4)/9e4;y.startTime=Math.max(E,0),y.endTime=Math.max(E+L,0);const k=y.text.trim();y.text=decodeURIComponent(encodeURIComponent(k)),y.id||(y.id=ns(y.startTime,y.endTime,k)),y.endTime>0&&c.push(y)},o.onparsingerror=function(y){m=y},o.onflush=function(){if(m){a(m);return}n(c)},l.forEach(y=>{if(g)if(ss(y,"X-TIMESTAMP-MAP=")){g=!1,y.slice(16).split(",").forEach(v=>{ss(v,"LOCAL:")?d=v.slice(6):ss(v,"MPEGTS:")&&(h=parseInt(v.slice(7)))});try{f=fu(d)/1e3}catch(v){m=v}return}else y===""&&(g=!1);o.parse(y+`
|
|
24
24
|
`)}),o.flush()}const as="stpp.ttml.im1t",Hn=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Vn=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,pu={left:"start",center:"center",right:"end",start:"start",end:"end"};function Kn(s,e,t,i){const r=X(new Uint8Array(s),["mdat"]);if(r.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const n=r.map(o=>Fe(o)),a=Fc(e.baseTime,1,e.timescale);try{n.forEach(o=>t(yu(o,a)))}catch(o){i(o)}}function yu(s,e){const r=new DOMParser().parseFromString(s,"text/xml").getElementsByTagName("tt")[0];if(!r)throw new Error("Invalid ttml");const n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(n).reduce((d,h)=>(d[h]=r.getAttribute(`ttp:${h}`)||n[h],d),{}),o=r.getAttribute("xml:space")!=="preserve",l=zn(os(r,"styling","style")),c=zn(os(r,"layout","region")),u=os(r,"body","[begin]");return[].map.call(u,d=>{const h=Wn(d,o);if(!h||!d.hasAttribute("begin"))return null;const f=cs(d.getAttribute("begin"),a),m=cs(d.getAttribute("dur"),a);let g=cs(d.getAttribute("end"),a);if(f===null)throw Yn(d);if(g===null){if(m===null)throw Yn(d);g=f+m}const y=new ts(f-e,g-e,h);y.id=ns(y.startTime,y.endTime,y.text);const v=c[d.getAttribute("region")],T=l[d.getAttribute("style")],x=vu(v,T,l),{textAlign:L}=x;if(L){const E=pu[L];E&&(y.lineAlign=E),y.align=L}return oe(y,x),y}).filter(d=>d!==null)}function os(s,e,t){const i=s.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(t)):[]}function zn(s){return s.reduce((e,t)=>{const i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function Wn(s,e){return[].slice.call(s.childNodes).reduce((t,i,r)=>{var n;return i.nodeName==="br"&&r?t+`
|
|
25
25
|
`:(n=i.childNodes)!=null&&n.length?Wn(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}function vu(s,e,t){const i="http://www.w3.org/ns/ttml#styling";let r=null;const n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=s!=null&&s.hasAttribute("style")?s.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(r=t[a]),n.reduce((o,l)=>{const c=ls(e,i,l)||ls(s,i,l)||ls(r,i,l);return c&&(o[l]=c),o},{})}function ls(s,e,t){return s&&s.hasAttributeNS(e,t)?s.getAttributeNS(e,t):null}function Yn(s){return new Error(`Could not parse ttml timestamp ${s}`)}function cs(s,e){if(!s)return null;let t=$n(s);return t===null&&(Hn.test(s)?t=xu(s,e):Vn.test(s)&&(t=Tu(s,e))),t}function xu(s,e){const t=Hn.exec(s),i=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+i/e.frameRate}function Tu(s,e){const t=Vn.exec(s),i=Number(t[1]);switch(t[2]){case"h":return i*3600;case"m":return i*60;case"ms":return i*1e3;case"f":return i/e.frameRate;case"t":return i/e.tickRate}return i}class Eu{constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Xn(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},e.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(p.FRAG_LOADING,this.onFragLoading,this),e.on(p.FRAG_LOADED,this.onFragLoaded,this),e.on(p.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(p.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(p.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(p.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(p.FRAG_LOADING,this.onFragLoading,this),e.off(p.FRAG_LOADED,this.onFragLoaded,this),e.off(p.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(p.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(p.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(p.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){if(this.config.enableCEA708Captions&&(!this.cea608Parser1||!this.cea608Parser2)){const e=new Qt(this,"textTrack1"),t=new Qt(this,"textTrack2"),i=new Qt(this,"textTrack3"),r=new Qt(this,"textTrack4");this.cea608Parser1=new Mn(1,e,t),this.cea608Parser2=new Mn(3,i,r)}}addCues(e,t,i,r,n){let a=!1;for(let o=n.length;o--;){const l=n[o],c=Su(l[0],l[1],t,i);if(c>=0&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],i),a=!0,c/(i-t)>.5))return}if(a||n.push([t,i]),this.config.renderTextTracksNatively){const o=this.captionsTracks[e];this.Cues.newCue(o,t,i,r)}else{const o=this.Cues.newCue(null,t,i,r);this.hls.trigger(p.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:i,initPTS:r,timescale:n}){const{unparsedVttFrags:a}=this;i==="main"&&(this.initPTS[t.cc]={baseTime:r,timescale:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(o=>{this.onFragLoaded(p.FRAG_LOADED,o)}))}getExistingTrack(e,t){const{media:i}=this;if(i)for(let r=0;r<i.textTracks.length;r++){const n=i.textTracks[r];if(qn(n,{name:e,lang:t,attrs:{}}))return n}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:i,media:r}=this,{label:n,languageCode:a}=t[e],o=this.getExistingTrack(n,a);if(o)i[e]=o,it(i[e]),Mr(i[e],r);else{const l=this.createTextTrack("captions",n,a);l&&(l[e]=!0,i[e]=l)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const i=t.label,r={_id:e,label:i,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(p.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}createTextTrack(e,t,i){const r=this.media;if(r)return r.addTextTrack(e,t,i)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:e}=this;Object.keys(e).forEach(t=>{it(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Xn(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let i=0;i<t.length;i++)it(t[i])}onSubtitleTracksUpdated(e,t){const i=t.subtitleTracks||[],r=i.some(n=>n.textCodec===as);if(this.config.enableWebVTT||r&&this.config.enableIMSC1){if(_n(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const a=this.media,o=a?Nt(a.textTracks):null;if(this.tracks.forEach((l,c)=>{let u;if(o){let d=null;for(let h=0;h<o.length;h++)if(o[h]&&qn(o[h],l)){d=o[h],o[h]=null;break}d&&(u=d)}if(u)it(u);else{const d=jn(l);u=this.createTextTrack(d,l.name,l.lang),u&&(u.mode="disabled")}u&&this.textTracks.push(u)}),o!=null&&o.length){const l=o.filter(c=>c!==null).map(c=>c.label);l.length&&S.warn(`Media element contains unused subtitle tracks: ${l.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const a=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(p.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(i=>{const r=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!r)return;const n=`textTrack${r[1]}`,a=this.captionsProperties[n];a&&(a.label=i.name,i.lang&&(a.languageCode=i.lang),a.media=i)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){this.initCea608Parsers();const{cea608Parser1:i,cea608Parser2:r,lastCc:n,lastSn:a,lastPartIndex:o}=this;if(!(!this.enabled||!i||!r)&&t.frag.type===j.MAIN){var l,c;const{cc:u,sn:d}=t.frag,h=(l=t==null||(c=t.part)==null?void 0:c.index)!=null?l:-1;d===a+1||d===a&&h===o+1||u===n||(i.reset(),r.reset()),this.lastCc=u,this.lastSn=d,this.lastPartIndex=h}}onFragLoaded(e,t){const{frag:i,payload:r}=t;if(i.type===j.SUBTITLE)if(r.byteLength){const n=i.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){const o=this.tracks[i.level],l=this.vttCCs;l[i.cc]||(l[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),o&&o.textCodec===as?this._parseIMSC1(i,r):this._parseVTTs(t)}}else this.hls.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const i=this.hls;Kn(t,this.initPTS[e.cc],r=>{this._appendCues(r,e.level),i.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},r=>{S.log(`Failed to parse IMSC1: ${r}`),i.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:r})})}_parseVTTs(e){var t;const{frag:i,payload:r}=e,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[i.cc]&&o===-1){a.push(e);return}const l=this.hls,c=(t=i.initSegment)!=null&&t.data?Le(i.initSegment.data,new Uint8Array(r)):r;gu(c,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,u=>{this._appendCues(u,i.level),l.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},u=>{const d=u.message==="Missing initPTS for VTT MPEGTS";d?a.push(e):this._fallbackToIMSC1(i,r),S.log(`Failed to parse VTT cue: ${u}`),!(d&&o>i.cc)&&l.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:u})})}_fallbackToIMSC1(e,t){const i=this.tracks[e.level];i.textCodec||Kn(t,this.initPTS[e.cc],()=>{i.textCodec=as,this._parseIMSC1(e,t)},()=>{i.textCodec="wvtt"})}_appendCues(e,t){const i=this.hls;if(this.config.renderTextTracksNatively){const r=this.textTracks[t];if(!r||r.mode==="disabled")return;e.forEach(n=>Nr(r,n))}else{const r=this.tracks[t];if(!r)return;const n=r.default?"default":"subtitles"+t;i.trigger(p.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){const{frag:i}=t;i.type===j.SUBTITLE&&this.onFragLoaded(p.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){this.initCea608Parsers();const{cea608Parser1:i,cea608Parser2:r}=this;if(!this.enabled||!i||!r)return;const{frag:n,samples:a}=t;if(!(n.type===j.MAIN&&this.closedCaptionsForLevel(n)==="NONE"))for(let o=0;o<a.length;o++){const l=a[o].bytes;if(l){const c=this.extractCea608Data(l);i.addData(a[o].pts,c[0]),r.addData(a[o].pts,c[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:i,endOffsetSubtitles:r,type:n}){const{media:a}=this;if(!(!a||a.currentTime<i)){if(!n||n==="video"){const{captionsTracks:o}=this;Object.keys(o).forEach(l=>ki(o[l],t,i))}if(this.config.renderTextTracksNatively&&t===0&&r!==void 0){const{textTracks:o}=this;Object.keys(o).forEach(l=>ki(o[l],t,r))}}}extractCea608Data(e){const t=[[],[]],i=e[0]&31;let r=2;for(let n=0;n<i;n++){const a=e[r++],o=127&e[r++],l=127&e[r++];if(o===0&&l===0)continue;if((4&a)!==0){const u=3&a;(u===0||u===1)&&(t[u].push(o),t[u].push(l))}}return t}}function jn(s){return s.characteristics&&/transcribes-spoken-dialog/gi.test(s.characteristics)&&/describes-music-and-sound/gi.test(s.characteristics)?"captions":"subtitles"}function qn(s,e){return!!s&&s.kind===jn(e)&&Ji(e,s)}function Su(s,e,t,i){return Math.min(e,i)-Math.max(s,t)}function Xn(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class us{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(p.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(p.BUFFER_CODECS,this.onBufferCodecs,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(p.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(p.BUFFER_CODECS,this.onBufferCodecs,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){const i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&z(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}const e=this.hls.levels;if(e.length){const t=this.hls,i=this.getMaxLevel(e.length-1);i!==this.autoLevelCapping&&S.log(`Setting autoLevelCapping to ${i}: ${e[i].height}p@${e[i].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=i,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const i=t.filter((r,n)=>this.isLevelAllowed(r)&&n<=e);return this.clientRect=null,us.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const e=this.media,t={width:0,height:0};if(e){const i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,!t.width&&!t.height&&(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}isLevelAllowed(e){return!this.restrictedLevels.some(i=>e.bitrate===i.bitrate&&e.width===i.width&&e.height===i.height)}static getMaxLevelByMediaSize(e,t,i){if(!(e!=null&&e.length))return-1;const r=(o,l)=>l?o.width!==l.width||o.height!==l.height:!0;let n=e.length-1;const a=Math.max(t,i);for(let o=0;o<e.length;o+=1){const l=e[o];if((l.width>=a||l.height>=a)&&r(l,e[o+1])){n=o;break}}return n}}class bu{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const i=this.hls.config;if(i.capLevelOnFPSDrop){const r=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=r,r&&typeof r.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,i){const r=performance.now();if(t){if(this.lastTime){const n=r-this.lastTime,a=i-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*a/n,c=this.hls;if(c.trigger(p.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:i}),l>0&&a>c.config.fpsDroppedMonitoringThreshold*o){let u=c.currentLevel;S.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(c.autoLevelCapping===-1||c.autoLevelCapping>=u)&&(u=u-1,c.trigger(p.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:c.currentLevel}),c.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=r,this.lastDroppedFrames=i,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}const ei="[eme]";class ht{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=ht.CDMCleanupPromise?[ht.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=S.debug.bind(S,ei),this.log=S.log.bind(S,ei),this.warn=S.warn.bind(S,ei),this.error=S.error.bind(S,ei),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(p.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(p.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(p.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(p.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(p.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(p.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:i}=this.config,r=t[e];if(r)return r.licenseUrl;if(e===ne.WIDEVINE&&i)return i;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){const{drmSystems:t}=this.config,i=t[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,i=(a,o,l)=>!!a&&l.indexOf(a)===o,r=t.map(a=>a.audioCodec).filter(i),n=t.map(a=>a.videoCodec).filter(i);return r.length+n.length===0&&n.push("avc1.42e01e"),new Promise((a,o)=>{const l=c=>{const u=c.shift();this.getMediaKeysPromise(u,r,n).then(d=>a({keySystem:u,mediaKeys:d})).catch(d=>{c.length?l(c):d instanceof _e?o(d):o(new _e({type:q.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_ACCESS,error:d,fatal:!0},d.message))})};l(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let r=`Configured requestMediaKeySystemAccess is not a function ${i}`;return or===null&&self.location.protocol==="http:"&&(r=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(r))}return i(e,t)}getMediaKeysPromise(e,t,i){const r=Fo(e,t,i,this.config.drmSystemOptions),n=this.keySystemAccessPromises[e];let a=n==null?void 0:n.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(r)}`),a=this.requestMediaKeySystemAccess(e,r);const o=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),a.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);const c=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),o.mediaKeys=l.createMediaKeys().then(u=>(this.log(`Media-keys created for "${e}"`),c.then(d=>d?this.setMediaKeysServerCertificate(u,e,d):u))),o.mediaKeys.catch(u=>{this.error(`Failed to create media-keys for "${e}"}: ${u}`)}),o.mediaKeys})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${Oe.hexDump(e.keyId||[])}`);const r=i.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:i,mediaKeysSession:r,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const i=this.createMediaKeySessionContext(e),r=this.getKeyIdString(t),n="cenc";this.keyIdToKeySessionPromise[r]=this.generateRequestWithPreferredKeySession(i,n,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return Oe.hexDump(e.keyId)}updateKeySession(e,t){var i;const r=e.mediaKeysSession;return this.log(`Updating key-session "${r.sessionId}" for keyID ${Oe.hexDump(((i=e.decryptdata)==null?void 0:i.keyId)||[])}
|
|
26
|
-
} (data length: ${t&&t.byteLength})`),r.update(t)}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,i)=>{const r=Si(this.config),n=e.map(rr).filter(a=>!!a&&r.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{const o=ar(a);o?t(o):i(new Error(`Unable to find format for key-system "${a}"`))}).catch(i)})}loadKey(e){const t=e.keyInfo.decryptdata,i=this.getKeyIdString(t),r=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${r}`);let n=this.keyIdToKeySessionPromise[i];return n||(n=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(t).then(({keySystem:a,mediaKeys:o})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${r}`),this.attemptSetMediaKeys(a,o).then(()=>{this.throwIfDestroyed();const l=this.createMediaKeySessionContext({keySystem:a,mediaKeys:o,decryptdata:t}),c="cenc";return this.generateRequestWithPreferredKeySession(l,c,t.pssh,"playlist-key")}))),n.catch(a=>this.handleError(a))),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof _e?this.hls.trigger(p.ERROR,e.data):this.hls.trigger(p.ERROR,{type:q.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){const t=this.getKeyIdString(e),i=this.keyIdToKeySessionPromise[t];if(!i){const r=rr(e.keyFormat),n=r?[r]:Si(this.config);return this.attemptKeySystemAccess(n)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=Si(this.config)),e.length===0)throw new _e({type:q.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){const{initDataType:t,initData:i}=e;if(this.debug(`"${e.type}" event: init data type: "${t}"`),i===null)return;let r,n;if(t==="sinf"&&this.config.drmSystems[ne.FAIRPLAY]){const u=ce(new Uint8Array(i));try{const d=Ti(JSON.parse(u).sinf),h=pr(new Uint8Array(d));if(!h)return;r=h.subarray(8,24),n=ne.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{const u=nl(i);if(u===null)return;u.version===0&&u.systemId===nr.WIDEVINE&&u.data&&(r=u.data.subarray(8,24)),n=Po(u.systemId)}if(!n||!r)return;const a=Oe.hexDump(r),{keyIdToKeySessionPromise:o,mediaKeySessions:l}=this;let c=o[a];for(let u=0;u<l.length;u++){const d=l[u],h=d.decryptdata;if(h.pssh||!h.keyId)continue;const f=Oe.hexDump(h.keyId);if(a===f||h.uri.replace(/-/g,"").indexOf(a)!==-1){c=o[f],delete o[f],h.pssh=new Uint8Array(i),h.keyId=r,c=o[a]=c.then(()=>this.generateRequestWithPreferredKeySession(d,t,i,"encrypted-event-key-match"));break}}c||(c=o[a]=this.getKeySystemSelectionPromise([n]).then(({keySystem:u,mediaKeys:d})=>{var h;this.throwIfDestroyed();const f=new vt("ISO-23001-7",a,(h=ar(u))!=null?h:"");return f.pssh=new Uint8Array(i),f.keyId=r,this.attemptSetMediaKeys(u,d).then(()=>{this.throwIfDestroyed();const m=this.createMediaKeySessionContext({decryptdata:f,keySystem:u,mediaKeys:d});return this.generateRequestWithPreferredKeySession(m,t,i,"encrypted-event-no-match")})})),c.catch(u=>this.handleError(u))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const r=Promise.all(i).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(r),r.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(r),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>i.indexOf(n)===-1)})}generateRequestWithPreferredKeySession(e,t,i,r){var n,a;const o=(n=this.config.drmSystems)==null||(a=n[e.keySystem])==null?void 0:a.generateRequest;if(o)try{const m=o.call(this.hls,t,i,e);if(!m)throw new Error("Invalid response from configured generateRequest filter");t=m.initDataType,i=e.decryptdata.pssh=m.initData?new Uint8Array(m.initData):null}catch(m){var l;if(this.warn(m.message),(l=this.hls)!=null&&l.config.debug)throw m}if(i===null)return this.log(`Skipping key-session request for "${r}" (no initData)`),Promise.resolve(e);const c=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${r}": ${c} (init data type: ${t} length: ${i?i.byteLength:null})`);const u=new Qi,d=e._onmessage=m=>{const g=e.mediaKeysSession;if(!g){u.emit("error",new Error("invalid state"));return}const{messageType:y,message:v}=m;this.log(`"${y}" message event for session "${g.sessionId}" message size: ${v.byteLength}`),y==="license-request"||y==="license-renewal"?this.renewLicense(e,v).catch(T=>{this.handleError(T),u.emit("error",T)}):y==="license-release"?e.keySystem===ne.FAIRPLAY&&(this.updateKeySession(e,Ei("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${y}"`)},h=e._onkeystatuseschange=m=>{if(!e.mediaKeysSession){u.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);const y=e.keyStatus;u.emit("keyStatus",y),y==="expired"&&(this.warn(`${e.keySystem} expired for key ${c}`),this.renewKeySession(e))};e.mediaKeysSession.addEventListener("message",d),e.mediaKeysSession.addEventListener("keystatuseschange",h);const f=new Promise((m,g)=>{u.on("error",g),u.on("keyStatus",y=>{y.startsWith("usable")?m():y==="output-restricted"?g(new _e({type:q.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):y==="internal-error"?g(new _e({type:q.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${y}"`)):y==="expired"?g(new Error("key expired while generating request")):this.warn(`unhandled key status change "${y}"`)})});return e.mediaKeysSession.generateRequest(t,i).then(()=>{var m;this.log(`Request generated for key-session "${(m=e.mediaKeysSession)==null?void 0:m.sessionId}" keyId: ${c}`)}).catch(m=>{throw new _e({type:q.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_SESSION,error:m,fatal:!1},`Error generating key-session request: ${m}`)}).then(()=>f).catch(m=>{throw u.removeAllListeners(),this.removeSession(e),m}).then(()=>(u.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,i)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${Oe.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${Oe.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){const t=this.config,i=t.loader,r=new i(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,o)=>{const l={responseType:"arraybuffer",url:n},c=t.certLoadPolicy.default,u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(h,f,m,g)=>{a(h.data)},onError:(h,f,m,g)=>{o(new _e({type:q.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:de({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`))},onTimeout:(h,f,m)=>{o(new _e({type:q.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(h,f,m)=>{o(new Error("aborted"))}};r.load(l,u,d)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,i){return new Promise((r,n)=>{e.setServerCertificate(i).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${i==null?void 0:i.byteLength}) on "${t}"`),r(e)}).catch(a=>{n(new _e({type:q.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(i=>this.updateKeySession(e,new Uint8Array(i)).catch(r=>{throw new _e({type:q.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:r,fatal:!0},r.message)}))}unpackPlayReadyKeyMessage(e,t){const i=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!i.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const r=new DOMParser().parseFromString(i,"application/xml"),n=r.querySelectorAll("HttpHeader");if(n.length>0){let u;for(let d=0,h=n.length;d<h;d++){var a,o;u=n[d];const f=(a=u.querySelector("name"))==null?void 0:a.textContent,m=(o=u.querySelector("value"))==null?void 0:o.textContent;f&&m&&e.setRequestHeader(f,m)}}const l=r.querySelector("Challenge"),c=l==null?void 0:l.textContent;if(!c)throw new Error("Cannot find <Challenge> in key message");return Ei(atob(c))}setupLicenseXHR(e,t,i,r){const n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,i,r)}).catch(a=>{if(!i.decryptdata)throw a;return e.open("POST",t,!0),n.call(this.hls,e,t,i,r)}).then(a=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:a||r})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:r}))}requestLicense(e,t){const i=this.config.keyLoadPolicy.default;return new Promise((r,n)=>{const a=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${a}`);const o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let l=o.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);const c=this.config.licenseResponseCallback;if(c)try{l=c.call(this.hls,o,a,e)}catch(u){this.error(u)}r(l)}else{const l=i.errorRetry,c=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>c||o.status>=400&&o.status<500)n(new _e({type:q.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{const u=c-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${u} attempts left`),this.requestLicense(e,t).then(r,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:l,licenseChallenge:c})=>{e.keySystem==ne.PLAYREADY&&(c=this.unpackPlayReadyKeyMessage(l,c)),l.send(c)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const i=t.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},vt.clearKeyUriToKeyIdMap();const i=t.length;ht.CDMCleanupPromise=Promise.all(t.map(r=>this.removeSession(r)).concat(e==null?void 0:e.setMediaKeys(null).catch(r=>{this.log(`Could not clear media keys: ${r}`)}))).then(()=>{i&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(r=>{this.log(`Could not close sessions and clear media keys: ${r}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){const i=t.reduce((r,n)=>(r.indexOf(n.keyFormat)===-1&&r.push(n.keyFormat),r),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:i}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const r=this.mediaKeySessions.indexOf(e);return r>-1&&this.mediaKeySessions.splice(r,1),t.remove().catch(n=>{this.log(`Could not remove session: ${n}`)}).then(()=>t.close()).catch(n=>{this.log(`Could not close session: ${n}`)})}}}ht.CDMCleanupPromise=void 0;class _e extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}var Te;(function(s){s.MANIFEST="m",s.AUDIO="a",s.VIDEO="v",s.MUXED="av",s.INIT="i",s.CAPTION="c",s.TIMED_TEXT="tt",s.KEY="k",s.OTHER="o"})(Te||(Te={}));var ds;(function(s){s.DASH="d",s.HLS="h",s.SMOOTH="s",s.OTHER="o"})(ds||(ds={}));var Je;(function(s){s.OBJECT="CMCD-Object",s.REQUEST="CMCD-Request",s.SESSION="CMCD-Session",s.STATUS="CMCD-Status"})(Je||(Je={}));const Au={[Je.OBJECT]:["br","d","ot","tb"],[Je.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[Je.SESSION]:["cid","pr","sf","sid","st","v"],[Je.STATUS]:["bs","rtp"]};class ft{constructor(e,t){this.value=void 0,this.params=void 0,Array.isArray(e)&&(e=e.map(i=>i instanceof ft?i:new ft(i))),this.value=e,this.params=t}}class Zn{constructor(e){this.description=void 0,this.description=e}}const Lu="Dict";function Cu(s){return Array.isArray(s)?JSON.stringify(s):s instanceof Map?"Map{}":s instanceof Set?"Set{}":typeof s=="object"?JSON.stringify(s):String(s)}function _u(s,e,t,i){return new Error(`failed to ${s} "${Cu(e)}" as ${t}`,{cause:i})}const Qn="Bare Item",Ru="Boolean",Du="Byte Sequence",Iu="Decimal",wu="Integer";function ku(s){return s<-999999999999999||999999999999999<s}const Pu=/[\x00-\x1f\x7f]+/,Fu="Token",Ou="Key";function Ue(s,e,t){return _u("serialize",s,e,t)}function Mu(s){if(typeof s!="boolean")throw Ue(s,Ru);return s?"?1":"?0"}function Nu(s){return btoa(String.fromCharCode(...s))}function Bu(s){if(ArrayBuffer.isView(s)===!1)throw Ue(s,Du);return`:${Nu(s)}:`}function Jn(s){if(ku(s))throw Ue(s,wu);return s.toString()}function $u(s){return`@${Jn(s.getTime()/1e3)}`}function ea(s,e){if(s<0)return-ea(-s,e);const t=Math.pow(10,e);if(Math.abs(s*t%1-.5)<Number.EPSILON){const r=Math.floor(s*t);return(r%2===0?r:r+1)/t}else return Math.round(s*t)/t}function Uu(s){const e=ea(s,3);if(Math.floor(Math.abs(e)).toString().length>12)throw Ue(s,Iu);const t=e.toString();return t.includes(".")?t:`${t}.0`}const Gu="String";function Hu(s){if(Pu.test(s))throw Ue(s,Gu);return`"${s.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Vu(s){return s.description||s.toString().slice(7,-1)}function ta(s){const e=Vu(s);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw Ue(e,Fu);return e}function hs(s){switch(typeof s){case"number":if(!z(s))throw Ue(s,Qn);return Number.isInteger(s)?Jn(s):Uu(s);case"string":return Hu(s);case"symbol":return ta(s);case"boolean":return Mu(s);case"object":if(s instanceof Date)return $u(s);if(s instanceof Uint8Array)return Bu(s);if(s instanceof Zn)return ta(s);default:throw Ue(s,Qn)}}function fs(s){if(/^[a-z*][a-z0-9\-_.*]*$/.test(s)===!1)throw Ue(s,Ou);return s}function ms(s){return s==null?"":Object.entries(s).map(([e,t])=>t===!0?`;${fs(e)}`:`;${fs(e)}=${hs(t)}`).join("")}function ia(s){return s instanceof ft?`${hs(s.value)}${ms(s.params)}`:hs(s)}function Ku(s){return`(${s.value.map(ia).join(" ")})${ms(s.params)}`}function zu(s,e={whitespace:!0}){if(typeof s!="object")throw Ue(s,Lu);const t=s instanceof Map?s.entries():Object.entries(s),i=e!=null&&e.whitespace?" ":"";return Array.from(t).map(([r,n])=>{n instanceof ft||(n=new ft(n));let a=fs(r);return n.value===!0?a+=ms(n.params):(a+="=",Array.isArray(n.value)?a+=Ku(n):a+=ia(n)),a}).join(`,${i}`)}function Wu(s,e){return zu(s,e)}const Yu=s=>s==="ot"||s==="sf"||s==="st",ju=s=>typeof s=="number"?z(s):s!=null&&s!==""&&s!==!1;function qu(s,e){const t=new URL(s),i=new URL(e);if(t.origin!==i.origin)return s;const r=t.pathname.split("/").slice(1),n=i.pathname.split("/").slice(1,-1);for(;r[0]===n[0];)r.shift(),n.shift();for(;n.length;)n.shift(),r.unshift("..");return r.join("/")}function Xu(){try{return crypto.randomUUID()}catch{try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{const n=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(r=="x"?n:n&3|8).toString(16)})}}}const ti=s=>Math.round(s),Zu=(s,e)=>(e!=null&&e.baseUrl&&(s=qu(s,e.baseUrl)),encodeURIComponent(s)),ii=s=>ti(s/100)*100,Qu={br:ti,d:ti,bl:ii,dl:ii,mtp:ii,nor:Zu,rtp:ii,tb:ti};function Ju(s,e){const t={};if(s==null||typeof s!="object")return t;const i=Object.keys(s).sort(),r=oe({},Qu,e==null?void 0:e.formatters),n=e==null?void 0:e.filter;return i.forEach(a=>{if(n!=null&&n(a))return;let o=s[a];const l=r[a];l&&(o=l(o,e)),!(a==="v"&&o===1)&&(a=="pr"&&o===1||ju(o)&&(Yu(a)&&typeof o=="string"&&(o=new Zn(o)),t[a]=o))}),t}function sa(s,e={}){return s?Wu(Ju(s,e),oe({whitespace:!1},e)):""}function ed(s,e={}){if(!s)return{};const t=Object.entries(s),i=Object.entries(Au).concat(Object.entries((e==null?void 0:e.customHeaderMap)||{})),r=t.reduce((n,a)=>{var o,l;const[c,u]=a,d=((o=i.find(h=>h[1].includes(c)))==null?void 0:o[0])||Je.REQUEST;return(l=n[d])!=null||(n[d]={}),n[d][c]=u,n},{});return Object.entries(r).reduce((n,[a,o])=>(n[a]=sa(o,e),n),{})}function td(s,e,t){return oe(s,ed(e,t))}const id="CMCD";function sd(s,e={}){if(!s)return"";const t=sa(s,e);return`${id}=${encodeURIComponent(t)}`}const ra=/CMCD=[^&#]+/;function rd(s,e,t){const i=sd(e,t);if(!i)return s;if(ra.test(s))return s.replace(ra,i);const r=s.includes("?")?"&":"?";return`${s}${r}${i}`}class nd{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=r=>{try{this.apply(r,{ot:Te.MANIFEST,su:!this.initialized})}catch(n){S.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=r=>{try{const n=r.frag,a=this.hls.levels[n.level],o=this.getObjectType(n),l={d:n.duration*1e3,ot:o};(o===Te.VIDEO||o===Te.AUDIO||o==Te.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(r,l)}catch(n){S.warn("Could not generate segment CMCD data.",n)}},this.hls=e;const t=this.config=e.config,{cmcd:i}=t;i!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||Xu(),this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.includeKeys=i.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHED,this.onMediaDetached,this),e.on(p.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHED,this.onMediaDetached,this),e.off(p.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var i,r;this.audioBuffer=(i=t.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(r=t.tracks.video)==null?void 0:r.buffer}createData(){var e;return{v:1,sf:ds.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){oe(t,this.createData());const i=t.ot===Te.INIT||t.ot===Te.VIDEO||t.ot===Te.MUXED;this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);const{includeKeys:r}=this;r&&(t=Object.keys(t).reduce((n,a)=>(r.includes(a)&&(n[a]=t[a]),n),{})),this.useHeaders?(e.headers||(e.headers={}),td(e.headers,t)):e.url=rd(e.url,t)}getObjectType(e){const{type:t}=e;if(t==="subtitle")return Te.TIMED_TEXT;if(e.sn==="initSegment")return Te.INIT;if(t==="audio")return Te.AUDIO;if(t==="main")return this.hls.audioTracks.length?Te.VIDEO:Te.MUXED}getTopBandwidth(e){let t=0,i;const r=this.hls;if(e===Te.AUDIO)i=r.audioTracks;else{const n=r.maxAutoLevel,a=n>-1?n+1:r.levels.length;i=r.levels.slice(0,a)}for(const n of i)n.bitrate>t&&(t=n.bitrate);return t>0?t:NaN}getBufferLength(e){const t=this.hls.media,i=e===Te.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!t?NaN:se.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,i=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}}const ad=3e5;class od{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=S.log.bind(S,"[content-steering]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.ERROR,this.onError,this))}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter(i=>i!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:i}=t;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:i}=t;if((i==null?void 0:i.action)===pe.SendAlternateToPenaltyBox&&i.flags===Ie.MoveAllAlternatesMatchingHost){const r=this.levels;let n=this.pathwayPriority,a=this.pathwayId;if(t.context){const{groupId:o,pathwayId:l,type:c}=t.context;o&&r?a=this.getPathwayForGroupId(o,c,a):l&&(a=l)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!n&&r&&(n=r.reduce((o,l)=>(o.indexOf(l.pathwayId)===-1&&o.push(l.pathwayId),o),[])),n&&n.length>1&&(this.updatePathwayPriority(n),i.resolved=this.pathwayId!==a),i.resolved||S.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${r&&r.length} priorities: ${JSON.stringify(n)} penalized: ${JSON.stringify(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){const i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i}return t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t;const i=this.penalizedPathways,r=performance.now();Object.keys(i).forEach(n=>{r-i[n]>ad&&delete i[n]});for(let n=0;n<e.length;n++){const a=e[n];if(a in i)continue;if(a===this.pathwayId)return;const o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,zr(t),this.hls.trigger(p.LEVELS_UPDATED,{levels:t});const c=this.hls.levels[o];l&&c&&this.levels&&(c.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&c.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${c.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,i){const r=this.getLevelsForPathway(i).concat(this.levels||[]);for(let n=0;n<r.length;n++)if(t===ee.AUDIO_TRACK&&r[n].hasAudioGroup(e)||t===ee.SUBTITLE_TRACK&&r[n].hasSubtitleGroup(e))return r[n].pathwayId;return i}clonePathways(e){const t=this.levels;if(!t)return;const i={},r={};e.forEach(n=>{const{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=n;if(t.some(u=>u.pathwayId===a))return;const c=this.getLevelsForPathway(o).map(u=>{const d=new ae(u.attrs);d["PATHWAY-ID"]=a;const h=d.AUDIO&&`${d.AUDIO}_clone_${a}`,f=d.SUBTITLES&&`${d.SUBTITLES}_clone_${a}`;h&&(i[d.AUDIO]=h,d.AUDIO=h),f&&(r[d.SUBTITLES]=f,d.SUBTITLES=f);const m=aa(u.uri,d["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),g=new st({attrs:d,audioCodec:u.audioCodec,bitrate:u.bitrate,height:u.height,name:u.name,url:m,videoCodec:u.videoCodec,width:u.width});if(u.audioGroups)for(let y=1;y<u.audioGroups.length;y++)g.addGroupId("audio",`${u.audioGroups[y]}_clone_${a}`);if(u.subtitleGroups)for(let y=1;y<u.subtitleGroups.length;y++)g.addGroupId("text",`${u.subtitleGroups[y]}_clone_${a}`);return g});t.push(...c),na(this.audioTracks,i,l,a),na(this.subtitleTracks,r,l,a)})}loadSteeringManifest(e){const t=this.hls.config,i=t.loader;this.loader&&this.loader.destroy(),this.loader=new i(t);let r;try{r=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(r.protocol!=="data:"){const u=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;r.searchParams.set("_HLS_pathway",this.pathwayId),r.searchParams.set("_HLS_throughput",""+u)}const n={responseType:"json",url:r.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},c={onSuccess:(u,d,h,f)=>{this.log(`Loaded steering manifest: "${r}"`);const m=u.data;if(m.VERSION!==1){this.log(`Steering VERSION ${m.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=m.TTL;const{"RELOAD-URI":g,"PATHWAY-CLONES":y,"PATHWAY-PRIORITY":v}=m;if(g)try{this.uri=new self.URL(g,r).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${g}`);return}this.scheduleRefresh(this.uri||h.url),y&&this.clonePathways(y);const T={steeringManifest:m,url:r.toString()};this.hls.trigger(p.STEERING_MANIFEST_LOADED,T),v&&this.updatePathwayPriority(v)},onError:(u,d,h,f)=>{if(this.log(`Error loading steering manifest: ${u.code} ${u.text} (${d.url})`),this.stopLoad(),u.code===410){this.enabled=!1,this.log(`Steering manifest ${d.url} no longer available`);return}let m=this.timeToLoad*1e3;if(u.code===429){const g=this.loader;if(typeof(g==null?void 0:g.getResponseHeader)=="function"){const y=g.getResponseHeader("Retry-After");y&&(m=parseFloat(y)*1e3)}this.log(`Steering manifest ${d.url} rate limited`);return}this.scheduleRefresh(this.uri||d.url,m)},onTimeout:(u,d,h)=>{this.log(`Timeout loading steering manifest (${d.url})`),this.scheduleRefresh(this.uri||d.url)}};this.log(`Requesting steering manifest: ${r}`),this.loader.load(n,l,c)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var i;const r=(i=this.hls)==null?void 0:i.media;if(r&&!r.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}}function na(s,e,t,i){s&&Object.keys(e).forEach(r=>{const n=s.filter(a=>a.groupId===r).map(a=>{const o=oe({},a);return o.details=void 0,o.attrs=new ae(o.attrs),o.url=o.attrs.URI=aa(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[r],o.attrs["PATHWAY-ID"]=i,o});s.push(...n)})}function aa(s,e,t,i){const{HOST:r,PARAMS:n,[t]:a}=i;let o;e&&(o=a==null?void 0:a[e],o&&(s=o));const l=new self.URL(s);return r&&!o&&(l.host=r),n&&Object.keys(n).sort().forEach(c=>{c&&l.searchParams.set(c,n[c])}),l.href}const ld=/^age:\s*[\d.]+\s*$/im;class oa{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new Dt,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null,this.stats=null}abortInternal(){const e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const i=this.loader=new self.XMLHttpRequest,r=this.stats;r.loading.first=0,r.loaded=0,r.aborted=!1;const n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!this.stats.aborted)return n(i,t.url)}).catch(a=>(i.open("GET",t.url,!0),n(i,t.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(a=>{this.callbacks.onError({code:i.status,text:a.message},t,i,r)}):this.openAndSendXhr(i,t,e)}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,!0);const r=t.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=i.loadPolicy;if(r)for(const o in r)e.setRequestHeader(o,r[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=n&&z(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:i}=this;if(!e||!t)return;const r=t.readyState,n=this.config;if(!i.aborted&&r>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),r===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const a=t.status,o=t.responseType!=="text";if(a>=200&&a<300&&(o&&t.response||t.responseText!==null)){i.loading.end=Math.max(self.performance.now(),i.loading.first);const l=o?t.response:t.responseText,c=t.responseType==="arraybuffer"?l.byteLength:l.length;if(i.loaded=i.total=c,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first),!this.callbacks)return;const u=this.callbacks.onProgress;if(u&&u(i,e,l,t),!this.callbacks)return;const d={url:t.responseURL,data:l,code:a};this.callbacks.onSuccess(d,i,e,t)}else{const l=n.loadPolicy.errorRetry,c=i.retry,u={url:e.url,data:void 0,code:a};Gt(l,c,!1,u)?this.retry(l):(S.error(`${a} while loading ${e.url}`),this.callbacks.onError({code:a,text:t.statusText},e,t,i))}}}loadtimeout(){var e;const t=(e=this.config)==null?void 0:e.loadPolicy.timeoutRetry,i=this.stats.retry;if(Gt(t,i,!0))this.retry(t);else{var r;S.warn(`timeout while loading ${(r=this.context)==null?void 0:r.url}`);const n=this.callbacks;n&&(this.abortInternal(),n.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:i}=this;this.retryDelay=Bi(e,i.retry),i.retry++,S.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t==null?void 0:t.url}, retrying ${i.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&ld.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}function cd(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const ud=/(\d+)-(\d+)\/(\d+)/;class la{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||md,this.controller=new self.AbortController,this.stats=new Dt}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,i){const r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now();const n=dd(e,this.controller.signal),a=i.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:c,maxLoadTimeMs:u}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=c&&z(c)?c:u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(r,e,this.response)},t.timeout),self.fetch(this.request).then(d=>{this.response=this.loader=d;const h=Math.max(self.performance.now(),r.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(r,e,this.response)},u-(h-r.loading.start)),!d.ok){const{status:f,statusText:m}=d;throw new gd(m||"fetch, bad network response",f,d)}return r.loading.first=h,r.total=fd(d.headers)||r.total,a&&z(t.highWaterMark)?this.loadProgressively(d,r,e,t.highWaterMark,a):o?d.arrayBuffer():e.responseType==="json"?d.json():d.text()}).then(d=>{const h=this.response;if(!h)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first);const f=d[l];f&&(r.loaded=r.total=f);const m={url:h.url,data:d,code:h.status};a&&!z(t.highWaterMark)&&a(r,e,d,h),i.onSuccess(m,r,e,h)}).catch(d=>{if(self.clearTimeout(this.requestTimeout),r.aborted)return;const h=d&&d.code||0,f=d?d.message:null;i.onError({code:h,text:f},e,d?d.details:null,r)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,i,r=0,n){const a=new rn,o=e.body.getReader(),l=()=>o.read().then(c=>{if(c.done)return a.dataLength&&n(t,i,a.flush(),e),Promise.resolve(new ArrayBuffer(0));const u=c.value,d=u.length;return t.loaded+=d,d<r||a.dataLength?(a.push(u),a.dataLength>=r&&n(t,i,a.flush(),e)):n(t,i,u,e),l()}).catch(()=>Promise.reject());return l()}}function dd(s,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(oe({},s.headers))};return s.rangeEnd&&t.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),t}function hd(s){const e=ud.exec(s);if(e)return parseInt(e[2])-parseInt(e[1])+1}function fd(s){const e=s.get("Content-Range");if(e){const i=hd(e);if(z(i))return i}const t=s.get("Content-Length");if(t)return parseInt(t)}function md(s,e){return new self.Request(s.url,e)}class gd extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}}const pd=/\s/,yd={newCue(s,e,t,i){const r=[];let n,a,o,l,c;const u=self.VTTCue||self.TextTrackCue;for(let h=0;h<i.rows.length;h++)if(n=i.rows[h],o=!0,l=0,c="",!n.isEmpty()){var d;for(let g=0;g<n.chars.length;g++)pd.test(n.chars[g].uchar)&&o?l++:(c+=n.chars[g].uchar,o=!1);n.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;const f=Gn(c.trim()),m=ns(e,t,f);s!=null&&(d=s.cues)!=null&&d.getCueById(m)||(a=new u(e,t,f),a.id=m,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),r.push(a))}return s&&r.length&&(r.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),r.forEach(h=>Nr(s,h))),r}},vd={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},ca=de(de({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:oa,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:jl,bufferController:Qc,capLevelController:us,errorController:Ml,fpsController:bu,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:or,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,certLoadPolicy:{default:vd},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},xd()),{},{subtitleStreamController:jc,subtitleTrackController:Xc,timelineController:Eu,audioStreamController:Wc,audioTrackController:Yc,emeController:ht,cmcdController:nd,contentSteeringController:od});function xd(){return{cueHandler:yd,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function Td(s,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const t=gs(s),i=["manifest","level","frag"],r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.forEach(n=>{const a=`${n==="level"?"playlist":n}LoadPolicy`,o=e[a]===void 0,l=[];r.forEach(c=>{const u=`${n}Loading${c}`,d=e[u];if(d!==void 0&&o){l.push(u);const h=t[a].default;switch(e[a]={default:h},c){case"TimeOut":h.maxLoadTimeMs=d,h.maxTimeToFirstByteMs=d;break;case"MaxRetry":h.errorRetry.maxNumRetry=d,h.timeoutRetry.maxNumRetry=d;break;case"RetryDelay":h.errorRetry.retryDelayMs=d,h.timeoutRetry.retryDelayMs=d;break;case"MaxRetryTimeout":h.errorRetry.maxRetryDelayMs=d,h.timeoutRetry.maxRetryDelayMs=d;break}}}),l.length&&S.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(e[a])}`)}),de(de({},t),e)}function gs(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(gs):Object.keys(s).reduce((e,t)=>(e[t]=gs(s[t]),e),{}):s}function Ed(s){const e=s.loader;e!==la&&e!==oa?(S.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1):cd()&&(s.loader=la,s.progressive=!0,s.enableSoftwareAES=!0,S.log("[config]: Progressive streaming enabled, using FetchLoader"))}let ps;class Sd extends Ui{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this),e.on(p.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this),e.off(p.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const i=this.hls.config.preferManagedMediaSource,r=[],n={},a={};let o=!1,l=!1,c=!1;t.levels.forEach(u=>{var d,h;const f=u.attrs;let{audioCodec:m,videoCodec:g}=u;((d=m)==null?void 0:d.indexOf("mp4a.40.34"))!==-1&&(ps||(ps=/chrome|firefox/i.test(navigator.userAgent)),ps&&(u.audioCodec=m=void 0)),m&&(u.audioCodec=m=Mt(m,i)),((h=g)==null?void 0:h.indexOf("avc1"))===0&&(g=u.videoCodec=dl(g));const{width:y,height:v,unknownCodecs:T}=u;if(o||(o=!!(y&&v)),l||(l=!!g),c||(c=!!m),T!=null&&T.length||m&&!Di(m,"audio",i)||g&&!Di(g,"video",i))return;const{CODECS:x,"FRAME-RATE":L,"HDCP-LEVEL":E,"PATHWAY-ID":k,RESOLUTION:C,"VIDEO-RANGE":B}=f,b=`${`${k||"."}-`}${u.bitrate}-${C}-${L}-${x}-${B}-${E}`;if(n[b])if(n[b].uri!==u.url&&!u.attrs["PATHWAY-ID"]){const R=a[b]+=1;u.attrs["PATHWAY-ID"]=new Array(R+1).join(".");const P=new st(u);n[b]=P,r.push(P)}else n[b].addGroupId("audio",f.AUDIO),n[b].addGroupId("text",f.SUBTITLES);else{const R=new st(u);n[b]=R,a[b]=1,r.push(R)}}),this.filterAndSortMediaOptions(r,t,o,l,c)}filterAndSortMediaOptions(e,t,i,r,n){let a=[],o=[],l=e;if((i||r)&&n&&(l=l.filter(({videoCodec:m,videoRange:g,width:y,height:v})=>(!!m||!!(y&&v))&&Al(g))),l.length===0){Promise.resolve().then(()=>{if(this.hls){t.levels.length&&this.warn(`One or more CODECS in variant not supported: ${JSON.stringify(t.levels[0].attrs)}`);const m=new Error("no level with compatible codecs found in manifest");this.hls.trigger(p.ERROR,{type:q.MEDIA_ERROR,details:D.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:m,reason:m.message})}});return}if(t.audioTracks){const{preferManagedMediaSource:m}=this.hls.config;a=t.audioTracks.filter(g=>!g.audioCodec||Di(g.audioCodec,"audio",m)),ua(a)}t.subtitles&&(o=t.subtitles,ua(o));const c=l.slice(0);l.sort((m,g)=>{if(m.attrs["HDCP-LEVEL"]!==g.attrs["HDCP-LEVEL"])return(m.attrs["HDCP-LEVEL"]||"")>(g.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&m.height!==g.height)return m.height-g.height;if(m.frameRate!==g.frameRate)return m.frameRate-g.frameRate;if(m.videoRange!==g.videoRange)return $t.indexOf(m.videoRange)-$t.indexOf(g.videoRange);if(m.videoCodec!==g.videoCodec){const y=Ar(m.videoCodec),v=Ar(g.videoCodec);if(y!==v)return v-y}if(m.uri===g.uri&&m.codecSet!==g.codecSet){const y=Ot(m.codecSet),v=Ot(g.codecSet);if(y!==v)return v-y}return m.averageBitrate!==g.averageBitrate?m.averageBitrate-g.averageBitrate:0});let u=c[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==c.length)){for(let m=0;m<c.length;m++)if(c[m].pathwayId===l[0].pathwayId){u=c[m];break}}this._levels=l;for(let m=0;m<l.length;m++)if(l[m]===u){var d;this._firstLevel=m;const g=u.bitrate,y=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${g}`),((d=this.hls.userConfig)==null?void 0:d.abrEwmaDefaultEstimate)===void 0){const v=Math.min(g,this.hls.config.abrEwmaDefaultEstimateMax);v>y&&y===ca.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=v)}break}const h=n&&!r,f={levels:l,audioTracks:a,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:r,altAudio:!h&&a.some(m=>!!m.url)};this.hls.trigger(p.MANIFEST_PARSED,f),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){const u=new Error("invalid level idx"),d=e<0;if(this.hls.trigger(p.ERROR,{type:q.OTHER_ERROR,details:D.LEVEL_SWITCH_ERROR,level:e,fatal:d,error:u,reason:u.message}),d)return;e=Math.min(e,t.length-1)}const i=this.currentLevelIndex,r=this.currentLevel,n=r?r.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,i===e&&a.details&&r&&n===o)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${o?" with Pathway "+o:""} from level ${i}${n?" with Pathway "+n:""}`);const l={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(p.LEVEL_SWITCHING,l);const c=a.details;if(!c||c.live){const u=this.switchParams(a.uri,r==null?void 0:r.details);this.loadPlaylist(u)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){const e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){t.fatal||!t.context||t.context.type===ee.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===j.MAIN){const i=t.elementaryStreams;if(!Object.keys(i).some(n=>!!i[n]))return;const r=this._levels[t.level];r!=null&&r.loadError&&(this.log(`Resetting level error count of ${r.loadError} on frag buffered`),r.loadError=0)}}onLevelLoaded(e,t){var i;const{level:r,details:n}=t,a=this._levels[r];if(!a){var o;this.warn(`Invalid level index ${r}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=!0);return}r===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0),this.playlistLoaded(r,t,a.details)):(i=t.deliveryDirectives)!=null&&i.skip&&(n.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist();const t=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){let r=i.uri;if(e)try{r=e.addDirectives(r)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}const n=i.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${n?" Pathway "+n:""} ${r}`),this.clearTimer(),this.hls.trigger(p.LEVEL_LOADING,{url:r,level:t,pathwayId:i.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;const i=this._levels.filter((r,n)=>n!==e?!0:(this.steering&&this.steering.removeLevel(r),r===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,r.details&&r.details.fragments.forEach(a=>a.level=-1)),!1));zr(i),this._levels=i,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(p.LEVELS_UPDATED,{levels:i})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:i}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(p.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}function ua(s){const e={};s.forEach(t=>{const i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++})}class bd{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const i in this.keyUriToKeyInfo){const r=this.keyUriToKeyInfo[i].loader;if(r){var t;if(e&&e!==((t=r.context)==null?void 0:t.frag.type))return;r.abort()}}}detach(){for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=D.KEY_LOAD_ERROR,i,r,n){return new Ve({type:q.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:i,networkDetails:r})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){const{sn:i,cc:r}=e;for(let n=0;n<t.length;n++){const a=t[n];if(r<=a.cc&&(i==="initSegment"||a.sn==="initSegment"||i<a.sn)){this.emeController.selectKeySystemFormat(a).then(o=>{a.setKeyFormat(o)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var i,r;t&&e.setKeyFormat(t);const n=e.decryptdata;if(!n){const c=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,c))}const a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if((i=o)!=null&&i.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if((r=o)!=null&&r.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(c=>(n.key=c.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[a]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){const i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const r=this.emeController.loadKey(i);if(r)return(e.keyLoadPromise=r.then(n=>(e.mediaKeySessionContext=n,i))).catch(n=>{throw e.keyLoadPromise=null,n})}return Promise.resolve(i)}loadKeyHTTP(e,t){const i=this.config,r=i.loader,n=new r(i);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,o)=>{const l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},c=i.keyLoadPolicy.default,u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(h,f,m,g)=>{const{frag:y,keyInfo:v,url:T}=m;if(!y.decryptdata||v!==this.keyUriToKeyInfo[T])return o(this.createKeyLoadError(y,D.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),g));v.decryptdata.key=y.decryptdata.key=new Uint8Array(h.data),y.keyLoader=null,v.loader=null,a({frag:y,keyInfo:v})},onError:(h,f,m,g)=>{this.resetLoader(f),o(this.createKeyLoadError(t,D.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),m,de({url:l.url,data:void 0},h)))},onTimeout:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,D.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m))},onAbort:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,D.INTERNAL_ABORTED,new Error("key loading aborted"),m))}};n.load(l,u,d)})}resetLoader(e){const{frag:t,keyInfo:i,url:r}=e,n=i.loader;t.keyLoader===n&&(t.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[r],n&&n.destroy()}}function da(){return self.SourceBuffer||self.WebKitSourceBuffer}function ha(){if(!tt())return!1;const e=da();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function Ad(){if(!ha())return!1;const s=tt();return typeof(s==null?void 0:s.isTypeSupported)=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>s.isTypeSupported(xt(e,"video")))||["mp4a.40.2","fLaC"].some(e=>s.isTypeSupported(xt(e,"audio"))))}function Ld(){var s;const e=da();return typeof(e==null||(s=e.prototype)==null?void 0:s.changeType)=="function"}const Cd=250,si=2,_d=.1,Rd=.05;class Dd{constructor(e,t,i,r){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=i,this.hls=r}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){const{config:i,media:r,stalled:n}=this;if(r===null)return;const{currentTime:a,seeking:o}=r,l=this.seeking&&!o,c=!this.seeking&&o;if(this.seeking=o,a!==e){if(this.moved=!0,o||(this.nudgeRetry=0),n!==null){if(this.stallReported){const y=self.performance.now()-n;S.warn(`playback not stuck anymore @${a}, after ${Math.round(y)}ms`),this.stallReported=!1}this.stalled=null}return}if(c||l){this.stalled=null;return}if(r.paused&&!o||r.ended||r.playbackRate===0||!se.getBuffered(r).length){this.nudgeRetry=0;return}const u=se.bufferInfo(r,a,0),d=u.nextStart||0;if(o){const y=u.len>si,v=!d||t&&t.start<=a||d-a>si&&!this.fragmentTracker.getPartialFragment(a);if(y||v)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var h;if(!(u.len>0)&&!d)return;const v=Math.max(d,u.start||0)-a,T=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,L=(T==null||(h=T.details)==null?void 0:h.live)?T.details.targetduration*2:si,E=this.fragmentTracker.getPartialFragment(a);if(v>0&&(v<=L||E)){r.paused||this._trySkipBufferHole(E);return}}const f=self.performance.now();if(n===null){this.stalled=f;return}const m=f-n;if(!o&&m>=Cd&&(this._reportStall(u),!this.media))return;const g=se.bufferInfo(r,a,i.maxBufferHole);this._tryFixBufferStall(g,m)}_tryFixBufferStall(e,t){const{config:i,fragmentTracker:r,media:n}=this;if(n===null)return;const a=n.currentTime,o=r.getPartialFragment(a);o&&(this._trySkipBufferHole(o)||!this.media)||(e.len>i.maxBufferHole||e.nextStart&&e.nextStart-a<i.maxBufferHole)&&t>i.highBufferWatchdogPeriod*1e3&&(S.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){const{hls:t,media:i,stallReported:r}=this;if(!r&&i){this.stallReported=!0;const n=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(e)})`);S.warn(n.message),t.trigger(p.ERROR,{type:q.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}}_trySkipBufferHole(e){const{config:t,hls:i,media:r}=this;if(r===null)return 0;const n=r.currentTime,a=se.bufferInfo(r,n,0),o=n<a.start?a.start:a.nextStart;if(o){const l=a.len<=t.maxBufferHole,c=a.len>0&&a.len<1&&r.readyState<3,u=o-n;if(u>0&&(l||c)){if(u>t.maxBufferHole){const{fragmentTracker:h}=this;let f=!1;if(n===0){const m=h.getAppendedFrag(0,j.MAIN);m&&o<m.end&&(f=!0)}if(!f){const m=e||h.getAppendedFrag(n,j.MAIN);if(m){let g=!1,y=m.end;for(;y<o;){const v=h.getPartialFragment(y);if(v)y+=v.duration;else{g=!0;break}}if(g)return 0}}}const d=Math.max(o+Rd,n+_d);if(S.warn(`skipping hole, adjusting currentTime from ${n} to ${d}`),this.moved=!0,this.stalled=null,r.currentTime=d,e&&!e.gap){const h=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${d}`);i.trigger(p.ERROR,{type:q.MEDIA_ERROR,details:D.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:h,reason:h.message,frag:e})}return d}}return 0}_tryNudgeBuffer(){const{config:e,hls:t,media:i,nudgeRetry:r}=this;if(i===null)return;const n=i.currentTime;if(this.nudgeRetry++,r<e.nudgeMaxRetry){const a=n+(r+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${n} to ${a}`);S.warn(o.message),i.currentTime=a,t.trigger(p.ERROR,{type:q.MEDIA_ERROR,details:D.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{const a=new Error(`Playhead still not moving while enough data buffered @${n} after ${e.nudgeMaxRetry} nudges`);S.error(a.message),t.trigger(p.ERROR,{type:q.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}}const Id=100;class wd extends Vi{constructor(e,t,i){super(e,t,i,"[stream-controller]",j.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(p.ERROR,this.onError,this),e.on(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(p.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(p.BUFFER_CREATED,this.onBufferCreated,this),e.on(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(p.ERROR,this.onError,this),e.off(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(p.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(p.BUFFER_CREATED,this.onBufferCreated,this),e.off(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying()}startLoad(e){if(this.levels){const{lastCurrentTime:t,hls:i}=this;if(this.stopLoad(),this.setInterval(Id),this.level=-1,!this.startFragRequested){let r=i.startLevel;r===-1&&(i.config.testBandwidth&&this.levels.length>1?(r=0,this.bitrateTest=!0):r=i.firstAutoLevel),i.nextLoadLevel=r,this.level=i.loadLevel,this.loadedmetadata=!1}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=M.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=M.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case M.WAITING_LEVEL:{const{levels:t,level:i}=this,r=t==null?void 0:t[i],n=r==null?void 0:r.details;if(n&&(!n.live||this.levelLastLoaded===r)){if(this.waitForCdnTuneIn(n))break;this.state=M.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=M.IDLE;break}break}case M.FRAG_LOADING_WAITING_RETRY:{var e;const t=self.performance.now(),i=this.retryDate;if(!i||t>=i||(e=this.media)!=null&&e.seeking){const{levels:r,level:n}=this,a=r==null?void 0:r[n];this.resetStartWhenNotLoaded(a||null),this.state=M.IDLE}}break}this.state===M.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:i,media:r}=this;if(t===null||!r&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;const n=e.nextLoadLevel;if(!(i!=null&&i[n]))return;const a=i[n],o=this.getMainFwdBufferInfo();if(o===null)return;const l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){const g={};this.altAudio&&(g.type="video"),this.hls.trigger(p.BUFFER_EOS,g),this.state=M.ENDED;return}e.loadLevel!==n&&e.manualLevel===-1&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;const c=a.details;if(!c||this.state===M.WAITING_LEVEL||c.live&&this.levelLastLoaded!==a){this.level=n,this.state=M.WAITING_LEVEL;return}const u=o.len,d=this.getMaxBufferLength(a.maxBitrate);if(u>=d)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);const h=this.backtrackFragment?this.backtrackFragment.start:o.end;let f=this.getNextFragment(h,c);if(this.couldBacktrack&&!this.fragPrevious&&f&&f.sn!=="initSegment"&&this.fragmentTracker.getState(f)!==he.OK){var m;const y=((m=this.backtrackFragment)!=null?m:f).sn-c.startSN,v=c.fragments[y-1];v&&f.cc===v.cc&&(f=v,this.fragmentTracker.removeFragment(v))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,h)){if(!f.gap){const y=this.audioOnly&&!this.altAudio?te.AUDIO:te.VIDEO,v=(y===te.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;v&&this.afterBufferFlushed(v,y,j.MAIN)}f=this.getNextFragmentLoopLoading(f,c,o,j.MAIN,d)}f&&(f.initSegment&&!f.initSegment.data&&!this.bitrateTest&&(f=f.initSegment),this.loadFragment(f,a,h))}loadFragment(e,t,i){const r=this.fragmentTracker.getState(e);this.fragCurrent=e,r===he.NOT_LOADED||r===he.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,i)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,j.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(t!=null&&t.readyState){let i;const r=this.getAppendedFrag(t.currentTime);r&&r.start>1&&this.flushMainBuffer(0,r.start-1);const n=this.getLevelDetails();if(n!=null&&n.live){const o=this.getMainFwdBufferInfo();if(!o||o.len<n.targetduration*2)return}if(!t.paused&&e){const o=this.hls.nextLoadLevel,l=e[o],c=this.fragLastKbps;c&&this.fragCurrent?i=this.fragCurrent.duration*l.maxBitrate/(1e3*c)+1:i=0}else i=0;const a=this.getBufferedFrag(t.currentTime+i);if(a){const o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();const l=o.maxStartPTS?o.maxStartPTS:o.start,c=o.duration,u=Math.max(a.end,l+Math.min(Math.max(c-this.config.maxFragLookUpTolerance,c*(this.couldBacktrack?.5:.125)),c*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(u,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case M.KEY_LOADING:case M.FRAG_LOADING:case M.FRAG_LOADING_WAITING_RETRY:case M.PARSING:case M.PARSED:this.state=M.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const i=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new Dd(this.config,i,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const e=this.media,t=e?e.currentTime:null;z(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);const i=this.getMainFwdBufferInfo();if(i===null||i.len===0){this.warn(`Main forward buffer length on "seeked" event ${i?i.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(p.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1}onManifestParsed(e,t){let i=!1,r=!1;t.levels.forEach(n=>{const a=n.audioCodec;a&&(i=i||a.indexOf("mp4a.40.2")!==-1,r=r||a.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=i&&r&&!Ld(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:i}=this;if(!i||this.state!==M.IDLE)return;const r=i[t.level];(!r.details||r.details.live&&this.levelLastLoaded!==r||this.waitForCdnTuneIn(r.details))&&(this.state=M.WAITING_LEVEL)}onLevelLoaded(e,t){var i;const{levels:r}=this,n=t.level,a=t.details,o=a.totalduration;if(!r){this.warn(`Levels were reset while loading level ${n}`);return}this.log(`Level ${n} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);const l=r[n],c=this.fragCurrent;c&&(this.state===M.FRAG_LOADING||this.state===M.FRAG_LOADING_WAITING_RETRY)&&c.level!==t.level&&c.loader&&this.abortCurrentFrag();let u=0;if(a.live||(i=l.details)!=null&&i.live){var d;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;u=this.alignPlaylists(a,l.details,(d=this.levelLastLoaded)==null?void 0:d.details)}if(l.details=a,this.levelLastLoaded=l,this.hls.trigger(p.LEVEL_UPDATED,{details:a,level:n}),this.state===M.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=M.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,u),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:i,part:r,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const o=a[i.level],l=o.details;if(!l){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}const c=o.videoCodec,u=l.PTSKnown||!l.live,d=(t=i.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new Cn(this.hls,j.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=r?r.index:-1,g=m!==-1,y=new Gi(i.level,i.sn,i.stats.chunkCount,n.byteLength,m,g),v=this.initPTS[i.cc];f.push(n,d,h,c,i,r,l.totalduration,u,y,v)}onAudioTrackSwitching(e,t){const i=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const n=this.hls;i&&(n.trigger(p.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(p.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const i=t.id,r=!!this.hls.audioTracks[i].url;if(r){const n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=r,this.tick()}onBufferCreated(e,t){const i=t.tracks;let r,n,a=!1;for(const o in i){const l=i[o];if(l.id==="main"){if(n=o,r=l,o==="video"){const c=i[o];c&&(this.videoBuffer=c.buffer)}}else a=!0}a&&r?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:i,part:r}=t;if(i&&i.type!==j.MAIN)return;if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===M.PARSED&&(this.state=M.IDLE);return}const n=r?r.stats:i.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),i.sn!=="initSegment"&&(this.fragPrevious=i),this.fragBufferedComplete(i,r)}onError(e,t){var i;if(t.fatal){this.state=M.ERROR;return}switch(t.details){case D.FRAG_GAP:case D.FRAG_PARSING_ERROR:case D.FRAG_DECRYPT_ERROR:case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(j.MAIN,t);break;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===M.WAITING_LEVEL&&((i=t.context)==null?void 0:i.type)===ee.LEVEL&&(this.state=M.IDLE);break;case D.BUFFER_APPEND_ERROR:case D.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;if(t.details===D.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){const{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!se.getBuffered(e).length){const i=this.state!==M.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,i)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=M.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==te.AUDIO||this.audioOnly&&!this.altAudio){const i=(t===te.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,t,j.MAIN),this.tick()}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let i=this.startPosition;if(i>=0&&t<i){if(e.seeking){this.log(`could not seek to ${i}, already seeking at ${t}`);return}const r=se.getBuffered(e),a=(r.length?r.start(0):0)-i;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${a} to match buffer start`),i+=a,this.startPosition=i),this.log(`seek to target start position ${i} from current time ${t}`),e.currentTime=i}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(i=>{const{hls:r}=this;if(!i||this.fragContextChanged(e))return;t.fragmentError=0,this.state=M.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const n=e.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),r.trigger(p.FRAG_LOADED,i),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;const i="main",{hls:r}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}const{frag:l,part:c,level:u}=o,{video:d,text:h,id3:f,initSegment:m}=n,{details:g}=u,y=this.altAudio?void 0:n.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=M.PARSING,m){if(m!=null&&m.tracks){const x=l.initSegment||l;this._bufferInitSegment(u,m.tracks,x,a),r.trigger(p.FRAG_PARSING_INIT_SEGMENT,{frag:x,id:i,tracks:m.tracks})}const v=m.initPTS,T=m.timescale;z(v)&&(this.initPTS[l.cc]={baseTime:v,timescale:T},r.trigger(p.INIT_PTS_FOUND,{frag:l,id:i,initPTS:v,timescale:T}))}if(d&&g&&l.sn!=="initSegment"){const v=g.fragments[l.sn-1-g.startSN],T=l.sn===g.startSN,x=!v||l.cc>v.cc;if(n.independent!==!1){const{startPTS:L,endPTS:E,startDTS:k,endDTS:C}=d;if(c)c.elementaryStreams[d.type]={startPTS:L,endPTS:E,startDTS:k,endDTS:C};else if(d.firstKeyFrame&&d.independent&&a.id===1&&!x&&(this.couldBacktrack=!0),d.dropped&&d.independent){const B=this.getMainFwdBufferInfo(),_=(B?B.end:this.getLoadPosition())+this.config.maxBufferHole,b=d.firstKeyFramePTS?d.firstKeyFramePTS:L;if(!T&&_<b-this.config.maxBufferHole&&!x){this.backtrack(l);return}else x&&(l.gap=!0);l.setElementaryStreamInfo(d.type,l.start,E,l.start,C,!0)}else T&&L>si&&(l.gap=!0);l.setElementaryStreamInfo(d.type,L,E,k,C),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(d,l,c,a,T||x)}else if(T||x)l.gap=!0;else{this.backtrack(l);return}}if(y){const{startPTS:v,endPTS:T,startDTS:x,endDTS:L}=y;c&&(c.elementaryStreams[te.AUDIO]={startPTS:v,endPTS:T,startDTS:x,endDTS:L}),l.setElementaryStreamInfo(te.AUDIO,v,T,x,L),this.bufferFragmentData(y,l,c,a)}if(g&&f!=null&&(t=f.samples)!=null&&t.length){const v={id:i,frag:l,details:g,samples:f.samples};r.trigger(p.FRAG_PARSING_METADATA,v)}if(g&&h){const v={id:i,frag:l,details:g,samples:h.samples};r.trigger(p.FRAG_PARSING_USERDATA,v)}}_bufferInitSegment(e,t,i,r){if(this.state!==M.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;const{audio:n,video:a,audiovideo:o}=t;if(n){let l=e.audioCodec;const c=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5"),n.metadata.channelCount!==1&&c.indexOf("firefox")===-1&&(l="mp4a.40.5")),l&&l.indexOf("mp4a.40.5")!==-1&&c.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),n.levelCodec=l,n.id="main",this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${n.codec}]`)}a&&(a.levelCodec=e.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),this.hls.trigger(p.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{const u=t[l].initSegment;u!=null&&u.byteLength&&this.hls.trigger(p.BUFFER_APPENDING,{type:l,data:u,frag:i,part:null,chunkMeta:r,parent:i.type})}),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,j.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=M.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const i=e.currentTime;if(se.isBuffered(e,i)?t=this.getAppendedFrag(i):se.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;const r=this.fragPlaying,n=t.level;(!r||t.sn!==r.sn||r.level!==n)&&(this.fragPlaying=t,this.hls.trigger(p.FRAG_CHANGED,{frag:t}),(!r||r.level!==n)&&this.hls.trigger(p.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){const e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){const e=this.media;if(e){const t=e.currentTime,i=this.currentFrag;if(i&&z(t)&&z(i.programDateTime)){const r=i.programDateTime+(t-i.start)*1e3;return new Date(r)}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class be{static get version(){return"1.5.6"}static isMSESupported(){return ha()}static isSupported(){return Ad()}static getMediaSource(){return tt()}static get Events(){return p}static get ErrorTypes(){return q}static get ErrorDetails(){return D}static get DefaultConfig(){return be.defaultConfig?be.defaultConfig:ca}static set DefaultConfig(e){be.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new Qi,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,bo(e.debug||!1,"Hls instance");const t=this.config=Td(be.DefaultConfig,e);this.userConfig=e,t.progressive&&Ed(t);const{abrController:i,bufferController:r,capLevelController:n,errorController:a,fpsController:o}=t,l=new a(this),c=this.abrController=new i(this),u=this.bufferController=new r(this),d=this.capLevelController=new n(this),h=new o(this),f=new pl(this),m=new El(this),g=t.contentSteeringController,y=g?new g(this):null,v=this.levelController=new Sd(this,y),T=new Xl(this),x=new bd(this.config),L=this.streamController=new wd(this,T,x);d.setStreamController(L),h.setStreamController(L);const E=[f,v,L];y&&E.splice(1,0,y),this.networkControllers=E;const k=[c,u,d,h,m,T];this.audioTrackController=this.createController(t.audioTrackController,E);const C=t.audioStreamController;C&&E.push(new C(this,T,x)),this.subtitleTrackController=this.createController(t.subtitleTrackController,E);const B=t.subtitleStreamController;B&&E.push(new B(this,T,x)),this.createController(t.timelineController,k),x.emeController=this.emeController=this.createController(t.emeController,k),this.cmcdController=this.createController(t.cmcdController,k),this.latencyController=this.createController(Sl,k),this.coreComponents=k,E.push(l);const _=l.onErrorOut;typeof _=="function"&&this.on(p.ERROR,_,l)}createController(e,t){if(e){const i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i)}once(e,t,i=this){this._emitter.once(e,t,i)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,i=this,r){this._emitter.off(e,t,i,r)}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(i){if(S.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),!this.triggeringException){this.triggeringException=!0;const r=e===p.ERROR;this.trigger(p.ERROR,{type:q.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:r,event:e,error:i}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){S.log("destroy"),this.trigger(p.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){S.log("attachMedia"),this._media=e,this.trigger(p.MEDIA_ATTACHING,{media:e})}detachMedia(){S.log("detachMedia"),this.trigger(p.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();const t=this.media,i=this.url,r=this.url=yi.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,S.log(`loadSource:${r}`),t&&i&&(i!==r||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(p.MANIFEST_LOADING,{url:e})}startLoad(e=-1){S.log(`startLoad(${e})`),this.started=!0,this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){S.log("stopLoad"),this.started=!1,this.networkControllers.forEach(e=>{e.stopLoad()})}resumeBuffering(){this.started&&this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.startLoad(-1)})}pauseBuffering(){this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.stopLoad()})}swapAudioCodec(){S.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){S.log("recoverMediaError");const e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e){this.levelController.removeLevel(e)}get levels(){const e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){S.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){S.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){S.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){S.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){S.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(S.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){bl(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const i=e.length;for(let r=0;r<i;r++)if(e[r].maxBitrate>=t)return r;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:i}=this;let r;if(t===-1&&e!=null&&e.length?r=e.length-1:r=t,i)for(let n=r;n--;){const a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=i)return n}return r}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}setAudioOption(e){var t;return(t=this.audioTrackController)==null?void 0:t.setAudioOption(e)}setSubtitleOption(e){var t;return(t=this.subtitleTrackController)==null||t.setSubtitleOption(e),null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}be.defaultConfig=void 0;function ys(){const s=document;return!!(s.fullscreenElement||s.mozFullScreenElement||s.webkitFullscreenElement||s.msFullscreenElement)}function fa(s){if(ys())return new Promise(t=>t(null));const e=s;if(e.requestFullscreen)return e==null?void 0:e.requestFullscreen();if(e.mozRequestFullScreen)return e==null?void 0:e.mozRequestFullScreen();if(e.webkitRequestFullScreen)return e==null?void 0:e.webkitRequestFullScreen();if(e.msRequestFullscreen)return e==null?void 0:e.msRequestFullscreen()}function ma(){if(!ys())return new Promise(e=>e(null));const s=document;if(s.exitFullscreen)return s.exitFullscreen();if(s.mozCancelFullScreen)return s.mozCancelFullScreen();if(s.webkitCancelFullScreen)return s.webkitCancelFullScreen();if(s.msExitFullscreen)return s.msExitFullscreen()}function ga(s,e){let t=null;return function(...i){const r=this;t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,s.apply(r,i)},e||1e3)}}const kd={name:"EToggleSwitch",props:{options:{type:Array,required:!0},color:{type:String,default:"brand"},size:{type:String,default:"sm"},defaultValue:{type:[String,Number,Boolean],default:null}},data(){return{value:this.defaultValue||this.options[0].value}},methods:{handleClick(s){this.value=s,this.$emit("input",s),console.log({value:this.value})}}};var Pd=function(){var e=this,t=e._self._c;return t("div",{class:{"e-flex e-items-center e-justify-center e-w-fit e-h-min e-bg-gray-900 e-rounded-md e-e-shadow-md e-transition-colors e-duration-200 e-ease-in-out":!0,"e-p-1":e.size==="sm","e-p-1.5":e.size==="md","e-p-2":e.size==="lg"}},[t("input",{directives:[{name:"model",rawName:"v-model",value:e.value,expression:"value"}],staticClass:"e-hidden",attrs:{id:"toggle",type:"checkbox"},domProps:{checked:Array.isArray(e.value)?e._i(e.value,null)>-1:e.value},on:{change:function(i){var r=e.value,n=i.target,a=!!n.checked;if(Array.isArray(r)){var o=null,l=e._i(r,o);n.checked?l<0&&(e.value=r.concat([o])):l>-1&&(e.value=r.slice(0,l).concat(r.slice(l+1)))}else e.value=a}}}),e._l(e.options,function(i){return t("button",{key:i.value,class:["e-cursor-pointer",{"e-bg-inherit":e.value!==i.value," e-text-gray-100 e-rounded-md e-shadow e-transition e-duration-200 e-ease-in-out":e.value===i.value,"e-py-[.2rem] e-p-1 e-rounded-md":e.size==="sm","e-p-1":e.size==="md","e-p-1.5":e.size==="lg","e-bg-brand-600":e.color==="brand"&&e.value===i.value,"e-bg-gray-600":!["primary","brand"].includes(e.color)&&e.value===i.value,"e-bg-[#629efc] e-text-gray-900 e-font-normal":e.color==="primary"&&e.value===i.value}],on:{click:function(r){return e.handleClick(i.value)}}},[t("span",{staticClass:"e-font-medium",class:{"e-text-xs":e.size==="sm","e-text-sm":e.size==="md","e-text-base":e.size==="lg"}},[e._v(e._s(i.title))])])})],2)},Fd=[],Od=ge(kd,Pd,Fd,!1,null,null,null,null);const vs=Od.exports,Md={name:"EVideoPlayerActions",components:{EToggleSwitch:vs},props:{frames:{type:Array,default:()=>[]},frameIndex:{type:Number,default:0},isLastFrame:{type:Boolean,default:!0},timePerFrame:{type:Number,default:250},isFullscreen:{type:Boolean,default:!1},isPlaying:{type:Boolean,default:!1},infoText:{type:Object,default:()=>({index:"",label:""})},hasLive:{type:Boolean,default:!1},isLive:{type:Boolean,default:!1},disablePlayButton:{type:Boolean,default:!1},isRecordingWidget:{type:Boolean,default:!1},initialSnapshotQuality:{type:[String,Number],default:Lt.auto},showSnapshotQuality:{type:Boolean,default:!1},isVideo:{type:Boolean,default:!1},hasEdgeVideo:{type:Boolean,default:!1},size:{type:String,default:"md"},allowedToChangeSpeed:{type:Boolean,default:!0},allowedToChangeQuality:{type:Boolean,default:!0}},data(){return{recordingType:"jpegs",allowedSpeeds:[.25,.5,.75,1,1.5,2,2.5],selectedSpeed:1,allowedQualities:Object.values(Lt),selectedQuality:"auto"}},computed:{isEdgeVideoEnabled(){return this.recordingType==="video"},switchOptions(){return[{title:"VIDEO",value:"video"},{title:"JPEGS",value:"jpegs"}]}},watch:{isEdgeVideoEnabled(s){this.$emit("toggle-video-mode",s)},isVideo:{handler(s){this.recordingType=s?"video":"jpegs"},immediate:!0}},mounted(){this.initPlayerSettings(),console.log({selectedQuality:this.selectedQuality,selectedSpeedIndex:this.selectedSpeed,allowedSpeeds:this.allowedSpeeds,allowedQualities:this.allowedQualities,selectedQualitySelected:this.allowedQualities.find(s=>s===this.selectedQuality),selectedSpeed:this.allowedSpeeds.find(s=>s===this.allowedSpeeds[this.selectedSpeed])})},methods:{toggleLive(){this.hasLive&&(this.isLive?this.$emit("disable-live-view"):this.$emit("enable-live-view"))},initPlayerSettings(){var t,i;if(!this.allowedToChangeQuality&&!this.allowedToChangeSpeed)return;const s=window.localStorage.getItem("snapshotsPlayerSpeed"),e=window.localStorage.getItem("snapshotsPlayerQuality");e!=="undefined"?this.selectedQuality=(t=this.allowedQualities.find(r=>r===e||r===this.initialSnapshotQuality))!=null?t:"auto":this.selectedQuality="auto",s?this.selectedSpeed=(i=this.allowedSpeeds.find(r=>r===Number.parseFloat(s)))!=null?i:1:this.selectedSpeed=1,this.updateTimePerFrame(),this.updateQuality()},updateFrameIndex(s){let e=this.frameIndex+s;e>=this.frames.length&&(e=this.frames.length-1),e<0&&(e=0),e>=0&&(this.$emit("frame-index-change",{frameIndex:e}),console.log({newIndex:e,$refs:this.$refs}))},updateTimePerFrame(){this.$emit("change",{timePerFrameValue:250/this.selectedSpeed}),this.allowedToChangeSpeed&&window.localStorage.setItem("snapshotsPlayerSpeed",this.selectedSpeed.toString())},updateQuality(){var s;this.$emit("snapshots-quality",this.selectedQuality),this.allowedToChangeQuality&&window.localStorage.setItem("snapshotsPlayerQuality",(s=this.selectedQuality)!=null?s:"auto")},toggleFullscreen(){this.$emit("toggle-fullscreen",{isFullscreen:!this.isFullscreen})},togglePlaying(){this.isLive&&this.frames.length>0&&this.$emit("disable-live-view"),this.$emit("toggle-play-pause",{isPlaying:!(this.isPlaying||this.isLive)})}}},Fh="";var Nd=function(){var e=this,t=e._self._c;return t("div",{staticClass:"e-relative e-flex e-items-center e-justify-between e-pt-2 e-pb-3"},[t("div",{staticClass:"e-w-1/3"},[t("EToggleSwitch",{attrs:{options:e.switchOptions,color:"primary",size:"sm"},on:{input:i=>e.recordingType=i}})],1),t("div",{staticClass:"e-m-auto e-flex e-flex-1 e-justify-center e-items-center e-gap-6"},[t("button",{staticClass:"e-select-none e-duration-200 e-cursor-pointer e-font-medium e-text-lg text-drop-shadow e-text-white hover:hover-filter-drop e-flex e-justify-center e-items-center e-align-middle",attrs:{text:"",icon:""},on:{click:function(i){return e.updateFrameIndex(-10)}}},[e.isVideo?t("svg",{staticClass:"ltr-0 e1mhci4z1",attrs:{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","data-name":"Back10","aria-hidden":"true"}},[t("path",{attrs:{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M11.0198 2.04817C13.3222 1.8214 15.6321 2.39998 17.5557 3.68532C19.4794 4.97066 20.8978 6.88324 21.5694 9.09717C22.241 11.3111 22.1242 13.6894 21.2388 15.8269C20.3534 17.9643 18.7543 19.7286 16.714 20.8192C14.6736 21.9098 12.3182 22.2592 10.0491 21.8079C7.77999 21.3565 5.73759 20.1323 4.26989 18.3439C2.80219 16.5555 2 14.3136 2 12L0 12C-2.74181e-06 14.7763 0.962627 17.4666 2.72387 19.6127C4.48511 21.7588 6.93599 23.2278 9.65891 23.7694C12.3818 24.3111 15.2083 23.8918 17.6568 22.5831C20.1052 21.2744 22.0241 19.1572 23.0866 16.5922C24.149 14.0273 24.2892 11.1733 23.4833 8.51661C22.6774 5.85989 20.9752 3.56479 18.6668 2.02238C16.3585 0.479973 13.5867 -0.214321 10.8238 0.0578004C8.71195 0.265799 6.70517 1.02858 5 2.2532V1H3V5C3 5.55228 3.44772 6 4 6H8V4H5.99999C7.45608 2.90793 9.19066 2.22833 11.0198 2.04817ZM2 4V7H5V9H1C0.447715 9 0 8.55228 0 8V4H2ZM14.125 16C13.5466 16 13.0389 15.8586 12.6018 15.5758C12.1713 15.2865 11.8385 14.8815 11.6031 14.3609C11.3677 13.8338 11.25 13.2135 11.25 12.5C11.25 11.7929 11.3677 11.1758 11.6031 10.6488C11.8385 10.1217 12.1713 9.71671 12.6018 9.43388C13.0389 9.14463 13.5466 9 14.125 9C14.7034 9 15.2077 9.14463 15.6382 9.43388C16.0753 9.71671 16.4116 10.1217 16.6469 10.6488C16.8823 11.1758 17 11.7929 17 12.5C17 13.2135 16.8823 13.8338 16.6469 14.3609C16.4116 14.8815 16.0753 15.2865 15.6382 15.5758C15.2077 15.8586 14.7034 16 14.125 16ZM14.125 14.6501C14.5151 14.6501 14.8211 14.4637 15.043 14.0909C15.2649 13.7117 15.3759 13.1814 15.3759 12.5C15.3759 11.8186 15.2649 11.2916 15.043 10.9187C14.8211 10.5395 14.5151 10.3499 14.125 10.3499C13.7349 10.3499 13.4289 10.5395 13.207 10.9187C12.9851 11.2916 12.8741 11.8186 12.8741 12.5C12.8741 13.1814 12.9851 13.7117 13.207 14.0909C13.4289 14.4637 13.7349 14.6501 14.125 14.6501ZM8.60395 15.8554V10.7163L7 11.1405V9.81956L10.1978 9.01928V15.8554H8.60395Z",fill:"currentColor"}})]):t("v-icon",[e._v(" fa-angle-double-left ")])],1),t("button",{staticClass:"lg:fa-2xl fa-xl fa-solid disabled:e-opacity-30 e-select-none e-duration-200 e-cursor-pointer text-drop-shadow e-text-white hover:hover-filter-drop e-flex e-justify-center e-items-center e-align-middle",class:{"e-mx-2 e-ml-4":e.size!=="sm","e-border-double e-border-0 e-border-[12*1.8]":e.isPlaying,"e-ml-3 e-mx-1":e.size==="sm","fa-play":!e.isPlaying||e.disablePlayButton||e.isLastFrame||e.isLive,"fa-pause":e.isPlaying},attrs:{"aria-label":e.isLive?"play":e.isPlaying?"pause":"play",disabled:e.disablePlayButton||e.isLastFrame||e.isLive,title:e.isPlaying?"pause":"play"},on:{click:function(i){return e.$emit("toggle-play-pause")}}}),t("button",{staticClass:"e-select-none disabled:e-opacity-30 e-duration-200 e-cursor-pointer e-font-medium e-text-lg text-drop-shadow e-text-white hover:hover-filter-drop e-flex e-justify-center e-items-center e-align-middle",attrs:{text:"",icon:"",disabled:e.isLive||e.isLastFrame,dark:""},on:{click:function(i){return e.updateFrameIndex(10)}}},[e.isVideo?t("svg",{staticClass:"ltr-0 e1mhci4z1",attrs:{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","data-name":"Forward10","aria-hidden":"true"}},[t("path",{attrs:{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M6.4443 3.68532C8.36795 2.39998 10.6778 1.8214 12.9802 2.04817C14.8093 2.22833 16.5439 2.90793 18 4H16V6H20C20.5523 6 21 5.55229 21 5V1H19V2.2532C17.2948 1.02859 15.2881 0.2658 13.1762 0.057802C10.4133 -0.214319 7.64154 0.479975 5.33316 2.02238C3.02478 3.56479 1.32262 5.85989 0.516718 8.51661C-0.289188 11.1733 -0.148981 14.0273 0.913451 16.5922C1.97588 19.1572 3.8948 21.2744 6.34325 22.5831C8.79169 23.8918 11.6182 24.3111 14.3411 23.7694C17.064 23.2278 19.5149 21.7588 21.2761 19.6127C23.0374 17.4666 24 14.7763 24 12L22 12C22 14.3136 21.1978 16.5555 19.7301 18.3439C18.2624 20.1323 16.22 21.3565 13.9509 21.8079C11.6818 22.2592 9.32641 21.9098 7.28604 20.8192C5.24567 19.7286 3.64657 17.9643 2.76121 15.8269C1.87585 13.6894 1.75901 11.3111 2.4306 9.09718C3.10219 6.88324 4.52065 4.97067 6.4443 3.68532ZM22 4V7H19V9H23C23.5523 9 24 8.55229 24 8V4H22ZM12.6018 15.5758C13.0389 15.8586 13.5466 16 14.125 16C14.7034 16 15.2078 15.8586 15.6382 15.5758C16.0753 15.2865 16.4116 14.8815 16.6469 14.3609C16.8823 13.8338 17 13.2135 17 12.5C17 11.7929 16.8823 11.1759 16.6469 10.6488C16.4116 10.1217 16.0753 9.71671 15.6382 9.43389C15.2078 9.14463 14.7034 9 14.125 9C13.5466 9 13.0389 9.14463 12.6018 9.43389C12.1713 9.71671 11.8385 10.1217 11.6031 10.6488C11.3677 11.1759 11.25 11.7929 11.25 12.5C11.25 13.2135 11.3677 13.8338 11.6031 14.3609C11.8385 14.8815 12.1713 15.2865 12.6018 15.5758ZM15.043 14.0909C14.8211 14.4637 14.5151 14.6501 14.125 14.6501C13.7349 14.6501 13.429 14.4637 13.207 14.0909C12.9851 13.7117 12.8741 13.1814 12.8741 12.5C12.8741 11.8186 12.9851 11.2916 13.207 10.9187C13.429 10.5395 13.7349 10.3499 14.125 10.3499C14.5151 10.3499 14.8211 10.5395 15.043 10.9187C15.2649 11.2916 15.3759 11.8186 15.3759 12.5C15.3759 13.1814 15.2649 13.7117 15.043 14.0909ZM8.60395 10.7163V15.8554H10.1978V9.01929L7 9.81956V11.1405L8.60395 10.7163Z",fill:"currentColor"}})]):t("v-icon",[e._v(" fa-angle-double-right")])],1)]),t("div",{staticClass:"e-flex e-items-center e-gap-4 e-w-1/3 e-justify-end"},[t("button",{staticClass:"e-relative e-flex e-items-center e-gap-2 e-justify-center e-px-3 e-py-1 e-font-medium e-text-xs lg:e-leading-6 e-shadow e-rounded-md e-bg-gray-900 lg:e-text-sm e-transition e-ease-in-out e-duration-150",on:{click:function(i){return i.preventDefault(),e.toggleLive.apply(null,arguments)}}},[e.hasLive&&e.isLive?t("span",{staticClass:"e-relative e-flex e-h-2 e-w-2"},[t("span",{staticClass:"e-animate-ping e-absolute e-inline-flex e-h-full e-w-full e-rounded-full e-bg-brand-400 e-opacity-75"}),t("span",{staticClass:"e-relative e-inline-flex e-rounded-full e-h-2 e-w-2 e-bg-brand-500"})]):t("span",{staticClass:"e-relative e-inline-flex e-rounded-full e-h-2 e-w-2 e-bg-slate-500"}),t("span",{class:{"e-text-brand-500":e.hasLive&&e.isLive,"e-text-gray-200":!e.hasLive||!e.isLive}},[e._v(" LIVE ")])]),t("label",{staticClass:"xl:e-flex e-justify-center e-items-center e-gap-2 e-hidden",attrs:{for:"playbackSpeedSelect"}},[t("span",{staticClass:"e-text-sm e-font-semibold"},[e._v(" playback speed x ")]),t("select",{directives:[{name:"model",rawName:"v-model",value:e.selectedSpeed,expression:"selectedSpeed"}],staticClass:"e-bg-none e-px-1 e-text-white e-font-semibold e-w-fit e-py-0 e-shadow-sm e-flex e-justify-center e-items-center",class:{"e-opacity-50 e-cursor-default":e.isLive},attrs:{id:"playbackSpeedSelect",disabled:e.isLive},on:{change:[function(i){var r=Array.prototype.filter.call(i.target.options,function(n){return n.selected}).map(function(n){var a="_value"in n?n._value:n.value;return a});e.selectedSpeed=i.target.multiple?r:r[0]},e.updateTimePerFrame]}},e._l(e.allowedSpeeds,function(i){return t("option",{key:i,staticClass:"e-bg-gray-900",domProps:{value:i}},[e._v(" "+e._s(i)+" ")])}),0)]),e.showSnapshotQuality?t("label",{staticClass:"xl:e-flex e-justify-center e-items-center e-gap-2 e-hidden",attrs:{for:"qualitySelect"}},[t("span",{staticClass:"fas fa-gear"}),t("select",{directives:[{name:"model",rawName:"v-model",value:e.selectedQuality,expression:"selectedQuality"}],staticClass:"e-bg-none e-px-1 e-text-white e-font-semibold e-w-fit e-py-0 e-shadow-sm e-flex e-justify-center e-items-center",class:{"e-opacity-50 e-cursor-default":e.isLive},attrs:{id:"qualitySelect",disabled:e.isLive},on:{change:[function(i){var r=Array.prototype.filter.call(i.target.options,function(n){return n.selected}).map(function(n){var a="_value"in n?n._value:n.value;return a});e.selectedQuality=i.target.multiple?r:r[0]},e.updateQuality]}},e._l(e.allowedQualities,function(i){return t("option",{key:i,staticClass:"e-bg-gray-900",domProps:{value:i}},[e._v(" "+e._s(i)+" ")])}),0)]):e._e(),t("button",{ref:"fullScreenCustomBtn",staticClass:"e-text-xl fa-2xl fa-solid e-cursor-pointer",class:{"fa-expand":!e.isFullscreen,"fa-compress":e.isFullscreen},on:{click:e.toggleFullscreen}})])])},Bd=[],$d=ge(Md,Nd,Bd,!1,null,null,null,null);const Ud=$d.exports,Gd={name:"EVideoPlayerProgressBar",props:{frames:{type:Array,default:()=>[]},events:{type:Array,default:()=>[]},preloadedFrames:{type:Array,default:()=>[]},frameIndex:{type:Number,default:0},ticks:{type:Boolean,default:!0},size:{type:String,default:"md"}},data(){return{hovered:!1,progressBar:null,isDraggingCursor:!1,mousePosition:{x:0,y:0},updateRefTimeout:null}},computed:{hoveredFrameData(){return this.frames[this.hoveredFrameIndex]||{}},mouseToWidthRatio(){var s,e,t;return this.mousePosition.x/((t=(e=(s=this.progressBar)==null?void 0:s.getBoundingClientRect())==null?void 0:e.width)!=null?t:1)},tooltipPosition(){var t,i,r;let s=this.size==="sm"?"65":"155",e;return this.mousePosition.x<Number(s)/2?e="7%":((r=(i=(t=this.progressBar)==null?void 0:t.getBoundingClientRect())==null?void 0:i.width)!=null?r:0)-this.mousePosition.x<Number(s)/2?e="93%":e=`${100*this.mouseToWidthRatio}%`,{width:`${s}px`,left:e,pointerEvents:"none",bottom:"6px"}},hoverBarStyle(){return{width:`${100*this.mouseToWidthRatio}%`}},progressStyle(){return{width:`${100*((this.isDraggingCursor?this.hoveredFrameIndex:this.frameIndex)/(this.frames.length-1))}%`}},hoveredFrameIndex(){return Math.round(this.mouseToWidthRatio*(this.frames.length-1))},preloadedChunks(){const s=[...this.preloadedFrames];return s.sort((e,t)=>e>t?1:-1),s.reduce((e,t)=>{if(!e.length)return[[t,t]];const[i,r]=e.slice(-1)[0]||[0,0];return t-r>1?[...e,[t,t]]:[...e.slice(0,-1),[i,t]]},[])}},mounted(){this.updateRefTimeout=setTimeout(()=>{this.updateRefs()})},beforeDestroy(){clearTimeout(this.updateRefTimeout)},methods:{getMousePosition(s){var t;if(!this.progressBar)return{x:0,y:0};const e=(t=this.progressBar)==null?void 0:t.getBoundingClientRect();return{x:s.clientX-e.x,y:s.clientY-e.y}},onMouseEnter(){this.hovered=!0},onMouseMove(s){this.mousePosition=this.getMousePosition(s)},onMouseLeave(){this.hovered=!1,this.isDraggingCursor=!1},onCursorMouseDown(){this.isDraggingCursor=!0},onCursorMouseUp(){this.isDraggingCursor=!1},onProgressBarClick(){this.$emit("change",{frameIndex:this.hoveredFrameIndex}),this.$emit("frame-index-change",{frameIndex:this.hoveredFrameIndex}),this.$emit("seek",this.hoveredFrameIndex)},updateRefs(){this.progressBar=this.$refs.progressBar},getChunkStyle(s,e){const[t,i]=[100*s/(this.frames.length-1),100*e/(this.frames.length-1)];return{left:`${t}%`,width:`${i-t}%`}}}},Oh="";var Hd=function(){var e=this,t=e._self._c;return t("div",{ref:"progressBar",staticClass:"e-relative e-z-[2] e-cursor-pointer e-w-full e-py-2 e-pt-3",on:{click:e.onProgressBarClick,mouseenter:e.onMouseEnter,mousemove:e.onMouseMove,mouseleave:e.onMouseLeave}},[t("div",{staticClass:"e-transition-opacity e-cursor-pointer e-duration-200"},[t("div",{staticClass:"e-bg-video-player-progress-bar-base-bg e-w-full e-h-[7px] e-absolute"}),e._l(e.preloadedChunks,function([i,r]){return t("span",{key:r,staticClass:"e-z-[1] e-bg-video-player-progress-bar-chunk-bg e-h-[7px] e-absolute",style:e.getChunkStyle(i,r)})}),t("div",{staticClass:"e-transition-background e-duration-200 e-h-[7px] e-absolute",class:{"e-bg-video-player-progress-bar-base-bg":!e.hovered,"e-bg-video-player-progress-bar-hover-bg":e.hovered},style:e.hoverBarStyle}),e.ticks&&e.frames.length<300?t("div",{staticClass:"e-flex e-justify-between e-items-center e-z-[3] e-w-full e-h-[7px] e-absolute"},e._l(e.frames,function(i,r){return t("div",{key:r,staticClass:"player-progress__tick e-h-[7px] e-bg-[#0064b1] e-w-[1px]"})}),0):e._e(),t("div",{staticClass:"e-h-[7px] e-absolute e-bg-video-player-progress-bar-progress-bg e-duration-200 e-ease-out e-z-[2]",style:e.progressStyle},[t("span",{staticClass:"e-right-0 e-h-[12px] e-w-[12px] e-opacity-0 e-z-[3] e-absolute e-border-2 e-border-solid e-border-white e-border-opacity-100 e-rounded-full e-transition-opacity e-duration-200 e-bg-red-500 e-transform e-translate-x-[3px] e-translate-y-[-3px]",on:{pointerdown:e.onCursorMouseDown,pointerup:e.onCursorMouseUp}})])],2),t("div",{staticClass:"player-progress-tooltip-shadow e-absolute e-duration-200 e-transition-opacity -e-translate-x-1/2 -e-translate-y-[150%] e-select-none e-text-white e-font-medium e-mt-2",class:{"e-opacity-0":!e.hovered,"e-opacity-100":e.hovered},style:e.tooltipPosition},[e._t("tooltip",null,{hoveredTimestamp:e.hoveredFrameData.timestamp,selectedFrame:e.hoveredFrameData.src}),e._v(" "+e._s(e.hoveredFrameData.label)+" ")],2)])},Vd=[],Kd=ge(Gd,Hd,Vd,!1,null,"92f9461c",null,null);const zd=Kd.exports,Wd={name:"EVideoThumbnailPreview",props:{targetTimestamp:{type:[Date,String,void 0],default:void 0},aspectRatio:{type:Number,default:16/9},height:{type:Number,default:175},thumbnailsUrls:{type:Array,default:()=>[]},selectedFrame:{type:String,default:""},timezone:{type:String,default:"UTC"}},data(){return{thumbnailWidth:0,thumbnailHeight:0,numberOfThumbnails:0,placeholderUrl:"data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="}},computed:{targetThumbnailIndex(){if(this.thumbnailsUrls.length===0||!this.targetTimestamp)return 0;const s=ve(new Date(this.targetTimestamp)),e=ve(s).startOf("hour"),t=s.diff(e,"seconds"),i=Math.floor(t/3600*this.thumbnailsUrls.length);return i<0?0:i>=this.thumbnailsUrls.length?this.thumbnailsUrls.length-1:i},thumbnailStyle(){return{height:`${this.height}px`,maxHeight:`${this.height}px`,aspectRatio:this.aspectRatio}}},watch:{targetTimestamp:{immediate:!0,async handler(s,e){const t=ve(s).startOf("hour").toString(),i=ve(e).startOf("hour").toString();if(t===i&&s)return;const r=ve.tz(t,this.timezone).startOf("hour").format("YYYY-MM-DDTHH:mm:ss[Z]");console.log({formattedHour:r}),this.$emit("download-thumbnail",r)}}},methods:{}},Mh="";var Yd=function(){var e=this,t=e._self._c;return t("div",{staticClass:"video-thumbnail"},[t("img",{staticClass:"video-thumbnail__img e-absolute -e-translate-x-1/4 -e-translate-y-[105%] e-rounded-[.5rem] img-shadow",style:e.thumbnailStyle,attrs:{src:e.selectedFrame||e.thumbnailsUrls[e.targetThumbnailIndex]||e.placeholderUrl,alt:"thumbnail"}})])},jd=[],qd=ge(Wd,Yd,jd,!1,null,null,null,null);const Xd=qd.exports,Zd={name:"EVideoPlayerControls",components:{EVideoPlayerActions:Ud,EVideoPlayerProgressBar:zd,EVideoPlayerThumbnailPreview:Xd},props:{size:{type:String,default:"md"},withProgressBar:{type:Boolean,default:!0},frames:{type:Array,default:()=>[]},events:{type:Array,default:()=>[]},frameIndex:{type:Number,default:0},preloadedFrames:{type:Array,default:()=>[]},withThumbnailPreview:{type:Boolean,default:!0},withPlayerActions:{type:Boolean,default:!0},isFullScreen:{type:Boolean,default:!1},isPlaying:{type:Boolean,default:!1},isLive:{type:Boolean,default:!1},currentTime:{type:String,default:""},videoLength:{type:String,default:""},thumbnailsUrls:{type:Array,default:()=>[]},timezone:{type:String,default:"UTC"}},data(){return{isFocused:!1}},computed:{containerClasses(){return this.size==="sm"?"e-px-2":"e-px-5"},isLastFrame(){return this.frameIndex===this.frames.length-1}}};var Qd=function(){var e=this,t=e._self._c;return t("div",{staticClass:"player__footer w-100",class:e.containerClasses,on:{mouseenter:function(i){e.isFocused=!0},mouseleave:function(i){e.isFocused=!1}}},[t("div",{staticClass:"player__footer__background"}),e.withProgressBar?t("EVideoPlayerProgressBar",e._b({attrs:{frames:e.frames,events:e.events,"frame-index":e.frameIndex,"preloaded-frames":e.preloadedFrames,timezone:e.timezone},on:{change:i=>e.$emit("on-state-change",i),seek:i=>e.$emit("on-progress-bar-seek",i),"frame-index-change":i=>e.$emit("frame-index-change",i),"marker-active":i=>e.$emit("marker-active",i),"marker-reset":i=>e.$emit("marker-reset",i),"marker-selected":i=>e.$emit("marker-selected",i)},scopedSlots:e._u([{key:"tooltip",fn:function({hoveredTimestamp:i}){return[e.withThumbnailPreview?t("EVideoPlayerThumbnailPreview",{attrs:{timezone:e.timezone,"target-timestamp":i,"thumbnails-urls":e.thumbnailsUrls},on:{"download-thumbnail":r=>e.$emit("download-thumbnail",r)}}):e._e()]}}],null,!1,3363812299)},"EVideoPlayerProgressBar",e.$attrs,!1)):e._e(),e.withPlayerActions?t("EVideoPlayerActions",{attrs:{"is-playing":e.isPlaying,"is-last-frame":e.isLastFrame,"is-fullscreen":e.isFullScreen,"is-live":e.isLive,frames:e.frames,"show-snapshot-quality":!0,"has-edge-video":!0,"is-video":!0,"frame-index":e.frameIndex,"has-live":!0},on:{"frame-index-change":i=>e.$emit("frame-index-change",i),"enable-live-view":function(i){return e.$emit("enable-live-view")},"disable-live-view":function(i){return e.$emit("disable-live-view")},change:function(i){return e.$emit("on-state-change",i)},"toggle-fullscreen":function(i){return e.$emit("toggle-fullscreen")},"toggle-video-mode":i=>e.$emit("toggle-video-mode",i),"toggle-play-pause":function(i){return e.$emit("toggle-play-pause")}}}):e._e()],1)},Jd=[],eh=ge(Zd,Qd,Jd,!1,null,null,null,null);const th=eh.exports,ih={name:"EZoomable",props:{ignorePointerEvents:{type:Boolean,default:!1},withOverlay:{type:Boolean,default:!0}},data(){return{scale:1,minScale:1,maxScale:20,top:0,left:0,isPanning:!1,panStart:{x:0,y:0},isPinching:!1,previousPinchDistance:0,pinchDistance:0,pointers:{},transform:"matrix(1, 0, 0, 1, 0, 0)"}},computed:{contentStyle(){return{transform:this.transform}},isZoomed(){return this.scale>1}},watch:{contentStyle:{handler(s){this.$emit("apply-zoomable-style",{imgStyle:s})},immediate:!0,deep:!0}},methods:{updateZoomScale(){this.scale>this.maxScale?this.scale=this.maxScale:this.scale<this.minScale&&(this.scale=this.minScale)},handleZoom(s){s.preventDefault();const e=this.$refs.container.getBoundingClientRect(),t=this.$refs.content.getBoundingClientRect();if(!e||!t)return;const i=s.clientX,r=s.clientY,n=Math.max(-1,Math.min(1,s.wheelDelta||-s.detail)),a=this.scale;this.scale+=n/10,this.updateZoomScale();const o=((i-t.left)/t.width).toFixed(2),l=((r-t.top)/t.height).toFixed(2);this.left=Math.round(i-e.left-o*(t.width*this.scale/a)),this.top=Math.round(r-e.top-l*(t.height*this.scale/a));const c=0,u=0-e.width*(this.scale-1),d=0-e.height*(this.scale-1),h=0;this.left<u?this.left=u:this.left>c&&(this.left=c),this.top<d?this.top=d:this.top>h&&(this.top=h),this.updateTransform()},handleMouseDown(s){this.isZoomed&&(this.isPanning=!0,this.panStart={x:s.clientX,y:s.clientY})},handleMouseUp(){this.isPanning=!1},handleMouseLeave(){this.isPanning=!1},handleMouseMove(s){if(!this.isPanning||!this.isZoomed)return;const e=s.clientX-this.panStart.x,t=s.clientY-this.panStart.y;this.left+=e,this.top+=t,this.applyBoundsCorrection(),this.panStart={x:s.clientX,y:s.clientY},this.updateTransform()},applyBoundsCorrection(){const s=this.$refs.container.getBoundingClientRect(),e=this.$refs.content.getBoundingClientRect();if(!s||!e)return;const[t,i,r,n]=[s.top-e.top,e.right-s.right,e.bottom-s.bottom,s.left-e.left].map(a=>a<0?a:0);this.left+=n-i,this.top+=t-r},updateTransform(){this.transform=`matrix(${this.scale}, 0, 0, ${this.scale}, ${this.left}, ${this.top})`},getPointersDistance(s,e){return Math.hypot(e.clientX-s.clientX,e.clientY-s.clientY)},getPointersMidPoint(s,e){return{x:s.clientX+(e.clientX-s.clientX)/2,y:s.clientY+(e.clientY-s.clientY)/2}},updatePointerEvent(s){this.pointers[s.pointerId]=s},clearPointerEvent(s){this.$delete(this.pointers,s.pointerId)},updatePinchDistance(){const s=Object.values(this.pointers);s.length===2&&(this.pinchDistance=this.getPointersDistance(...s))},handlePointerDown(s){this.ignorePointerEvents||(this.updatePointerEvent(s),this.isPinching=Object.values(this.pointers).length===2,this.isPinching?(this.isPanning=!1,this.updatePinchDistance()):this.handleMouseDown(s))},handlePointerMove(s){if(!this.ignorePointerEvents)if(this.updatePointerEvent(s),this.isPinching){this.previousPinchDistance=this.pinchDistance,this.updatePinchDistance();const e=this.pinchDistance/this.previousPinchDistance;this.scale*=e,this.updateZoomScale();const t=Object.values(this.pointers),i=this.getPointersMidPoint(...t);this.left=i.x-(i.x-this.left)*e,this.top=i.y-(i.y-this.top)*e,this.applyBoundsCorrection(),this.updateTransform()}else this.handleMouseMove(s)},handlePointerUp(s){this.ignorePointerEvents||(this.clearPointerEvent(s),this.previousPinchDistance=0,this.pinchDistance=0,this.isPanning=!1,this.isPinching=!1)}}},Nh="";var sh=function(){var e=this,t=e._self._c;return t("div",{ref:"container",staticClass:"e-w-full e-h-full"},[t("div",{staticClass:"e-w-full e-h-full",class:{"e-cursor-grab":e.isZoomed,"e-cursor-grabbing":e.isPanning},on:{mousewheel:e.handleZoom,mousedown:e.handleMouseDown,mouseup:e.handleMouseUp,mouseleave:e.handleMouseLeave,mousemove:e.handleMouseMove,pointerdown:e.handlePointerDown,pointermove:e.handlePointerMove,pointerup:e.handlePointerUp,pointercancel:e.handlePointerUp,pointerout:e.handlePointerUp,pointerleave:e.handlePointerUp}},[t("div",{ref:"content",staticClass:"e-w-full e-h-full e-transform-0 e-touch-none",style:e.contentStyle},[e._t("default")],2),e.withOverlay?t("div",{staticClass:"e-absolute e-w-full e-h-full e-bottom-0 e-left-0 e-overflow-hidden"},[e._t("overlay")],2):e._e()])])},rh=[],nh=ge(ih,sh,rh,!1,null,"3fb6736d",null,null);const xs=nh.exports,Bh="",ah={name:"EVideoPlayerOverlayAnimation",props:{isPlaying:{type:Boolean,default:!1}}};var oh=function(){var e=this,t=e._self._c;return t("div",{staticClass:"image-player-overlay d-flex align-center justify-center"},[t("div",{staticClass:"image-player-overlay__wrapper"},[e.isPlaying?t("svg",{attrs:{height:"100%",viewBox:"-1 0 36 36",width:"100%"}},[t("path",{attrs:{d:"M 12,26 18.5,22 18.5,14 12,10 z M 18.5,22 25,18 25,18 18.5,14 z"}})]):t("svg",{attrs:{height:"100%",viewBox:"0.5 0 36 36",width:"100%"}},[t("path",{attrs:{d:"M 12,26 16,26 16,10 12,10 z M 21,26 25,26 25,10 21,10 z"}})])])])},lh=[],ch=ge(ah,oh,lh,!1,null,null,null,null);const uh=ch.exports,Ts=new Intl.NumberFormat(void 0,{minimumIntegerDigits:2}),pa=["play","pause","ended","loadeddata","waiting","playing","timeupdate","canplay","canplaythrough","statechanged","error"],Es=s=>{const e=Math.floor(s%60),t=Math.floor(s/60)%60,i=Math.floor(s/3600);return i===0?`${t}:${Ts.format(e)}`:`${i}:${Ts.format(t)}:${Ts.format(e)}`},dh={name:"VideoPlayer",components:{ESpinner:pi,EVideoPlayerControls:th,EZoomable:xs,EVideoPlayerOverlayAnimation:uh},props:{targetTimestamp:{type:[String,Date],default:void 0},sources:{type:[Array,String],required:!0},videoListeners:{type:Object,default:()=>({})},videoOptions:{type:Object,default:()=>({})},isHls:{type:Boolean,default:!1},streamingToken:{type:String,default:""},isLiveView:{type:Boolean,default:!1},pauseOnClick:{type:Boolean,default:!0},isHlsLoading:{type:Boolean,default:!1},isPlaying:{type:Boolean,default:!1},preloadedInterval:{type:Object,default:()=>({})},selectedResolution:{type:[Number,void 0],default:void 0},isLive:{type:Boolean,default:!1},isZoomable:{type:Boolean,default:!1},zoomableIgnorePointerEvents:{type:Boolean,default:!1},blurBackground:{type:Boolean,default:!1},isRecordings:{type:Boolean,default:!1},progressBarEvents:{type:Array,default:()=>[]},progressBarFrames:{type:Array,default:()=>[]},progressBarFrameIndex:{type:Number,default:0},progressBarPreloadedFrames:{type:Array,default:()=>[]},thumbnailsUrls:{type:Array,default:()=>[]},timezone:{type:String,default:"UTC"},playPauseAnimation:{type:Boolean,default:!0},disablePlayPauseAnimation:{type:Boolean,default:!1}},data(){return{playing:!1,percentagePlayed:0,videoLength:"0:00",duration:0,videoDuration:0,currentTime:"0:00",realtime:0,isScrubbing:!1,wasPaused:!1,isFullscreen:!1,isFinished:!1,isLoading:!0,isError:!1,player:new be,playbackRetries:0}},computed:{sourceItems(){return Array.isArray(this.sources)?this.sources:[{src:this.sources}]},hasStartedOrFinished(){return(this.isFinished||this.realtime<=.1)&&!this.isLoading&&!this.isLooped()},withControls(){const s=this.videoOptions;return(s==null?void 0:s.controls)===!1?"hide":""}},watch:{selectedResolution(){if(!this.isHls)return;const s=this.sources[0];this.player.loadSource(s.src),this.isLoading=!0,this.isPlaying&&this.play()},isPlaying:{immediate:!0,handler(s){this.isHls&&(s?(this.isLiveView&&this.initHls(),this.$emit("hls-play")):this.$emit("hls-pause"))}},targetTimestamp:{immediate:!0,handler(s){var n,a;if(!this.isHls)return;const e=this.$refs.player,t=(n=this.preloadedInterval)==null?void 0:n.start,i=(a=this.preloadedInterval)==null?void 0:a.end;if(!(t&&i))return;const r=ve(s).isBetween(ve(t),ve(i),void 0,"[]");e.currentTime=0,r||this.initHls()}},isHlsLoading(s){s?setTimeout(()=>{this.isHlsLoading&&(this.isLoading=!0)},this.isPlaying?500:3e3):this.isLoading=!1}},mounted(){this.isHls&&this.initHls(),this.bindEvents(),this.initializePlayer(),this.initializeFullscreenListeners()},beforeDestroy(){this.unbindEvents(),this.destroyPlayer(),this.removeFullscreenListeners()},methods:{initHls(){var t,i,r,n,a;const s=this.$refs.player,e=this.sources[0];(t=this.player)!=null&&t.stopLoad&&this.player.stopLoad(),be.isSupported()&&(this.isLoading=!0,this.player=new be({startPosition:0,xhrSetup:o=>{this.streamingToken&&o.setRequestHeader("Authorization",`Bearer ${this.streamingToken}`)}}),(i=this.player)==null||i.loadSource(e.src),(r=this.player)==null||r.attachMedia(s),(n=this.player)==null||n.on(be.Events.MANIFEST_PARSED,()=>{this.playing&&s.play()}),(a=this.player)==null||a.on(be.Events.ERROR,this.handleHlsError))},onContainerClick(){this.pauseOnClick&&this.togglePlay()},handle404Error(){this.isError=!0,this.isLoading=!1,this.playing=!1},handleHlsError(s,e){var a;if(!e.fatal)return;const t=e.type===be.ErrorTypes.NETWORK_ERROR,i=e.type===be.ErrorTypes.MEDIA_ERROR,r=t&&((a=e.networkDetails)==null?void 0:a.status)===404,n=()=>{this.player.destroy(),this.videoListeners.error?this.videoListeners.error():this.handle404Error()};if(r){n();return}if(t){console.error("A network error occurred:",e),this.player.startLoad();return}i&&(console.error("A media error occurred:",e),this.player.recoverMediaError()),n()},bindEvents(){const s=this.$refs.player;pa.forEach(e=>{if(this.isLive){const t=this.$refs.timelineContainer;this.percentagePlayed=1e4,t==null||t.style.setProperty("--progress-position",this.percentagePlayed.toString())}else s.addEventListener(e,()=>this.bindVideoEvent(e),!0)})},unbindEvents(){const s=this.$refs.player;pa.forEach(e=>{s.removeEventListener(e,()=>this.bindVideoEvent(e),!0)})},bindVideoEvent(s){const e=this.$refs.player;if(!e)return;const t=this.$refs.timelineContainer;s==="loadeddata"&&(this.videoLength=Es(e.duration)),t&&(s==="timeupdate"&&(this.percentagePlayed=(e==null?void 0:e.currentTime)/(e==null?void 0:e.duration)*100,t==null||t.style.setProperty("--progress-position",this.percentagePlayed.toString())),this.$emit(s,{event,player:e}))},initializePlayer(){const s=this.$refs.player;s&&(s.autoplay&&this.setPlaying(!0),document.addEventListener("mouseup",this.handleScrubbingOnMouseEnd),document.addEventListener("keydown",this.handleKeyDown))},destroyPlayer(){this.player&&(this.player.stopLoad(),this.player.destroy()),window.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("mouseup",this.handleScrubbingOnMouseEnd)},removeFullscreenListeners(){document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled?(document.removeEventListener("fullscreenchange",this.handleFullscreenChange),document.removeEventListener("webkitfullscreenchange",this.handleFullscreenChange),document.removeEventListener("mozfullscreenchange",this.handleFullscreenChange),document.removeEventListener("MSFullscreenChange",this.handleFullscreenChange)):console.log("Fullscreen API is not supported in this browser.")},initializeFullscreenListeners(){document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled?(document.addEventListener("fullscreenchange",this.handleFullscreenChange),document.addEventListener("webkitfullscreenchange",this.handleFullscreenChange),document.addEventListener("mozfullscreenchange",this.handleFullscreenChange),document.addEventListener("MSFullscreenChange",this.handleFullscreenChange)):console.log("Fullscreen API is not supported in this browser.")},handleFullscreenChange(){this.isFullscreen=document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement||window.innerWidth==screen.width&&window.innerHeight==screen.height},isLooped(){return this.$refs.player.loop},handleScrubbingOnMouseEnd(s){this.isScrubbing&&this.toggleScrubbing(s)},handleEnded(){this.isFinished=!0,this.playing=!1},handleLoading(){this.isLoading=!1},async play(){const s=this.$refs.player;if(s&&this.isHls)try{await s.play(),this.setPlaying(!0)}catch(e){console.error(e),this.playbackRetries+=1,this.initHls()}},pause(){const s=this.$refs.player;s&&(s.pause(),this.setPlaying(!1))},async togglePlay(){this.playing?this.pause():await this.play()},setPlaying(s){this.playing=s},seekToPercentage(s){const e=this.$refs.player;if(!e)return;const t=s/100*e.duration;e.currentTime=t},convertTimeToDuration(s){return[parseInt(s/60%60,10),parseInt(s%60,10)].join(":").replace(/\b(\d)\b/g,"0$1")},closeFullscreenMode(){document.fullscreenElement&&(ma().then(()=>{this.isFullscreen=!1,console.log("Exited fullscreen")}),this.isFullscreen=!1)},openFullscreenMode(){const s=this.$refs.videoContainer;s&&(fa(s).then(()=>{this.isFullscreen=!0}),this.isFullscreen=!0)},toggleFullscreenMode(){console.log("executed",{isFullscreen:this.isFullscreen}),this.isFullscreen?this.closeFullscreenMode():this.openFullscreenMode()},getDuration(){const s=this.$refs.player;this.videoLength=Es(s.duration),this.videoDuration=s.duration},handleTimeUpdate(){const s=this.$refs.player,e=this.$refs.timelineContainer;if(!s||!e)return;this.currentTime=Es(s.currentTime),this.realtime=s.currentTime;const t=Number(this.realtime)/Number(this.videoDuration);e.style.setProperty("--progress-position",t.toString())},handleTimelineUpdate(s){const e=this.$refs.player;if(!document.body.contains(e))return;const t=this.$refs.timelineContainer,i=t.getBoundingClientRect(),r=Math.min(Math.max(0,s.x-i.x),i.width)/i.width;t.style.setProperty("--preview-position",r.toString()),this.isScrubbing&&(s.preventDefault(),t.style.setProperty("--progress-position",r.toString()))},skip(s=5){const e=this.$refs.player;e.currentTime+=s},async toggleScrubbing(s){const e=this.$refs.timelineContainer,t=this.$refs.videoContainer,i=this.$refs.player;if(!i)return;const r=e.getBoundingClientRect(),n=Math.min(Math.max(0,s.x-r.x),r.width)/r.width;if(this.isScrubbing=(s.buttons&1)===1,t.classList.toggle("scrubbing",this.isScrubbing),this.isScrubbing){this.wasPaused=i.paused,await i.pause(),this.handleTimelineUpdate(s);return}if(this.realtime=n*this.videoDuration,i.currentTime=n*this.videoDuration,this.wasPaused)return;const a=i.play();a!==void 0&&a.then(()=>this.handleTimelineUpdate(s)).catch(console.error)},handleKeyDown(s){var t;const e=(t=document.activeElement)==null?void 0:t.tagName.toLowerCase();if(e!=="input")switch(s.key.toLowerCase()){case" ":if(e==="button")return;this.togglePlay();break;case"k":this.togglePlay();break;case"escape":s.preventDefault(),this.closeFullscreenMode(),this.isFullscreen=!1;break;case"f":this.openFullscreenMode(),this.isFullscreen=!0;break}}}},$h="";var hh=function(){var e=this,t=e._self._c;return t("div",{ref:"videoContainer",staticClass:"video-container paused",attrs:{"data-volume-level":"high"}},[e.isZoomable?t("EZoomable",{attrs:{"ignore-pointer-events":e.zoomableIgnorePointerEvents},on:{"apply-zoomable-style":function(i){return e.$emit("apply-zoomable-style",i)}},scopedSlots:e._u([{key:"overlay",fn:function(){return[e._t("zoomable-overlay")]},proxy:!0}],null,!0)},[t("div",{staticClass:"e-w-full e-h-full e-relative"},[e.blurBackground?t("img",{staticClass:"e-absolute e-block e-w-full e-scale-150 e-z-[-1] e-inset-0 e-m-auto e-blur-video-poster",attrs:{src:e.videoOptions.poster,alt:"background-image"},on:{error:function(i){return e.$emit("poster-error",i)}}}):e._e()]),t("video",e._g(e._b({ref:"player",staticClass:"e-w-full e-h-full e-absolute e-inset-0 e-z-50",attrs:{controls:!1,preload:"auto"},on:{ended:e.handleEnded,click:e.onContainerClick,loadedmetadata:e.getDuration,timeupdate:e.handleTimeUpdate,loadeddata:e.handleLoading}},"video",e.videoOptions,!1),e.videoListeners),e._l(e.sourceItems,function(i){return t("source",e._g({key:i.src,attrs:{src:i.src,type:i.type},on:{error:e.handle404Error}},e.videoListeners))}),0)]):t("video",e._g(e._b({ref:"player",staticClass:"e-w-full e-h-full",attrs:{controls:!1,preload:"auto"},on:{ended:e.handleEnded,click:e.onContainerClick,loadedmetadata:e.getDuration,timeupdate:e.handleTimeUpdate,loadeddata:e.handleLoading}},"video",e.videoOptions,!1),e.videoListeners),e._l(e.sourceItems,function(i){return t("source",e._g({key:i.src,attrs:{src:i.src,type:i.type},on:{error:e.handle404Error}},e.videoListeners))}),0),e.isLoading?t("div",{staticClass:"spinner-container"},[t("ESpinner",{attrs:{color:!e.isHls,size:e.isHls?"7xl":"9xl",opacity:"0.6",dark:!0}})],1):e._e(),e._t("default"),e.playPauseAnimation&&!e.disablePlayPauseAnimation?t("EVideoPlayerOverlayAnimation",{attrs:{"is-playing":e.isPlaying}}):e._e(),e.isError?t("div",{staticClass:"spinner-container e-gap-3"},[t("i",{staticClass:"fa-solid fa-video-slash fa-2xl e-align-middle"}),t("span",[e._v("This video file cannot be played.")])]):e._e(),e.isRecordings?t("EVideoPlayerControls",{attrs:{"is-playing":e.playing,"is-live":e.isLive,"current-time":e.currentTime,"video-length":e.videoLength,"is-fullscreen":e.isFullscreen,frames:e.progressBarFrames,events:e.progressBarEvents,"frame-index":e.progressBarFrameIndex,"preloaded-frames":e.progressBarPreloadedFrames,"thumbnails-urls":e.thumbnailsUrls,timezone:e.timezone},on:{"download-thumbnail":i=>e.$emit("download-thumbnail",i),"toggle-play-pause":e.togglePlay,"toggle-fullscreen":e.toggleFullscreenMode,"timeline-update":e.handleTimelineUpdate,"enable-live-view":function(i){return e.$emit("enable-live-view")},"toggle-video-mode":i=>e.$emit("toggle-video-mode",i),"frame-index-change":i=>e.$emit("frame-index-change",i)}}):t("div",{class:["video-controls-container",e.withControls]},[t("div",{staticClass:"controls"},[t("button",{ref:"playPauseBtn",staticClass:"play-pause-btn fa-lg fa-solid",class:{"fa-play":!e.playing,"fa-pause":e.playing},attrs:{title:e.playing?"pause":"play"},on:{click:e.togglePlay}}),t("div",{staticClass:"duration-container"},[t("div",{ref:"currentTimeElem",staticClass:"current-time"},[e._v(" "+e._s(e.currentTime)+" ")]),e._v(" / "),t("div",{ref:"totalTimeElem",staticClass:"total-time"},[e._v(e._s(e.videoLength))])]),t("div",{ref:"timelineContainer",staticClass:"timeline-container",on:{mousemove:e.handleTimelineUpdate,mousedown:e.toggleScrubbing}},[t("div",{staticClass:"timeline"},[t("div",{staticClass:"thumb-indicator"})])]),t("button",{ref:"fullScreenBtn",staticClass:"full-screen-btn fa-solid",class:{"fa-expand":!e.isFullscreen,"fa-compress":e.isFullscreen},on:{click:e.toggleFullscreenMode}})])])],2)},fh=[],mh=ge(dh,hh,fh,!1,null,"b64a8d0d",null,null);const ya=mh.exports,ri=s=>{const e=I.utcFormat("%_d")(s),i={1:"st",2:"nd",3:"rd"}[e.charAt(1)]||"th";return`${e}${i}`},va=s=>new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate()+1)).getUTCDate()===1?"":I.utcFormat("%-d")(s),St=s=>["0"," 0","00"].includes(I.utcFormat("%H")(s))?"":`${I.utcFormat("%H")(s)}h`,je=s=>{const e=I.utcFormat("%H:%M")(s);return e==="00:00"?"":e},Ss=s=>I.utcFormat("%M:%S")(s),xa=s=>`${I.utcFormat("%Hh%Mm")(s)}`,bs=s=>{const e=je(s),t=ri(s),i=I.utcFormat("%B")(s);return e||`${i} ${t}`},As=s=>{const e=je(s),t=Number.parseInt(I.utcFormat("%H")(s)),i=ri(s),r=I.utcFormat("%B")(s);return e&&t%6===0?`${r} ${i} ${e}`:bs(s)},bt=s=>e=>{const t=I.utcFormat("%H")(e);return!(I.utcFormat("%M")(e)==="00"&&Number.parseInt(t)%s===0)},Ls=s=>e=>{const t=I.utcFormat("%M")(e);return Number.parseInt(t)%s!==0},Ta=s=>e=>{const t=I.utcFormat("%M")(e),i=I.utcFormat("%S")(e);return Number.parseInt(t)%s!==0&&Number.parseInt(i)===0},K={_10_seconds:25e-6,_20_seconds:1e-4,_30_seconds:15e-5,_1_minute:3e-4,_2_minutes:75e-5,_5_minutes:.002,_15_minutes:.005,_30_minutes:.01,_1_hour:.025,_2_hours:.05,_3_hours:.1,_4_hours:.15,_6_hours:.25,_1_day:1,_2_days:2,_1_month:8,_1_month_abbr:13,_1_month_letter:22,_3_months:33,_2_year:48,_5_years:120,_20_years:480,_75_years:1800,_300_years:7200,infinity:1/0},gh={[mt.overview]:[{precision:K._30_seconds,interval:I.utcMinute.every(2),format:xa},{precision:K._1_minute,interval:I.utcMinute.every(5),format:xa},{precision:K._2_minutes,interval:I.utcMinute.every(10),format:bs},{precision:K._5_minutes,interval:I.utcMinute.every(20),format:As},{precision:K._15_minutes,interval:I.utcHour,format:As},{precision:K._30_minutes,interval:I.utcHour.every(2),format:As},{precision:K._2_hours,interval:I.utcHour.every(6),format:s=>{const e=je(s),t=ri(s),i=I.utcFormat("%B")(s);return e||`${i} ${t}`}},{precision:K._3_hours,interval:I.utcHour.every(12),format:bs},{precision:K._6_hours,interval:I.utcHour.every(24),format:s=>{const e=ri(s);return`${I.utcFormat("%b")(s)} ${e}`}},{precision:K._2_days,interval:I.utcMonth,format:s=>{const t=s.getUTCMonth()===0&&s.getUTCDate()===1?"%Y – %B":"%B";return I.utcFormat(t)(s)}},{precision:K._2_year,interval:I.utcYear.every(2),format:"%Y"},{precision:K._5_years,interval:I.utcYear.every(5),format:"%Y"},{precision:K._20_years,interval:I.utcYear.every(20),format:"%Y"},{precision:K._75_years,interval:I.utcYear.every(75),format:"%Y"},{precision:K._300_years,interval:I.utcYear.every(300),format:"%Y"},{precision:K.infinity,interval:I.utcMonth.every(12),format:"%Y"}],[mt.detailed]:[{precision:K._10_seconds,interval:I.utcSecond.every(10),format:Ss},{precision:K._20_seconds,interval:(Aa=I.utcSecond.every(20))==null?void 0:Aa.filter(Ta(2)),format:Ss},{precision:K._30_seconds,interval:(La=I.utcSecond.every(30))==null?void 0:La.filter(Ta(2)),format:Ss},{precision:K._1_minute,interval:I.utcMinute.filter(Ls(5)),format:je},{precision:K._2_minutes,interval:(Ca=I.utcMinute.every(2))==null?void 0:Ca.filter(Ls(10)),format:je},{precision:K._5_minutes,interval:(_a=I.utcMinute.every(5))==null?void 0:_a.filter(Ls(20)),format:je},{precision:K._15_minutes,interval:(Ra=I.utcMinute.every(15))==null?void 0:Ra.filter(bt(1)),format:je},{precision:K._30_minutes,interval:(Da=I.utcMinute.every(30))==null?void 0:Da.filter(bt(2)),format:je},{precision:K._1_hour,interval:I.utcHour.filter(bt(6)),format:St},{precision:K._2_hours,interval:(Ia=I.utcHour.every(2))==null?void 0:Ia.filter(bt(6)),format:St},{precision:K._3_hours,interval:(wa=I.utcHour.every(3))==null?void 0:wa.filter(bt(12)),format:St},{precision:K._4_hours,interval:I.utcHour.every(4),format:St},{precision:K._6_hours,interval:I.utcHour.every(6),format:St},{precision:K._1_day,interval:I.utcDay,format:va},{precision:K._2_days,interval:I.utcDay.every(2),format:va},{precision:K._1_month,interval:I.utcMonth,format:"%B"},{precision:K._1_month_abbr,interval:I.utcMonth,format:"%b"},{precision:K._1_month_letter,interval:I.utcMonth,format:s=>I.utcFormat("%B")(s).charAt(0)},{precision:K._3_months,interval:I.utcMonth.every(3),format:"Q%q"},{precision:K._2_year,interval:I.utcMonth.every(6),format:"%Y"},{precision:K._5_years,interval:I.utcYear.every(2),format:"%Y"},{precision:K._20_years,interval:I.utcYear.every(4),format:"%Y"},{precision:K._75_years,interval:I.utcYear.every(25),format:"%Y"},{precision:K._300_years,interval:I.utcYear.every(100),format:"%Y"},{precision:K.infinity,interval:I.utcYear.every(500),format:""}],[mt.detailedBackground]:[{precision:K._10_seconds,interval:I.utcSecond,format:""},{precision:K._20_seconds,interval:I.utcSecond.every(5),format:""},{precision:K._30_seconds,interval:I.utcSecond.every(10),format:""},{precision:K._1_minute,interval:I.utcSecond.every(20),format:""},{precision:K._2_minutes,interval:I.utcSecond.every(30),format:""},{precision:K._5_minutes,interval:I.utcMinute,format:""},{precision:K._15_minutes,interval:I.utcMinute.every(3),format:""},{precision:K._30_minutes,interval:I.utcMinute.every(6),format:""},{precision:K._1_hour,interval:I.utcMinute.every(15),format:""},{precision:K._2_hours,interval:I.utcMinute.every(30),format:""},{precision:K._3_hours,interval:I.utcHour,format:""},{precision:K._4_hours,interval:I.utcHour,format:""},{precision:K._6_hours,interval:I.utcMinute.every(120),format:""},{precision:K._1_day,interval:I.utcHour.every(8),format:""},{precision:K._2_days,interval:I.utcHour.every(12),format:""},{precision:K._1_month,interval:I.utcDay.filter(s=>{const e=s.getUTCDate(),t=new Date(s.getUTCFullYear(),s.getUTCMonth()+1,0).getUTCDate(),i=Math.ceil(t/5);return e===i||e===2*i||e===3*i||e===4*i}),format:""},{precision:K._1_month_abbr,interval:I.utcDay.filter(s=>{const e=s.getUTCDate(),t=new Date(s.getUTCFullYear(),s.getUTCMonth()+1,0).getUTCDate(),i=Math.ceil(t/4);return e===i||e===2*i||e===3*i}),format:""},{precision:K._1_month_letter,interval:I.utcDay.filter(s=>{const e=s.getUTCDate(),t=new Date(s.getUTCFullYear(),s.getUTCMonth()+1,0).getUTCDate(),i=Math.ceil(t/2);return e===i}),format:""},{precision:K._3_months,interval:I.utcMonth,format:""},{precision:K._3_months,interval:I.utcMonth,format:""},{precision:K._2_year,interval:I.utcYear,format:""},{precision:K._5_years,interval:I.utcYear.every(2),format:""},{precision:K._20_years,interval:I.utcYear.every(5),format:""},{precision:K._75_years,interval:I.utcYear.every(20),format:""},{precision:K._300_years,interval:I.utcYear.every(100),format:""},{precision:K.infinity,interval:I.utcYear.every(500),format:""}]},ni={bind(s,e){const{value:t}=e;if(typeof t!="function"){console.error("Invalid callback function provided to v-resize-observer");return}const i=new ResizeObserver(r=>{r[0]&&t(r[0])});i.observe(s),s.__resizeObserver__=i},unbind(s){s.__resizeObserver__&&(s.__resizeObserver__.disconnect(),delete s.__resizeObserver__)}},Ea=[{name:"resize-observer",definition:ni}],qe={milestone:"e-tl-milestone",milestoneBullet:"e-tl-milestone--bullet",milestoneDot:"e-tl-milestone--dot",milestoneContent:"e-tl-milestone-content",milestoneLine:"e-tl-milestone-line",milestonesContainer:"e-tl-milestones",milestoneHovered:"e-tl-milestone--hovered",milestoneSelected:"e-tl-milestone--selected",milestoneLabel:"e-tl-milestone-label",milestoneDotContainer:"e-tl-milestone-dot-container",milestoneDotLine:"e-tl-milestone-dot-line",milestoneDotDot:"e-tl-milestone-dot-dot",milestoneDotHovered:"e-tl-milestone-dot--hovered"},ph=Ae.extend({name:"ETimeline",directives:{resizeObserver:ni},props:{milestone:{type:Object,required:!0},size:{type:Number,default:18},borderColor:{type:String,default:"#eee"},backgroundColor:{type:String,default:"#aaa"},borderWidth:{type:Number,default:2},transitionDuration:{type:Number,default:500},dot:{type:Boolean,default:!1},dotSize:{type:Number,default:8},lineWidth:{type:Number,default:2},lineHeight:{type:Number,default:28}},data(){return{milestoneClasses:qe,timeouts:[],isInitialRender:!0,isMouseOver:!1}},computed:{transitionStyles(){return this.isInitialRender?{}:{transition:`transform ${this.transitionDuration}ms, width ${this.transitionDuration}ms, height ${this.transitionDuration}ms, padding ${this.transitionDuration}ms, border-radius ${this.transitionDuration}ms`}},sizeStyles(){return this.dot?{}:{width:`${this.size}px`,height:`${this.size}px`}},positionStyles(){return this.dot&&this.isMouseOver?{transform:`translateY(calc(-100% - ${this.lineHeight}px))`}:{}},styles(){return{...this.sizeStyles,...this.positionStyles,backgroundColor:this.backgroundColor,borderColor:this.borderColor,borderWidth:`${this.borderWidth}px`,borderStyle:"solid",...this.transitionStyles}},contentStyles(){return this.transitionStyles},computedTransitionDuration(){return this.isInitialRender?0:this.transitionDuration},labelStyles(){return{transition:`opacity ${this.computedTransitionDuration}ms`}},dotContainerStyles(){return{top:this.isMouseOver?`calc(100% - ${this.borderWidth}px)`:`calc(50% + ${this.dotSize/2}px)`,height:`calc(${this.lineHeight}px + ${this.dotSize}px)`,left:`calc(50% - ${this.lineWidth}px / 2)`,transition:`${this.computedTransitionDuration}ms`}},lineStyles(){return{bottom:`${this.dotSize/2}px`,left:`calc(50% - ${this.lineWidth}px / 2)`,width:`${this.lineWidth}px`,height:this.isMouseOver?`${this.lineHeight}px`:"0",backgroundColor:this.borderColor,transition:`${this.computedTransitionDuration}ms`}},dotStyles(){return{top:`${this.lineHeight}px`,left:`calc(50% - ${this.dotSize}px / 2)`,width:`${this.dotSize}px`,height:`${this.dotSize}px`,backgroundColor:this.borderColor,transition:`${this.computedTransitionDuration}ms`}}},mounted(){this.$nextTick(()=>{this.dot||(this.onMilestoneMouseOver(),this.onMilestoneMouseLeave()),this.isInitialRender=!1})},methods:{onMilestoneMouseOver(s){if(this.isMouseOver=!0,this.dot)return;const e=(s==null?void 0:s.target)||this.$refs.container;if(!e)return;const t=e.children[0];if(!t)return;const i=t.children[0];if(!i)return;const r=i.getBoundingClientRect(),n=e.dataset.timeoutId;n&&(clearTimeout(Number(n)),e.dataset.timeoutId=""),e.dataset.initialWidth||(e.dataset.initialWidth=e.style.width),e.dataset.initialHeight||(e.dataset.initialHeight=e.style.height),e.dataset.initialContentWidth||(e.dataset.initialContentWidth=String(r.width)),e.dataset.initialContentHeight||(e.dataset.initialContentHeight=String(r.height)),e.dataset.transitionStart=String(Date.now()),e.style.width=e.dataset.initialContentWidth+"px",e.style.height=e.dataset.initialContentHeight+"px",e.style.borderRadius="0.5em",e.classList.add(qe.milestoneHovered),t.style.opacity="1",t.style.width=e.dataset.initialContentWidth+"px",t.style.height=e.dataset.initialContentHeight+"px"},onMilestoneMouseMove(){this.timeouts.forEach(s=>clearTimeout(s)),this.isMouseOver=!0},onMilestoneMouseLeave(s){if(this.dot){this.timeouts.push(setTimeout(()=>{this.isMouseOver=!1},this.transitionDuration+100));return}const e=(s==null?void 0:s.target)||this.$refs.container;if(!e)return;e.style.width=e.dataset.initialWidth||"",e.style.height=e.dataset.initialHeight||"",e.style.borderRadius="10em";const t=e.children[0];if(!t)return;t.style.width="0",t.style.height="0",t.style.opacity="0";const i=Date.now()-Number(e.dataset.transitionStart),r=i>this.transitionDuration?this.transitionDuration:i,n=setTimeout(()=>{e.classList.remove(qe.milestoneHovered),e.dataset.timeoutId=""},r);e.dataset.timeoutId=String(n),this.timeouts.push(n)},onMilestoneClick(s,e){this.$emit("milestone-click",e)}}}),Uh="";var yh=function(){var e=this,t=e._self._c;return t("div",{ref:"container",class:{[e.milestoneClasses.milestone]:!0,[e.milestoneClasses.milestoneBullet]:!e.dot,[e.milestoneClasses.milestoneHovered]:e.isMouseOver&&!e.dot,[e.milestoneClasses.milestoneDot]:e.dot,[e.milestoneClasses.milestoneDotHovered]:e.isMouseOver&&e.dot},style:e.styles,attrs:{tabindex:"0"},on:{mouseover:i=>e.onMilestoneMouseOver(i,e.milestone),mousemove:e.onMilestoneMouseMove,mouseleave:i=>e.onMilestoneMouseLeave(i,e.milestone),click:i=>e.onMilestoneClick(i,e.milestone)}},[t("div",{class:e.milestoneClasses.milestoneContent,style:e.contentStyles},[e._t("content",function(){return[t("span",[e._v(" "+e._s(e.milestone.text)+" ")])]})],2),e.dot?t("div",{class:e.milestoneClasses.milestoneDotContainer,style:e.dotContainerStyles},[t("div",{class:e.milestoneClasses.milestoneDotLine,style:e.lineStyles}),t("div",{class:e.milestoneClasses.milestoneDotDot,style:e.dotStyles})]):t("div",{class:e.milestoneClasses.milestoneLabel,style:e.labelStyles},[e._t("label")],2)])},vh=[],xh=ge(ph,yh,vh,!1,null,null,null,null);const Th=xh.exports,$={eventGroup:"event-group",eventGroupBg:"event-group-bg",eventRect:"event-rect",eventBarContainer:"event-bar-container",eventBarContainerHovered:"event-bar-container--hovered",eventBarContainerSelected:"event-bar-container--selected",eventBar:"event-bar",eventBarHoverZone:"event-bar-hover-zone",eventBarCap:"event-bar-cap",eventRectText:"event-rect-text",eventRectHovered:"event-rect--hovered",eventRectSelected:"event-rect--selected",labelGroup:"label-g",labelBg:"label-bg",labelBgFill:"label-bg-fill",labelText:"label-text",loadingIndicator:"loading-indicator",xAxis:"x-axis",selectedTimestampCursor:"selected-timestamp-cursor",marker:"marker",markerLabel:"marker-label",markerLine:"marker-line",markerDragged:"marker--dragged",milestone:"milestone",milestoneLine:"milestone-line",milestonesContainer:"milestones",milestoneHovered:"milestone--hovered",barChartGroup:"bar-chart-group",lineGraphGroup:"line-graph-group",lineGraphGroupLabel:"line-graph-group-label",lineGraphPath:"line-graph-path",lineGraphHoverZone:"line-graph-hover-zone",lineGraphDot:"line-graph-dot",curtain:"curtain",forbiddenInterval:"forbidden-interval"},Ge={transparencyGradient:"transparency-gradient",transparencyGradientLight:"transparency-gradient-light",loadingGradient:"loading-gradient",stripedPattern:"stripedPattern"},Eh=Ae.extend({name:"ETimeline",directives:{resizeObserver:ni},components:{ETimelineMilestone:Th},props:{eventsGroups:{type:Object,default:()=>({})},xAxesConfig:{type:Object,default:()=>gh},dark:{type:Boolean,default:!1},startDate:{type:String,default:void 0},endDate:{type:String,default:void 0},selectedTimestamp:{type:String,default:void 0},showEventTooltip:{type:Boolean,default:!0},disableZoom:{type:Boolean,default:!1},insertZerosAtInterval:{type:String,default:void 0},flattenLineGraphEnds:{type:Boolean,default:!0},curtains:{type:Boolean,default:!1},showLabels:{type:Boolean,default:!0},rectMinWidth:{type:Number,default:1},barHeight:{type:Number,default:18},barYPadding:{type:Number,default:0},barXPadding:{type:Number,default:0},chartMinHeight:{type:Number,default:60},minZoom:{type:Number,default:1e-4},maxZoom:{type:Number,default:85e4},minDate:{type:String,default:void 0},maxDate:{type:String,default:void 0},minVisibleDate:{type:String,default:void 0},maxVisibleDate:{type:String,default:void 0},cursorTimestamp:{type:[String,void 0],default:void 0},selectedClass:{type:[String,void 0],default:void 0},panOnDateClick:{type:Boolean,default:!1},panTransitionDuration:{type:Number,default:800},selectedDate:{type:String,default:""},autoResize:{type:Boolean,default:!0},markers:{type:Array,default:()=>[]},stickyMarkers:{type:Boolean,default:!0},fitMarkersOnChange:{type:Boolean,default:!1},fitMarkersTransitionDuration:{type:Number,default:800},zoomToBoundariesTransitionDuration:{type:Number,default:0},milestoneBulletSize:{type:Number,default:18},milestonesFirst:{type:Boolean,default:!0}},data(){return{tooltip:null,cursor:null,timeline:null,wrapperDiv:null,selectedTimestampCursor:null,svg:null,axesContainer:null,xAxes:{},timeScale:null,initialTimeScale:null,currentTimeScaleDensity:null,zoomBehavior:null,isMouseDown:!1,axisHeight:22,isHoveringEvent:!1,hoveredEvent:null,isHoveringTimeline:!1,hoveredTimestamp:null,eventTooltipStyle:{},hoveredEventType:null,utcOffset:0,lastTransform:{x:0,k:1},transformDiff:{translation:0,scale:1},yScale:null,hoveredCounts:[],countsByTimestamp:{},dotsByTimestamp:{},visibleFrom:null,visibleTo:null,curtainHandleWidth:5,leftCurtainWidth:50,rightCurtainWidth:50,isHoveringCurtain:!1,isDraggingCurtain:!1,characterWidth:7.5,textPadding:5,debouncedOnResize:()=>{},isFirstPaint:!0,timeouts:[],groupsVisibility:{},markersPositions:{},markersDragBehavior:null,initialMarkerDragMouseOffset:0,selectedMilestoneId:null,isInitialized:!1,lastValidTransform:I.zoomIdentity}},computed:{combinedBarsHeight(){return Object.values(this.barGroups).reduce((s,e)=>s+(e.height||this.barChartHeight),0)},combinedMilestonesHeight(){return Object.values(this.milestonesGroups).reduce((s,e)=>s+(e.height||this.barChartHeight),0)},milestonesYOffset(){return this.milestonesFirst?0:this.combinedBarsHeight+(this.hasChart?this.chartHeight:0)},chartsYOffset(){return this.hasMilestones&&this.milestonesFirst?this.combinedMilestonesHeight:0},barsYOffset(){return(this.hasChart?this.chartHeight:0)+(this.hasMilestones&&this.milestonesFirst?this.combinedMilestonesHeight:0)},hasMilestones(){return Object.keys(this.milestonesGroups).length>0},barChartHeight(){return this.barHeight+this.barYPadding},classes(){return{wrapper:{"e-border-gray-700 e-timeline--dark":this.dark,"e-border-gray-300":!this.dark,"e-timeline--dragging":this.isInteractingWithCurtain},background:this.dark?"e-bg-gray-900":"e-bg-gray-50",tooltipSlot:this.dark?"e-bg-gray-900 e-text-white e-border-gray-700":"e-bg-gray-100 e-text-gray-700 e-border-gray-300",eventTooltipSlot:this.dark?"e-bg-gray-900 e-text-white e-border-gray-700":"e-bg-gray-100 e-text-gray-700 e-border-gray-300"}},lineGraphGroups(){return Object.entries(this.filteredEventsGroups).reduce((s,[e,t])=>t.chartType===ke.lineGraph?{...s,[e]:t}:s,{})},chartHeight(){if(!this.showLabels)return this.chartMinHeight;const e=(Object.keys(this.lineGraphGroups).length+Object.keys(this.barChartGroups).length)*this.barChartHeight;return Math.max(this.chartMinHeight,e)},barGroups(){return Object.entries(this.filteredEventsGroups).reduce((s,[e,t])=>!t.chartType||[ke.bars,ke.dots].includes(t.chartType)?{...s,[e]:t}:s,{})},barChartGroups(){return Object.entries(this.filteredEventsGroups).reduce((s,[e,t])=>t.chartType===ke.barChart?{...s,[e]:t}:s,{})},milestonesGroups(){return Object.entries(this.filteredEventsGroups).reduce((s,[e,t])=>t.chartType===ke.milestones?{...s,[e]:t}:s,{})},hasChart(){return Object.keys(this.lineGraphGroups).length+Object.keys(this.barChartGroups).length>0},labelRectWidth(){return Object.values(this.eventsGroups).reduce((t,i)=>{var r;return Math.max(t,(r=i.label)==null?void 0:r.length)},0)*this.characterWidth+2*this.textPadding},combinedXAxesHeight(){const s=Object.keys(this.xAxesConfig).length-1;return this.axisHeight*s},timelineHeight(){const s=Object.values(this.milestonesGroups).reduce((r,n)=>r+(n.height||this.barChartHeight),0),e=Object.keys(this.barGroups).length,t=this.barChartHeight*e,i=this.hasChart?this.chartHeight:0;return this.combinedXAxesHeight+i+t+s},filteredEventsGroups(){const s=Object.entries(this.eventsGroups).filter(([e,t])=>this.getCurrentGroupVisibility(e));return Object.fromEntries(s)},allEventsSorted(){const s=Object.values(this.filteredEventsGroups).map(e=>e.events).flat();return this.getSortedEvents(s)},oldestEvent(){let s;return this.allEventsSorted.length>1?s=this.allEventsSorted[0]:s={timestamp:new Date(new Date().getTime()-864e5)},s},latestEvent(){let s;return this.allEventsSorted.length>1?s=this.allEventsSorted[this.allEventsSorted.length-1]:s={timestamp:new Date},s},allLineChartTimestamps(){const s=new Set;return Object.values(this.lineGraphGroups).forEach(e=>{e.events.forEach(t=>{s.add(t.timestamp)})}),Array.from(s).sort()},placeholderLineChartGroup(){return this.fillTimeGaps(this.allLineChartTimestamps.map(s=>({timestamp:s,count:0})))},filledGapsLineGraphGroups(){return Object.entries(this.lineGraphGroups).reduce((s,[e,t])=>({...s,[e]:{...t,events:this.fillEvents(t.events)}}),{})},isInteractingWithCurtain(){return this.isHoveringCurtain||this.isDraggingCurtain},flattenedCounts(){return[...Object.values(this.lineGraphGroups),...Object.values(this.barChartGroups)].map(s=>s.events).flat()},hiddenGroupsLabels(){return Object.entries(this.groupsVisibility).reduce((s,[e,t])=>t?s:[...s,e],[])},minHoverZone(){return this.showLabels?this.labelRectWidth:0},sortedMarkers(){return this.isInitialized?[...this.markers].sort((s,e)=>new Date(s.timestamp).getTime()>new Date(e.timestamp).getTime()?1:-1):[]}},watch:{dark(){this.handleDarkModeChange()},selectedTimestamp(){this.repositionSelectedTimestampCursor()},markers(){this.updateMarkers(),this.fitMarkersOnChange&&this.zoomToFitMarkers()},startDate(){this.zoomToStartAndEndDates()},minDate(){this.updateForbiddenIntervals()},maxDate(){this.updateForbiddenIntervals()},endDate(){this.zoomToStartAndEndDates()},eventsGroups(){this.updateAndRedrawTimeline()},cursorTimestamp(){if(this.cursorTimestamp){this.hoveredTimestamp=this.cursorTimestamp;const s=this.tzStringToDate(this.hoveredTimestamp),e=this.timeScale(s);this.cursor.style.left=e+"px",this.isHoveringTimeline=!0}else this.isHoveringTimeline=!1},selectedDate(s){s&&this.panToTimestamp(s)},groupsVisibility(){this.updateAndRedrawTimeline()}},created(){this.debouncedOnResize=ga(this.handleResize,100)},mounted(){this.initTimeline()},beforeDestroy(){this.clearTimeline(),document.removeEventListener("mouseup",this.handleDocumentMouseUp)},methods:{updateTimeline(){this.initOrUpdateSvg(),this.updateXAxes(),this.updateYScaleDomain(),this.updateForbiddenIntervals(),this.drawEventsGroups(),this.updateCurtains(),this.repositionSelectedTimestampCursor(),this.updateMarkers(),this.registerEventsListeners(),this.isInitialized=!0},initTimeline(s,e){if(this.initRefs(),!this.timeline||this.timeline.offsetWidth===0){this.timeouts.push(setTimeout(this.initTimeline,500));return}this.initOrUpdateSvg(),this.initDefs(),this.initUtcOffset(),this.initTimeScale(s,e),this.initXAxes(),this.initYScale(),this.initZoomBehavior(),this.initForbiddenIntervals(),this.drawEventsGroups(),this.curtains&&(this.initCurtains(),this.emitCurtainChange()),this.initSelectedTimestampCursor(),this.updateMarkers(),this.registerEventsListeners(),this.emitVisibleInterval(gt.initial),this.selectedDate&&this.panOnDateClick&&this.panToTimestamp(this.selectedDate),this.isInitialized=!0},initRefs(){this.tooltip=this.$refs.tooltip,this.cursor=this.$refs.cursor,this.timeline=this.$refs.timelineContainer,this.selectedTimestampCursor=this.$refs.selectedTimestamp,this.wrapperDiv=this.$refs.wrapperDiv},initOrUpdateSvg(){this.svg||(this.svg=I.select(this.timeline).append("svg")),this.svg.attr("width",this.timeline.offsetWidth).attr("height",this.timelineHeight)},initDefs(){const s=this.svg.append("defs");Object.entries(this.filteredEventsGroups).forEach(([t,i])=>{const{color:r,chartType:n}=i,a=s.append("linearGradient").attr("id",`${Ge.loadingGradient}-${t}`).attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");a.append("stop").attr("offset","0%").attr("stop-color",r).attr("stop-opacity","0"),a.append("stop").attr("offset","50%").attr("stop-color",r).attr("stop-opacity","0.6"),a.append("stop").attr("offset","100%").attr("stop-color",r).attr("stop-opacity","0"),[ke.lineGraph,ke.barChart].includes(n)&&[{id:Ge.transparencyGradientLight,stop:38,opacity:.3},{id:Ge.transparencyGradient,stop:130,opacity:.4}].forEach(({id:l,stop:c,opacity:u})=>{const d=s.append("linearGradient").attr("id",`${l}-${t}`).attr("x1","0%").attr("x2","0%").attr("y1","0%").attr("y2","100%");d.append("stop").attr("offset","0%").style("stop-color",r).style("stop-opacity",u),d.append("stop").attr("offset",`${c}%`).style("stop-color",r).style("stop-opacity",0)})}),s.append("pattern").attr("id",Ge.stripedPattern).attr("width",6).attr("height",4).attr("patternUnits","userSpaceOnUse").attr("patternTransform","rotate(45)").append("rect").attr("width",2).attr("height",6).attr("transform","translate(0,0)").attr("fill","#ddd")},initUtcOffset(){const s=this.startDate||this.oldestEvent.timestamp||this.oldestEvent.startDate;this.utcOffset=ve.parseZone(s).utcOffset()},initTimeScale(s,e){const t=s||this.startDate||this.oldestEvent.timestamp||this.oldestEvent.startDate,i=e||this.endDate||this.latestEvent.timestamp||this.latestEvent.endDate;this.timeScale=I.scaleTime().domain([this.tzStringToDate(t),this.tzStringToDate(i)]).range([0,this.timeline.offsetWidth]),this.initialTimeScale=this.timeScale.copy(),this.updateCurrentTimeScaleDensity()},initXAxes(){let s=0;const e=5;for(const t in this.xAxesConfig){const i=this.createAxis(t);this.xAxes[t]=i,this.svg.append("g").classed($.xAxis,!0).classed(`${$.xAxis}-${t}`,!0).attr("transform",`translate(0, ${s||e})`).call(i),this.translateTicksText(t),s+=this.axisHeight}this.updateXAxes()},updateXAxes(){let s=0;const e=5;for(const t in this.xAxesConfig){const i=this.xAxes[t];i.tickSizeOuter(0),i.tickSizeInner(this.timelineHeight),this.svg.select(`.${$.xAxis}-${t}`).attr("transform",`translate(0, ${s||e})`).call(i),this.translateTicksText(t),s+=this.axisHeight}},initYScale(){this.yScale=I.scaleLinear().range([this.chartHeight,0]),this.updateYScaleDomain()},updateYScaleDomain(){const[s,e]=this.timeScale.domain(),t=this.flattenedCounts.filter(r=>{const n=new Date(r.startDate||r.timestamp),a=new Date(r.endDate||r.timestamp);return a>=s&&a<=e||n>=s&&n<=e}),i=I.max(t,r=>r.count);this.yScale.domain([0,i])},initZoomBehavior(){this.disableZoom||(this.zoomBehavior=I.zoom().on("zoom",this.handleZoom).scaleExtent([this.minZoom,this.maxZoom]),this.svg.call(this.zoomBehavior),this.svg.call(this.zoomBehavior.transform,I.zoomIdentity))},zoomToFitMarkers(){const s=this.markers.map(u=>new Date(u.timestamp).getTime());if(s.length<2)return;const e=Math.min(...s),t=Math.max(...s),i=this.initialTimeScale.domain().map(u=>u.getTime()),r=i[1]-i[0],n=t-e,a=.1*n,o=n+2*a;let l=r/o;const c=this.zoomBehavior.scaleExtent();l=Math.min(Math.max(l,c[0]),c[1]),this.svg.transition().duration(this.fitMarkersTransitionDuration/2).call(this.zoomBehavior.scaleTo,l).on("end",()=>this.translateMarkersIntoView(e,t,l))},translateMarkersIntoView(s,e,t){const i=this.timeScale(new Date(s)),r=this.timeScale(new Date(e)),n=(i+r)/2,o=this.svg.node().getBoundingClientRect().width/2-n,l=I.zoomTransform(this.svg.node());this.svg.transition().duration(this.fitMarkersTransitionDuration/2).call(this.zoomBehavior.transform,I.zoomIdentity.translate(l.x+o,l.y).scale(t))},initSelectedTimestampCursor(){this.svg.append("line").attr("class",$.selectedTimestampCursor).style("stroke","red").style("stroke-width","1px").style("opacity",0).attr("x1",0).attr("x2",0).attr("y1",0),this.repositionSelectedTimestampCursor()},updateMarkers(){if(!this.markers.length)return;const s=12,e=200;this.sortedMarkers.forEach((t,i,r)=>{const n=typeof t.timestamp=="string"?this.tzStringToDate(t.timestamp):t.timestamp,a=this.timeScale(n);let o=!1;const l=this.stickyMarkers?Math.max(a,i*s):a;if(i<r.length-1){const c=r[i+1],u=typeof c.timestamp=="string"?this.tzStringToDate(c.timestamp):c.timestamp,d=this.timeScale(u);o=(this.stickyMarkers?Math.max(d,(i+1)*s):a)-l<e+s}this.markersPositions={...this.markersPositions,[t.id]:{isHidden:o,position:l}}}),this.initMarkersDragBehavior()},updateAndRedrawTimeline(){this.updateTimeline()},clearTimeline(){this.svg&&this.svg.remove(),this.countsByTimestamp={}},repositionSelectedTimestampCursor(){const s=this.svg.select(`.${$.selectedTimestampCursor}`);if(!this.selectedTimestamp){s.style("opacity",0);return}const e=this.tzStringToDate(this.selectedTimestamp),t=this.timeScale(e);isNaN(t)?s.style("opacity",0):s.attr("x1",t).attr("x2",t).style("opacity",.5),s.attr("y2",this.timelineHeight)},updateCurrentTimeScaleDensity(){const s=this.timeScale.invert(0).getTime(),e=this.timeScale.invert(1).getTime(),t=36e5,i=(e-s)/t;isNaN(i)||(this.currentTimeScaleDensity=i)},registerEventsListeners(){document.addEventListener("mouseup",this.handleDocumentMouseUp),this.svg.on("mousedown",this.handleMouseDown),this.svg.on("mousemove",this.handleMouseMove),this.svg.on("click",this.handleClick),this.svg.on("mouseleave",this.handleMouseLeave)},emitVisibleInterval(s){const e=this.timeScale.invert(0),t=this.timeScale.invert(this.timeline.offsetWidth);if(this.visibleFrom&&this.visibleFrom.getTime()===e.getTime()&&this.visibleTo&&this.visibleTo.getTime()===t.getTime())return;this.visibleFrom=e,this.visibleTo=t;const i=this.dateToTzString(this.visibleFrom),r=this.dateToTzString(this.visibleTo);this.$emit("visible-interval-change",{fromDate:i,toDate:r,trigger:s,transform:this.transformDiff})},createAxis(s){const e=this.xAxesConfig[s],t=this.getAxisTicksConfig(e);return I.axisBottom(this.timeScale).ticks(t.interval).tickFormat(t.formatFn).tickSizeOuter(0).tickSizeInner(this.timelineHeight)},getAxisTicksConfig(s){const{interval:e,format:t}=s.find(r=>r.precision>=this.currentTimeScaleDensity&&r.interval);return{formatFn:r=>typeof t=="function"?t(r):I.timeFormat(t)(r),interval:e}},onResize(s){this.isFirstPaint?(this.handleResize(s),this.isFirstPaint=!1):this.debouncedOnResize(s)},handleResize({contentRect:s}){this.svg&&(this.svg.attr("width",s.width),this.updateAndRedrawTimeline())},handleDarkModeChange(){if(!this.showLabels)return;const s=this;this.svg.selectAll(`.${$.labelBg}`).each(function(){I.select(this).style("fill",s.dark?"black":"white")}),this.svg.selectAll(`.${$.labelBgFill}`).each(function(){const e=I.select(this),t=e.node().dataset.color;e.style("fill",s.getLabelBackgroundColor(t)).style("stroke",s.getTextFillColor(t)).style("stroke-width",.25)}),this.svg.selectAll(`.${$.labelText}`).each(function(){const e=I.select(this),t=e.node().dataset.color;e.style("fill",s.getTextFillColor(t))})},handleMouseDown(){this.isMouseDown=!0},handleDocumentMouseUp(s){this.isMouseDown=!1},handleMouseLeave(){this.isHoveringTimeline=!1,this.$emit("hovered-timestamp",void 0)},handleMouseMove(s){if(this.isMouseDown)return;const e=s.offsetX;if(e<=this.minHoverZone){this.isHoveringTimeline=!1;return}const t=this.timeScale.invert(e);this.hoveredTimestamp=this.dateToTzString(t),this.isHoveringTimeline=!0,this.$emit("hovered-timestamp",this.hoveredTimestamp),this.cursor.style.left=e+"px",this.tooltip&&(this.eventTooltipStyle={left:`${e}px`,bottom:`${this.timeline.getBoundingClientRect().height}px`,zIndex:100})},handleClick(s){const e=s.offsetX;if(e<=this.minHoverZone)return;const t=this.timeScale.invert(e),i=this.dateToTzString(t);this.$emit("date-clicked",i),this.isHoveringEvent&&this.$emit("event-clicked",{event:this.hoveredEvent,type:this.hoveredEventType}),this.panOnDateClick&&this.panToTimestamp(i)},handleMarkerClick(s){this.$emit("marker-clicked",s),this.panOnDateClick&&this.panToTimestamp(s.timestamp)},handleLineMouseOver(s,e,t){this.hoveredCounts=Object.entries(this.countsByTimestamp[`${e.timestamp}`]).reduce((i,r)=>{const[n,a]=r;return[...i,{type:n,count:a}]},[]),this.hoveredEvent=e,this.isHoveringEvent=!0,this.$emit("event-mouseover",{eventData:e,eventType:t,hoveredCounts:this.hoveredCounts})},handleLineMouseOut(){this.isHoveringEvent=!1,this.hoveredCounts=[],this.$emit("event-mouseout")},handleBarMouseOver(s,e,t){s.offsetX<=this.minHoverZone||(this.hoveredEvent=e,this.hoveredEventType=t,this.isHoveringEvent=!0,this.$emit("event-mouseover",{eventData:e,eventType:t}))},handleBarMouseOut(){this.isHoveringEvent=!1,this.hoveredEvent=null,this.$emit("event-mouseout")},handleLabelMouseOver(s){I.selectAll(`.${$.lineGraphGroup}-${s}`).classed(`${$.lineGraphGroup}--highlighted`,!0),I.selectAll(`.${$.lineGraphGroupLabel}`).classed(`${$.lineGraphGroupLabel}--highlighted`,!0)},handleLabelMouseLeave(s){I.selectAll(`.${$.lineGraphGroup}-${s}`).classed(`${$.lineGraphGroup}--highlighted`,!1),I.selectAll(`.${$.lineGraphGroupLabel}`).classed(`${$.lineGraphGroupLabel}--highlighted`,!1)},isZoomAllowed(s){const e=this.initialTimeScale.copy(),t=s.transform.rescaleX(e).domain(),i=this.minVisibleDate?this.tzStringToDate(this.minVisibleDate):void 0,r=this.maxVisibleDate?this.tzStringToDate(this.maxVisibleDate):void 0;return(!i||t[0]>=i)&&(!r||t[1]<=r)},handleZoom(s){if(!this.isZoomAllowed(s)){s.sourceEvent.preventDefault(),this.svg.call(this.zoomBehavior.transform,this.lastValidTransform);return}this.lastValidTransform=s.transform;const e=s.transform.rescaleX(this.initialTimeScale);this.timeScale.domain(e.domain()),this.updateCurrentTimeScaleDensity(),this.updateYScaleDomain();const t=s.transform.k/this.lastTransform.k;this.transformDiff={scale:t,translation:s.transform.x-this.lastTransform.x},this.lastTransform={...s.transform};for(const i in this.xAxes)this.rescaleAxis(i,e),this.translateTicksText(i);this.updateEventsBars(),this.updateLineGraphs(),this.updateBarChart(),this.updateLineGraphHoverZones(),this.updateMilestonesPositions(),this.repositionSelectedTimestampCursor(),this.updateForbiddenIntervals(),this.updateMarkers(),this.emitVisibleInterval(gt.zoom),this.curtains&&this.emitCurtainChange()},panToTimestamp(s){const e=this.tzStringToDate(s),t=this.timeScale(e),i=I.zoomTransform(this.svg.node()),r=i.x-t+this.timeline.offsetWidth/2;this.svg.transition().duration(this.panTransitionDuration).call(this.zoomBehavior.transform,I.zoomIdentity.translate(r,0).scale(i.k)),this.emitVisibleInterval(gt.autoPan)},emitCurtainChange(){const{startDate:s,endDate:e}=this.calculateDateRangeFromCurtains();this.$emit("curtain-range-change",{startDate:new Date(s).toISOString(),endDate:new Date(e).toISOString()})},calculateDateRangeFromCurtains(){const s=this.timeline.offsetWidth,e=this.timeScale.domain(),t=e[1].getTime()-e[0].getTime(),i=(this.leftCurtainWidth-this.curtainHandleWidth*2)/s*t,r=(this.rightCurtainWidth+this.curtainHandleWidth*2)/s*t,n=new Date(e[0].getTime()+i),a=new Date(e[1].getTime()-r);return{startDate:n,endDate:a}},handleDragStart(){this.isDraggingCurtain=!0},handleDragEnd(){this.isDraggingCurtain=!1},handleLeftDrag(s){s.sourceEvent.stopPropagation();const e=Math.min(s.x,this.timeline.offsetWidth-this.rightCurtainWidth);this.leftCurtainWidth=Math.max(0,e),this.svg.select(`.${$.curtain}--left`).attr("width",this.leftCurtainWidth),this.emitCurtainChange()},handleRightDrag(s){s.sourceEvent.stopPropagation();const e=this.timeline.offsetWidth,t=Math.min(this.timeline.offsetWidth-s.x,this.timeline.offsetWidth-this.leftCurtainWidth),i=e-t;this.rightCurtainWidth=Math.max(0,t),this.svg.select(`.${$.curtain}--right`).attr("width",this.rightCurtainWidth).attr("x",i),this.emitCurtainChange()},zoomToStartAndEndDates(){const s=this.startDate||this.oldestEvent.timestamp||this.oldestEvent.startDate,e=this.endDate||this.latestEvent.timestamp||this.latestEvent.endDate,t=this.tzStringToDate(s),i=this.tzStringToDate(e);this.initialTimeScale.domain([t,i]);const r=I.zoomTransform(this.svg.node()),n=i.getTime()-t.getTime(),o=this.initialTimeScale.range().map(f=>this.initialTimeScale.invert(f)).reduce((f,m)=>m.getTime()-f,0)/n*r.k,c=-(this.initialTimeScale(t)*o),[u,d]=this.zoomBehavior.scaleExtent(),h=Math.max(u,Math.min(d,o));this.svg.transition().duration(this.zoomToBoundariesTransitionDuration).call(this.zoomBehavior.transform,I.zoomIdentity.translate(c,0).scale(h))},rescaleAxis(s,e){const t=this.xAxes[s],i=this.getAxisTicksConfig(this.xAxesConfig[s]);t.scale(e).ticks(i.interval).tickFormat(i.formatFn).tickSizeOuter(0),this.svg.select(`.${$.xAxis}-${s}`).call(t)},translateTicksText(s){this.svg.select(`.${$.xAxis}-${s}`).selectAll(".tick text").each(function(){let e=I.select(this),t=e.node().getBBox();e.attr("x",t.height/2).attr("y",0).style("text-anchor","start")})},updateEventsBars(){const s=`.${$.eventGroup} > rect.${$.eventRect}`,e=`${s}:not(.${$.eventRect}--dot)`;this.svg.selectAll(s).attr("x",this.getEventRectX),this.svg.selectAll(e).attr("width",this.getEventRectWidth);const t=`.${$.eventGroup} > text.${$.eventRectText}`;this.svg.selectAll(t).attr("x",i=>this.getEventRectX(i)+this.textPadding).text(this.getEventText)},updateBarChart(){const s=Object.keys(this.barChartGroups).length;Object.keys(this.barChartGroups).forEach((e,t)=>{const i=h=>(this.getEventRectWidth(h)-this.barXPadding*2)/s,r=h=>this.yScale.range()[0]-this.yScale(h.count),n=h=>this.getEventRectX(h)+this.barXPadding+t*i(h),a=h=>this.yScale(h.count),o=`.${$.eventBarContainer}-${e}`,l=this.svg.selectAll(o),c=`.${$.barChartGroup} rect.${$.eventBarHoverZone}`;l.selectAll(c).attr("x",n).attr("width",i);const u=`.${$.barChartGroup} rect.${$.eventBar}`;l.selectAll(u).attr("x",n).attr("width",i).attr("y",a).attr("height",r);const d=`.${$.barChartGroup} rect.${$.eventBarCap}`;l.selectAll(d).attr("x",n).attr("width",i).attr("y",a)})},updateLineGraphs(){Object.entries(this.lineGraphGroups).forEach(([s])=>{const e=I.area().x(t=>this.timeScale(this.tzStringToDate(t.timestamp))).y0(this.timelineHeight).y1(t=>this.yScale(t.count)).curve(I.curveMonotoneX);this.svg.selectAll(`.${$.lineGraphPath}-${s}`).attr("d",t=>e(t))})},updateLineGraphHoverZones(){Object.keys(this.lineGraphGroups).forEach(s=>{const e=this;this.svg.selectAll(`.${$.lineGraphDot}-${s}`).each(function(t){I.select(this).attr("cx",e.timeScale(e.tzStringToDate(t.timestamp))).attr("cy",e.yScale(t.count))}),this.svg.selectAll(`.${$.lineGraphHoverZone}-${s}`).each(function(t){const i=e.timeScale(e.tzStringToDate(t.timestamp).getTime())-15;I.select(this).attr("x",i).attr("y",0).attr("width",30).attr("height",e.chartHeight)})})},getEventRectX(s){return isNaN(this.timeScale(this.tzStringToDate(s.startDate||s.timestamp)))?0:this.timeScale(this.tzStringToDate(s.startDate||s.timestamp))},getEventRectWidth(s){if(!s)return 0;if(s.startDate&&s.endDate){const e=new Date(s.startDate),t=new Date(s.endDate),i=this.timeScale(t)-this.timeScale(e);return Math.max(i,this.rectMinWidth)}else{const e=1/(this.currentTimeScaleDensity*3600);return Math.max(e,this.rectMinWidth)}},getEventText(s){var i;const t=(this.getEventRectWidth(s)-this.textPadding)/this.characterWidth;return t<4?"":((i=s.text)==null?void 0:i.length)<=t?s.text:`${s.text.slice(0,t-3)}...`},getElementLeftPosition(s){if(!s)return 0;const e=window.getComputedStyle(s);return parseInt(e.left)},isTimestampAllowedForMarker(s,e){return(this.minDate?s>=this.tzStringToDate(this.minDate):!0)&&(this.maxDate?s<=this.tzStringToDate(this.maxDate):!0)&&(e.minDate?s>=this.tzStringToDate(e.minDate):!0)&&(e.maxDate?s<=this.tzStringToDate(e.maxDate):!0)},handleMarkerDrag({marker:s,markerElement:e,dragEvent:t}){if(!s.isDraggable)return;t.type==="start"&&(this.initialMarkerDragMouseOffset=t.x-e.node().querySelector(`.${$.markerLine}`).getBoundingClientRect().left,e.classed($.markerDragged,!0));const i=t.x-this.initialMarkerDragMouseOffset,r=this.timeScale.invert(i-this.svg.node().getBoundingClientRect().left),n=this.timeScale(r),a=this.isTimestampAllowedForMarker(r,s);if(t.type==="drag"&&a&&e.attr("style",`left: ${n}px`),t.type==="end"&&a){const o=s.id||s.timestamp;this.markersPositions={...this.markersPositions,[o]:{...this.markersPositions[o],position:n}},e.classed($.markerDragged,!1)}t.type!=="start"&&this.$emit(`marker-drag-${t.type}`,{marker:s,newTimestamp:r.toISOString()})},removeMarkersDragBehavior(){this.markersDragBehavior&&(this.markersDragBehavior.on("start",null).on("drag",null).on("end",null),I.selectAll(`.${$.marker}`).call(this.markersDragBehavior))},initMarkersDragBehavior(){this.removeMarkersDragBehavior();const s=this;this.markersDragBehavior=I.drag().on("start",function(e,t){var i;(i=e.sourceEvent)==null||i.preventDefault(),s.handleMarkerDrag({marker:t,markerElement:I.select(this),dragEvent:e})}).on("drag",function(e,t){s.handleMarkerDrag({marker:t,markerElement:I.select(this),dragEvent:e})}).on("end",function(e,t){s.handleMarkerDrag({marker:t,markerElement:I.select(this),dragEvent:e})}),I.selectAll(`.${$.marker}`).data(this.sortedMarkers).call(this.markersDragBehavior)},initCurtains(){this.createCurtains(),this.updateCurtains()},createCurtains(){this.curtains&&(this.svg.append("rect").classed(`${$.curtain} ${$.curtain}--left`,!0).attr("fill","rgba(0, 0, 0, 0.5)").on("mouseenter",()=>this.isHoveringCurtain=!0).on("mouseleave",()=>this.isHoveringCurtain=!1).call(I.drag().on("start",this.handleDragStart).on("drag",this.handleLeftDrag).on("end",this.handleDragEnd)),this.svg.append("rect").classed(`${$.curtain} ${$.curtain}--right`,!0).attr("fill","rgba(0, 0, 0, 0.5)").on("mouseenter",()=>this.isHoveringCurtain=!0).on("mouseleave",()=>this.isHoveringCurtain=!1).call(I.drag().on("start",this.handleDragStart).on("drag",this.handleRightDrag).on("end",this.handleDragEnd)),this.updateCurtains())},updateCurtains(){const s=this.timeline.offsetWidth,e=this.timelineHeight;this.svg.select(`.${$.curtain}--left`).attr("width",this.leftCurtainWidth).attr("height",e+this.curtainHandleWidth*2).attr("y",-this.curtainHandleWidth).attr("x",-this.curtainHandleWidth),this.svg.select(`.${$.curtain}--right`).attr("x",s-this.rightCurtainWidth+this.curtainHandleWidth).attr("y",-this.curtainHandleWidth).attr("width",this.rightCurtainWidth+this.curtainHandleWidth*2).attr("height",e+this.curtainHandleWidth*2)},initForbiddenIntervals(){this.minDate&&this.svg.append("rect").attr("class",`${$.forbiddenInterval} ${$.forbiddenInterval}--min`),this.maxDate&&this.svg.append("rect").attr("class",`${$.forbiddenInterval} ${$.forbiddenInterval}--max`),this.updateForbiddenIntervals()},updateForbiddenIntervals(){const s=this.minDate?this.tzStringToDate(this.minDate).getTime():null,e=this.maxDate?this.tzStringToDate(this.maxDate).getTime():null;if(s){const t=this.timeScale(s);this.svg.select(`.${$.forbiddenInterval}--min`).attr("x",0).attr("y",0).attr("width",t>0?t:0).attr("height",this.timelineHeight).attr("fill",`url(#${Ge.stripedPattern})`)}if(e){const t=this.timeline.offsetWidth-this.timeScale(e),i=this.timeScale(e);this.svg.select(`.${$.forbiddenInterval}--max`).attr("x",i>0?i:0).attr("y",0).attr("width",t>0?t:0).attr("height",this.timelineHeight).attr("fill",`url(#${Ge.stripedPattern})`)}},drawEventsGroups(){this.svg.selectAll(`g.${$.eventGroup}`).remove(),this.svg.selectAll(`.${$.barChartGroup}`).remove(),this.svg.selectAll(`.${$.lineGraphGroup}`).remove(),this.svg.selectAll(`.${$.lineGraphGroupLabel}`).remove(),this.svg.selectAll(`.${$.loadingIndicator}`).remove(),this.drawLineGraphEventsGroups(),this.drawBarEventsGroups(),this.drawBarChartEventsGroups(),this.drawMilestonesPlaceholder()},drawLineGraphEventsGroups(){const s=this.combinedXAxesHeight+this.chartsYOffset,e=this.insertZerosAtInterval?this.filledGapsLineGraphGroups:this.lineGraphGroups;Object.entries(e).forEach(([t,i])=>{const r=this.svg.append("g").classed(`${$.lineGraphGroup} ${$.lineGraphGroup}-${t}`,!0).attr("transform",`translate(0,${s})`),{color:n,events:a}=i;this.drawLineGraph({events:a,gElement:r,color:n,type:t}),this.drawLineGraphHoverZones({events:a,gElement:r,color:n,type:t})}),Object.entries(this.lineGraphGroups).forEach(([t,i],r)=>{const{color:n,isLoading:a,label:o}=i,l=this.chartHeight-this.barChartHeight*(r+1),c=s+this.chartHeight-this.barChartHeight,u=this.svg.append("g").classed($.lineGraphGroupLabel,!0).attr("transform",`translate(0,${s})`).on("mouseover",()=>this.handleLabelMouseOver(t)).on("mouseleave",()=>this.handleLabelMouseLeave(t));this.drawProgressIndicator({type:t,color:n,isLoading:a,yPosition:c}),this.drawTextLabel({color:n,label:o,type:t,yPosition:l,gElement:u})})},drawLineGraph({events:s,gElement:e,color:t,type:i}){const r=I.area().x(a=>this.timeScale(this.tzStringToDate(a.timestamp))).y0(this.timelineHeight).y1(a=>this.yScale(a.count)).curve(I.curveMonotoneX),n=`clip-${i}`;e.append("defs").append("clipPath").attr("id",n).append("rect").attr("width",this.timeline.offsetWidth).attr("height",this.chartHeight),e.append("path").datum(s).classed(`${$.lineGraphPath}-${i}`,!0).attr("fill",`url(#${Ge.transparencyGradientLight}-${i})`).attr("stroke",t).attr("stroke-linejoin","round").attr("stroke-linecap","round").attr("stroke-width",1).attr("d",a=>r(a)).attr("clip-path",`url(#${n})`)},drawLineGraphHoverZones({events:s,gElement:e,color:t,type:i}){s.forEach(r=>{const n=`${r.timestamp}`;this.countsByTimestamp[n]={...this.countsByTimestamp[n]||{},[i]:r.count};const a=e.append("circle").classed(`${$.lineGraphDot} ${$.lineGraphDot}-${i}`,!0).attr("cx",this.timeScale(this.tzStringToDate(r.timestamp))).attr("cy",this.yScale(r.count)).attr("r",1.5).attr("fill",t).attr("stroke-width",0).datum(r);this.dotsByTimestamp[n]=[...this.dotsByTimestamp[n]||[],a],e.append("rect").classed(`${$.lineGraphHoverZone}-${i}`,!0).attr("x",this.timeScale(this.tzStringToDate(r.timestamp))-15).attr("y",0).attr("width",30).attr("height",this.chartHeight).attr("fill","transparent").datum(r).on("mouseover",o=>{this.handleLineMouseOver(o,r,i),this.dotsByTimestamp[n].forEach(l=>l.classed(`${$.lineGraphDot}--active`,!0))}).on("mouseout",()=>{this.handleLineMouseOut(),this.dotsByTimestamp[n].forEach(o=>o.classed(`${$.lineGraphDot}--active`,!1))})})},drawSingleBarEventsGroup({type:s,eventsGroup:e,index:t=0,milestone:i,height:r,dots:n,dotsSize:a}){const{color:o,bgColor:l,label:c,events:u,isLoading:d}=e;let h=t*this.barChartHeight+this.combinedXAxesHeight+this.barsYOffset;i&&(h=this.getMilestoneGroupYPosition(s)),this.drawProgressIndicator({yPosition:h,type:s,color:o,isLoading:d});const f=this.svg.append("g").attr("data-color",o).classed($.eventGroup,!0).classed(`${$.eventGroup}-${s}`,!0);if(this.drawBackground({color:l||o,gElement:f,yPosition:h,height:r}),i||n){const m=n?.5:2,g=h+this.barChartHeight/2;f.append("line").classed(qe.milestoneLine,!0).attr("x1",0).attr("x2",this.timeline.offsetWidth).attr("y1",g).attr("y2",g).style("stroke",o).style("stroke-width",m)}this.drawBars({events:u,color:o,gElement:f,yPosition:h,type:s,dots:n,dotsSize:a}),c&&this.drawTextLabel({color:o,label:c,type:s,gElement:f,yPosition:h,height:r})},drawBarEventsGroups(){Object.entries(this.barGroups).forEach(([s,e],t)=>this.drawSingleBarEventsGroup({type:s,eventsGroup:e,index:t,dots:e.chartType===ke.dots,dotsSize:e.dotsSize||3}))},drawMilestonesPlaceholder(){Object.entries(this.milestonesGroups).forEach(([s,e])=>this.drawSingleBarEventsGroup({type:s,eventsGroup:{...e,events:[],isLoading:!1},milestone:!0,height:e.height})),this.updateMilestonesPositions()},getMilestoneClass(s){return{[qe.milestoneSelected]:[s.id,s.timestamp].includes(this.selectedMilestoneId)}},getMilestoneColors(s,e){return{background:s||e,border:this.getTextFillColor(s||e,.25)}},getMilestoneGroupYPosition(s){let e=0;for(const[t,i]of Object.entries(this.milestonesGroups)){if(t===s)break;e+=i.height||this.barChartHeight}return this.combinedXAxesHeight+this.milestonesYOffset+e},updateMilestonesPositions(){Object.entries(this.milestonesGroups).forEach(([s,e])=>{const t=this.getMilestoneGroupYPosition(s),i=this.svg.select(`g.${$.eventGroup}-${s}`),r=2,a=(e.height||this.barChartHeight)/2,o=t+a-r/2;i.attr("x1",0).attr("x2",this.timeline.offsetWidth).select(`.${qe.milestoneLine}`).attr("y1",o).attr("y2",o);const l=I.select(`.${qe.milestonesContainer}-${s}`);l.style("top",`${t}px`).style("height",`${e.height||this.barChartHeight}px`);const c=l.selectAll(`.${qe.milestone}`).data(this.getSortedEvents(e.events));c.exit().remove(),c.enter().append("div").merge(c).style("left",u=>`${this.timeScale(this.tzStringToDate(u.timestamp))}px`).style("top",`${o}px`)})},drawBarChartEventsGroups(){const s=this.combinedXAxesHeight,e=this.barChartGroups;Object.entries(e).forEach(([t,i],r)=>{const n=this.svg.append("g").classed(`${$.barChartGroup} ${$.barChartGroup}-${t}`,!0).attr("transform",`translate(0,${s})`),{color:a,events:o}=i;this.drawBarsChart({events:o,color:a,gElement:n,yOffset:s,type:t,index:r})})},drawProgressIndicator({yPosition:s,type:e,isLoading:t}){this.svg.append("rect").classed(`${$.loadingIndicator} ${$.loadingIndicator}-${e}`,!0).attr("x",0).attr("y",s).attr("width",this.timeline.offsetWidth/3).attr("height",this.barChartHeight).attr("fill",`url(#${Ge.loadingGradient}-${e})`).style("visibility",t?"visible":"hidden")},drawBackground({color:s,yPosition:e,gElement:t,height:i}){t.append("rect").attr("class",$.eventGroupBg).attr("x",0).attr("y",e).attr("width",this.timeline.offsetWidth).attr("height",i||this.barChartHeight).attr("fill",I.color(s).toString()).style("opacity",.1)},drawBars({events:s,gElement:e,yPosition:t,color:i,type:r,dots:n,dotsSize:a}){const o=this,l=t+this.barYPadding/2,c=n?(this.barChartHeight-a)/2:0;e.selectAll($.eventRect).data(s).enter().append("rect").attr("class",u=>$.eventRect+(n?` ${$.eventRect}--dot`:"")+(u.className?` ${u.className}`:"")).attr("x",this.getEventRectX).attr("y",l+c).attr("ry",n?a:1.5).attr("rx",n?a:1.5).attr("width",n?a:this.getEventRectWidth).attr("height",n?a:this.barChartHeight-this.barYPadding).attr("stroke-width",5).attr("cursor","pointer").attr("stroke","#0000").style("fill",u=>u.color||i).on("mouseover",function(u,d){I.select(this).classed($.eventRectHovered,!0),o.handleBarMouseOver(u,d,r)}).on("mouseout",function(){I.select(this).classed($.eventRectHovered,!1),o.handleBarMouseOut()}),e.selectAll($.eventRectText).data(s.filter(u=>!!u.text)).enter().append("text").attr("class",$.eventRectText).attr("x",u=>this.getEventRectX(u)+this.textPadding).attr("y",t+this.barChartHeight/2).attr("dy","0.35em").style("text-anchor","start").style("font-size","12px").style("font-weight",600).style("stroke-linejoin","round").style("paint-order","stroke").style("pointer-events","none").style("fill",u=>this.getTextFillColor(u.color||i,.75)).text(this.getEventText)},drawBarsChart({events:s,gElement:e,color:t,yOffset:i,type:r,index:n}){const a=this,o=Object.keys(this.barChartGroups).length,l=f=>(this.getEventRectWidth(f)-this.barXPadding*2)/o,c=f=>this.yScale.range()[0]-this.yScale(f.count),u=f=>this.getEventRectX(f)+this.barXPadding+n*l(f),d=f=>this.yScale(f.count),h=e.selectAll($.eventBarContainer).data(s).enter().append("g").attr("class",`${$.eventBarContainer} ${$.eventBarContainer}-${r}`);h.append("rect").attr("class",f=>$.eventBarHoverZone+(f.className?` ${f.className}`:"")).attr("x",u).attr("y",-i).attr("width",l).attr("height",this.yScale.range()[0]+i).attr("fill",f=>f.color||t).attr("fill-opacity",0),h.append("rect").attr("class",f=>$.eventBar+(f.className?` ${f.className}`:"")).attr("x",u).attr("y",d).attr("width",l).attr("height",c).attr("stroke-width",5).attr("cursor","pointer").attr("stroke","#0000").attr("fill",`url(#${Ge.transparencyGradient}-${r})`),h.append("rect").attr("class",f=>$.eventBarCap+(f.className?` ${f.className}`:"")).attr("x",u).attr("y",d).attr("width",l).attr("height",2).attr("stroke-width",0).style("fill",f=>f.color||t),h.on("mouseover",function(f,m){const g=I.select(this);a.onBarChartBarMouseOver(g,t),a.handleBarMouseOver(f,m,r)}).on("mouseout",function(){const f=I.select(this);a.onBarChartBarMouseOut(f,r),a.handleBarMouseOut()}).on("click",function(){e.selectAll(`.${$.eventBarContainerSelected}`).classed($.eventBarContainerSelected,!1),I.select(this).classed($.eventBarContainerSelected,!0)})},onBarChartBarMouseOver(s,e){s.classed($.eventBarContainerHovered,!0),s.selectAll(`.${$.eventBarHoverZone}`).attr("fill-opacity",.2);const i=s.selectAll(`.${$.eventBar}`);i.attr("fill",e),i.attr("fill-opacity",.5)},onBarChartBarMouseOut(s,e){s.classed($.eventBarContainerHovered,!1),s.selectAll(`.${$.eventBarHoverZone}`).attr("fill-opacity",0);const i=s.selectAll(`.${$.eventBar}`);i.attr("fill",`url(#${Ge.transparencyGradient}-${e})`),i.attr("fill-opacity",1)},drawTextLabel({gElement:s,yPosition:e,color:t,label:i,type:r,height:n}){if(!this.showLabels)return;const a={x:-5,y:e,w:this.labelRectWidth,h:n||this.barChartHeight,radius:3},o=s.append("g").attr("class",`${$.labelGroup} ${$.labelGroup}-${r}`).style("cursor","pointer").on("click",()=>this.toggleGroupVisibility(r));o.append("rect").attr("class",$.labelBg).attr("data-color",t).attr("x",a.x).attr("y",a.y).attr("width",a.w).attr("height",a.h).attr("rx",a.radius).attr("ry",a.radius).style("fill",this.dark?"#131a29":"white"),o.append("rect").attr("class",$.labelBgFill).attr("data-color",t).attr("x",a.x).attr("y",a.y).attr("width",a.w).attr("height",a.h).attr("rx",a.radius).attr("ry",a.radius).style("fill",this.getLabelBackgroundColor(t)).style("stroke",this.getTextFillColor(t)).style("stroke-width",.25),o.append("text").attr("class",$.labelText).attr("data-color",t).attr("x",5).attr("y",e+(n||this.barChartHeight)/2).attr("dy","0.35em").style("text-anchor","start").style("font-size","12px").style("font-weight",500).style("stroke-linejoin","round").style("paint-order","stroke").style("fill",this.getTextFillColor(t)).text(i)},getTextFillColor(s,e=0){var t,i;return(this.dark?(t=I.color(s))==null?void 0:t.brighter(1.5+e):(i=I.color(s))==null?void 0:i.darker(2+e)).toString()},getLabelBackgroundColor(s){let e=I.color(s);return e.opacity=this.dark?.2:.5,e.toString()},getCurrentGroupVisibility(s){var i;const e=this.groupsVisibility[s];if(e!==void 0)return e;const t=(i=this.eventsGroups[s])==null?void 0:i.isHidden;return t!==void 0?!t:!0},toggleGroupVisibility(s){this.groupsVisibility={...this.groupsVisibility,[s]:!this.getCurrentGroupVisibility(s)}},getExternalLabelStyles(s){const e=this.eventsGroups[s].color;return{background:this.getLabelBackgroundColor(e),color:this.getTextFillColor(e)}},getExternalLabelWrapperStyles(s){const e=this.eventsGroups[s].color;return{borderColor:this.getTextFillColor(e)}},getMarkerClass(s){var e;return{"marker--hidden":(e=this.markersPositions[s==null?void 0:s.id])==null?void 0:e.isHidden,"marker--draggable":s==null?void 0:s.isDraggable,...s.className?{[s==null?void 0:s.className]:!0}:{}}},getMarkerContainerStyle(s){var e;return{left:`${(e=this.markersPositions[s.id])==null?void 0:e.position}px`}},getMarkerLabelStyle(s){return{background:s.color,color:s.textColor||""}},getMarkerLineStyle(s){return{background:s.color,height:`${this.timelineHeight+24}px`}},tzStringToDate(s){return ve(s).add(this.utcOffset,"minutes").toDate()},dateToTzString(s){const e=new Date(s).getTimezoneOffset();return ve(s).add(e,"minutes").utcOffset(this.utcOffset,!0).format()},getCurrentTimeBounds(){const s=this.timeScale.domain();return{startDate:s[0],endDate:s[1]}},getFormattedTimestamp(s){return ve.parseZone(s).format("YYYY-MM-DDTHH:mm:ss")},fillTimeGaps(s){if(s.length<=1)return s;const e=this.insertZerosAtInterval,t=n=>n.clone().add(1,e),i=n=>n.clone().subtract(1,e);let r=[];for(let n=0;n<s.length;n++){const a=s[n];if(r.push(a),n===s.length-1)break;const o=s[n+1],l=ve(a.timestamp),c=ve(o.timestamp);if(c.diff(l,e)>1){const u=t(l).toISOString(),d=i(c).toISOString();r.push({timestamp:u,count:0}),u!==d&&r.push({timestamp:d,count:0})}}if(this.flattenLineGraphEnds){const n=ve(s[0].timestamp),a=ve(s[s.length-1].timestamp),o=i(n).toISOString(),l=t(a).toISOString();r=[{timestamp:o,count:0},...r,{timestamp:l,count:0}]}return r},fillEvents(s){return this.placeholderLineChartGroup.map(e=>s.find(i=>i.timestamp===e.timestamp)||e)},onMilestoneClick(s,e){this.panOnDateClick&&this.panToTimestamp(s.timestamp),this.selectedMilestoneId=s.id||s.timestamp,this.$emit("milestone-click",{milestone:s,milestoneType:e})},getSortedEvents(s){return[...s].sort((e,t)=>new Date(e.timestamp||e.startDate)>new Date(t.timestamp||t.startDate)?1:-1)}}}),Gh="";var Sh=function(){var e=this,t=e._self._c;return t("div",{ref:"wrapperDiv",staticClass:"e-relative e-timeline e-border e-rounded",class:e.classes.wrapper},[t("div",{staticClass:"e-timeline__background e-w-full e-h-full e-absolute e-top-0 e-rounded",class:e.classes.background}),e._l(e.sortedMarkers,function(i){return t("div",{key:i.id,staticClass:"marker e-absolute e-h-full e-top-0",class:e.getMarkerClass(i),style:e.getMarkerContainerStyle(i),attrs:{"data-id":i.id},on:{click:function(r){return e.handleMarkerClick(i)}}},[t("div",{staticClass:"marker-label e-absolute"},[t("div",{staticClass:"marker-label-text",style:e.getMarkerLabelStyle(i)},[e._t(`marker.${i.id}`,function(){return[e._v(" "+e._s(i.label)+" ")]},{marker:i})],2)]),t("div",{staticClass:"marker-line e-absolute e-pointer-events-none",style:e.getMarkerLineStyle(i)})])}),e.autoResize?t("div",{directives:[{name:"resize-observer",rawName:"v-resize-observer",value:e.onResize,expression:"onResize"}],ref:"timelineContainer",staticClass:"e-timeline__svg-container e-relative e-h-13 e-rounded e-select-none e-overflow-x-hidden"}):t("div",{ref:"timelineContainer",staticClass:"e-timeline__svg-container e-relative e-h-13 e-rounded e-select-none e-overflow-x-hidden"}),e._l(e.milestonesGroups,function(i,r){return t("div",{key:`${r}`,staticClass:"e-timeline-milestones"},[t("div",{class:`e-tl-milestones e-tl-milestones-${r}`},e._l(e.getSortedEvents(i.events),function(n,a){return t("ETimelineMilestone",{key:`${n.milestoneType}-${a}`,class:e.getMilestoneClass(n),attrs:{"data-timestamp":n.timestamp,milestone:n,dot:i.dots,size:n.size||e.milestoneBulletSize,"transition-duration":i.milestonesTransitionDuration,"line-height":i.milestonesLineHeight,"dot-size":i.milestonesDotSize,"background-color":e.getMilestoneColors(n.color,i.color).background,"border-color":e.getMilestoneColors(n.color,i.color).border},on:{"milestone-click":function(o){return e.onMilestoneClick(n,r)}},scopedSlots:e._u([{key:"content",fn:function(){return[e._t(`milestoneContent.${n.milestoneType}`,function(){return[t("span",{staticClass:"e-px-2"},[e._v(" "+e._s(n.text)+" ")])]},{milestone:n,index:a})]},proxy:!0},{key:"label",fn:function(){return[e._t(`milestoneLabel.${n.milestoneType}`,null,{milestone:n})]},proxy:!0}],null,!0)})}),1)])}),t("div",{directives:[{name:"show",rawName:"v-show",value:e.isHoveringTimeline&&!e.isInteractingWithCurtain,expression:"isHoveringTimeline && !isInteractingWithCurtain"}],ref:"cursor",staticClass:"e-timeline__cursor e-absolute e-bg-green-600 e-w-px e-h-full e-top-0 e-pointer-events-none"}),t("div",{staticClass:"external-labels-container e-flex"},e._l(e.hiddenGroupsLabels,function(i){return t("div",{key:i,staticClass:"external-label",class:e.classes.background,style:e.getExternalLabelWrapperStyles(i),on:{click:function(r){return e.toggleGroupVisibility(i)}}},[t("div",{staticClass:"external-label__content",style:e.getExternalLabelStyles(i)},[e._v(" "+e._s(i)+" ")])])}),0),t("div",{key:"tooltip",ref:"tooltip",staticClass:"e-absolute",style:e.eventTooltipStyle},[e._t("tooltip",function(){return[t("div",{directives:[{name:"show",rawName:"v-show",value:e.isHoveringTimeline&&!e.isHoveringEvent&&!e.isInteractingWithCurtain&&!e.cursorTimestamp,expression:`
|
|
26
|
+
} (data length: ${t&&t.byteLength})`),r.update(t)}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,i)=>{const r=Si(this.config),n=e.map(rr).filter(a=>!!a&&r.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{const o=ar(a);o?t(o):i(new Error(`Unable to find format for key-system "${a}"`))}).catch(i)})}loadKey(e){const t=e.keyInfo.decryptdata,i=this.getKeyIdString(t),r=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${r}`);let n=this.keyIdToKeySessionPromise[i];return n||(n=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(t).then(({keySystem:a,mediaKeys:o})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${r}`),this.attemptSetMediaKeys(a,o).then(()=>{this.throwIfDestroyed();const l=this.createMediaKeySessionContext({keySystem:a,mediaKeys:o,decryptdata:t}),c="cenc";return this.generateRequestWithPreferredKeySession(l,c,t.pssh,"playlist-key")}))),n.catch(a=>this.handleError(a))),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof _e?this.hls.trigger(p.ERROR,e.data):this.hls.trigger(p.ERROR,{type:q.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){const t=this.getKeyIdString(e),i=this.keyIdToKeySessionPromise[t];if(!i){const r=rr(e.keyFormat),n=r?[r]:Si(this.config);return this.attemptKeySystemAccess(n)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=Si(this.config)),e.length===0)throw new _e({type:q.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){const{initDataType:t,initData:i}=e;if(this.debug(`"${e.type}" event: init data type: "${t}"`),i===null)return;let r,n;if(t==="sinf"&&this.config.drmSystems[ne.FAIRPLAY]){const u=ce(new Uint8Array(i));try{const d=Ti(JSON.parse(u).sinf),h=pr(new Uint8Array(d));if(!h)return;r=h.subarray(8,24),n=ne.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{const u=nl(i);if(u===null)return;u.version===0&&u.systemId===nr.WIDEVINE&&u.data&&(r=u.data.subarray(8,24)),n=Po(u.systemId)}if(!n||!r)return;const a=Oe.hexDump(r),{keyIdToKeySessionPromise:o,mediaKeySessions:l}=this;let c=o[a];for(let u=0;u<l.length;u++){const d=l[u],h=d.decryptdata;if(h.pssh||!h.keyId)continue;const f=Oe.hexDump(h.keyId);if(a===f||h.uri.replace(/-/g,"").indexOf(a)!==-1){c=o[f],delete o[f],h.pssh=new Uint8Array(i),h.keyId=r,c=o[a]=c.then(()=>this.generateRequestWithPreferredKeySession(d,t,i,"encrypted-event-key-match"));break}}c||(c=o[a]=this.getKeySystemSelectionPromise([n]).then(({keySystem:u,mediaKeys:d})=>{var h;this.throwIfDestroyed();const f=new vt("ISO-23001-7",a,(h=ar(u))!=null?h:"");return f.pssh=new Uint8Array(i),f.keyId=r,this.attemptSetMediaKeys(u,d).then(()=>{this.throwIfDestroyed();const m=this.createMediaKeySessionContext({decryptdata:f,keySystem:u,mediaKeys:d});return this.generateRequestWithPreferredKeySession(m,t,i,"encrypted-event-no-match")})})),c.catch(u=>this.handleError(u))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const r=Promise.all(i).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(r),r.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(r),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>i.indexOf(n)===-1)})}generateRequestWithPreferredKeySession(e,t,i,r){var n,a;const o=(n=this.config.drmSystems)==null||(a=n[e.keySystem])==null?void 0:a.generateRequest;if(o)try{const m=o.call(this.hls,t,i,e);if(!m)throw new Error("Invalid response from configured generateRequest filter");t=m.initDataType,i=e.decryptdata.pssh=m.initData?new Uint8Array(m.initData):null}catch(m){var l;if(this.warn(m.message),(l=this.hls)!=null&&l.config.debug)throw m}if(i===null)return this.log(`Skipping key-session request for "${r}" (no initData)`),Promise.resolve(e);const c=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${r}": ${c} (init data type: ${t} length: ${i?i.byteLength:null})`);const u=new Qi,d=e._onmessage=m=>{const g=e.mediaKeysSession;if(!g){u.emit("error",new Error("invalid state"));return}const{messageType:y,message:v}=m;this.log(`"${y}" message event for session "${g.sessionId}" message size: ${v.byteLength}`),y==="license-request"||y==="license-renewal"?this.renewLicense(e,v).catch(T=>{this.handleError(T),u.emit("error",T)}):y==="license-release"?e.keySystem===ne.FAIRPLAY&&(this.updateKeySession(e,Ei("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${y}"`)},h=e._onkeystatuseschange=m=>{if(!e.mediaKeysSession){u.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);const y=e.keyStatus;u.emit("keyStatus",y),y==="expired"&&(this.warn(`${e.keySystem} expired for key ${c}`),this.renewKeySession(e))};e.mediaKeysSession.addEventListener("message",d),e.mediaKeysSession.addEventListener("keystatuseschange",h);const f=new Promise((m,g)=>{u.on("error",g),u.on("keyStatus",y=>{y.startsWith("usable")?m():y==="output-restricted"?g(new _e({type:q.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):y==="internal-error"?g(new _e({type:q.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${y}"`)):y==="expired"?g(new Error("key expired while generating request")):this.warn(`unhandled key status change "${y}"`)})});return e.mediaKeysSession.generateRequest(t,i).then(()=>{var m;this.log(`Request generated for key-session "${(m=e.mediaKeysSession)==null?void 0:m.sessionId}" keyId: ${c}`)}).catch(m=>{throw new _e({type:q.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_SESSION,error:m,fatal:!1},`Error generating key-session request: ${m}`)}).then(()=>f).catch(m=>{throw u.removeAllListeners(),this.removeSession(e),m}).then(()=>(u.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,i)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${Oe.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${Oe.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){const t=this.config,i=t.loader,r=new i(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,o)=>{const l={responseType:"arraybuffer",url:n},c=t.certLoadPolicy.default,u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(h,f,m,g)=>{a(h.data)},onError:(h,f,m,g)=>{o(new _e({type:q.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:de({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`))},onTimeout:(h,f,m)=>{o(new _e({type:q.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(h,f,m)=>{o(new Error("aborted"))}};r.load(l,u,d)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,i){return new Promise((r,n)=>{e.setServerCertificate(i).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${i==null?void 0:i.byteLength}) on "${t}"`),r(e)}).catch(a=>{n(new _e({type:q.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(i=>this.updateKeySession(e,new Uint8Array(i)).catch(r=>{throw new _e({type:q.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:r,fatal:!0},r.message)}))}unpackPlayReadyKeyMessage(e,t){const i=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!i.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const r=new DOMParser().parseFromString(i,"application/xml"),n=r.querySelectorAll("HttpHeader");if(n.length>0){let u;for(let d=0,h=n.length;d<h;d++){var a,o;u=n[d];const f=(a=u.querySelector("name"))==null?void 0:a.textContent,m=(o=u.querySelector("value"))==null?void 0:o.textContent;f&&m&&e.setRequestHeader(f,m)}}const l=r.querySelector("Challenge"),c=l==null?void 0:l.textContent;if(!c)throw new Error("Cannot find <Challenge> in key message");return Ei(atob(c))}setupLicenseXHR(e,t,i,r){const n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,i,r)}).catch(a=>{if(!i.decryptdata)throw a;return e.open("POST",t,!0),n.call(this.hls,e,t,i,r)}).then(a=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:a||r})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:r}))}requestLicense(e,t){const i=this.config.keyLoadPolicy.default;return new Promise((r,n)=>{const a=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${a}`);const o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let l=o.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);const c=this.config.licenseResponseCallback;if(c)try{l=c.call(this.hls,o,a,e)}catch(u){this.error(u)}r(l)}else{const l=i.errorRetry,c=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>c||o.status>=400&&o.status<500)n(new _e({type:q.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{const u=c-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${u} attempts left`),this.requestLicense(e,t).then(r,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:l,licenseChallenge:c})=>{e.keySystem==ne.PLAYREADY&&(c=this.unpackPlayReadyKeyMessage(l,c)),l.send(c)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const i=t.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},vt.clearKeyUriToKeyIdMap();const i=t.length;ht.CDMCleanupPromise=Promise.all(t.map(r=>this.removeSession(r)).concat(e==null?void 0:e.setMediaKeys(null).catch(r=>{this.log(`Could not clear media keys: ${r}`)}))).then(()=>{i&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(r=>{this.log(`Could not close sessions and clear media keys: ${r}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){const i=t.reduce((r,n)=>(r.indexOf(n.keyFormat)===-1&&r.push(n.keyFormat),r),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:i}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const r=this.mediaKeySessions.indexOf(e);return r>-1&&this.mediaKeySessions.splice(r,1),t.remove().catch(n=>{this.log(`Could not remove session: ${n}`)}).then(()=>t.close()).catch(n=>{this.log(`Could not close session: ${n}`)})}}}ht.CDMCleanupPromise=void 0;class _e extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}var Te;(function(s){s.MANIFEST="m",s.AUDIO="a",s.VIDEO="v",s.MUXED="av",s.INIT="i",s.CAPTION="c",s.TIMED_TEXT="tt",s.KEY="k",s.OTHER="o"})(Te||(Te={}));var ds;(function(s){s.DASH="d",s.HLS="h",s.SMOOTH="s",s.OTHER="o"})(ds||(ds={}));var Je;(function(s){s.OBJECT="CMCD-Object",s.REQUEST="CMCD-Request",s.SESSION="CMCD-Session",s.STATUS="CMCD-Status"})(Je||(Je={}));const Au={[Je.OBJECT]:["br","d","ot","tb"],[Je.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[Je.SESSION]:["cid","pr","sf","sid","st","v"],[Je.STATUS]:["bs","rtp"]};class ft{constructor(e,t){this.value=void 0,this.params=void 0,Array.isArray(e)&&(e=e.map(i=>i instanceof ft?i:new ft(i))),this.value=e,this.params=t}}class Zn{constructor(e){this.description=void 0,this.description=e}}const Lu="Dict";function Cu(s){return Array.isArray(s)?JSON.stringify(s):s instanceof Map?"Map{}":s instanceof Set?"Set{}":typeof s=="object"?JSON.stringify(s):String(s)}function _u(s,e,t,i){return new Error(`failed to ${s} "${Cu(e)}" as ${t}`,{cause:i})}const Qn="Bare Item",Ru="Boolean",Du="Byte Sequence",Iu="Decimal",wu="Integer";function ku(s){return s<-999999999999999||999999999999999<s}const Pu=/[\x00-\x1f\x7f]+/,Fu="Token",Ou="Key";function Ue(s,e,t){return _u("serialize",s,e,t)}function Mu(s){if(typeof s!="boolean")throw Ue(s,Ru);return s?"?1":"?0"}function Nu(s){return btoa(String.fromCharCode(...s))}function Bu(s){if(ArrayBuffer.isView(s)===!1)throw Ue(s,Du);return`:${Nu(s)}:`}function Jn(s){if(ku(s))throw Ue(s,wu);return s.toString()}function $u(s){return`@${Jn(s.getTime()/1e3)}`}function ea(s,e){if(s<0)return-ea(-s,e);const t=Math.pow(10,e);if(Math.abs(s*t%1-.5)<Number.EPSILON){const r=Math.floor(s*t);return(r%2===0?r:r+1)/t}else return Math.round(s*t)/t}function Uu(s){const e=ea(s,3);if(Math.floor(Math.abs(e)).toString().length>12)throw Ue(s,Iu);const t=e.toString();return t.includes(".")?t:`${t}.0`}const Gu="String";function Hu(s){if(Pu.test(s))throw Ue(s,Gu);return`"${s.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Vu(s){return s.description||s.toString().slice(7,-1)}function ta(s){const e=Vu(s);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw Ue(e,Fu);return e}function hs(s){switch(typeof s){case"number":if(!z(s))throw Ue(s,Qn);return Number.isInteger(s)?Jn(s):Uu(s);case"string":return Hu(s);case"symbol":return ta(s);case"boolean":return Mu(s);case"object":if(s instanceof Date)return $u(s);if(s instanceof Uint8Array)return Bu(s);if(s instanceof Zn)return ta(s);default:throw Ue(s,Qn)}}function fs(s){if(/^[a-z*][a-z0-9\-_.*]*$/.test(s)===!1)throw Ue(s,Ou);return s}function ms(s){return s==null?"":Object.entries(s).map(([e,t])=>t===!0?`;${fs(e)}`:`;${fs(e)}=${hs(t)}`).join("")}function ia(s){return s instanceof ft?`${hs(s.value)}${ms(s.params)}`:hs(s)}function Ku(s){return`(${s.value.map(ia).join(" ")})${ms(s.params)}`}function zu(s,e={whitespace:!0}){if(typeof s!="object")throw Ue(s,Lu);const t=s instanceof Map?s.entries():Object.entries(s),i=e!=null&&e.whitespace?" ":"";return Array.from(t).map(([r,n])=>{n instanceof ft||(n=new ft(n));let a=fs(r);return n.value===!0?a+=ms(n.params):(a+="=",Array.isArray(n.value)?a+=Ku(n):a+=ia(n)),a}).join(`,${i}`)}function Wu(s,e){return zu(s,e)}const Yu=s=>s==="ot"||s==="sf"||s==="st",ju=s=>typeof s=="number"?z(s):s!=null&&s!==""&&s!==!1;function qu(s,e){const t=new URL(s),i=new URL(e);if(t.origin!==i.origin)return s;const r=t.pathname.split("/").slice(1),n=i.pathname.split("/").slice(1,-1);for(;r[0]===n[0];)r.shift(),n.shift();for(;n.length;)n.shift(),r.unshift("..");return r.join("/")}function Xu(){try{return crypto.randomUUID()}catch{try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{const n=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(r=="x"?n:n&3|8).toString(16)})}}}const ti=s=>Math.round(s),Zu=(s,e)=>(e!=null&&e.baseUrl&&(s=qu(s,e.baseUrl)),encodeURIComponent(s)),ii=s=>ti(s/100)*100,Qu={br:ti,d:ti,bl:ii,dl:ii,mtp:ii,nor:Zu,rtp:ii,tb:ti};function Ju(s,e){const t={};if(s==null||typeof s!="object")return t;const i=Object.keys(s).sort(),r=oe({},Qu,e==null?void 0:e.formatters),n=e==null?void 0:e.filter;return i.forEach(a=>{if(n!=null&&n(a))return;let o=s[a];const l=r[a];l&&(o=l(o,e)),!(a==="v"&&o===1)&&(a=="pr"&&o===1||ju(o)&&(Yu(a)&&typeof o=="string"&&(o=new Zn(o)),t[a]=o))}),t}function sa(s,e={}){return s?Wu(Ju(s,e),oe({whitespace:!1},e)):""}function ed(s,e={}){if(!s)return{};const t=Object.entries(s),i=Object.entries(Au).concat(Object.entries((e==null?void 0:e.customHeaderMap)||{})),r=t.reduce((n,a)=>{var o,l;const[c,u]=a,d=((o=i.find(h=>h[1].includes(c)))==null?void 0:o[0])||Je.REQUEST;return(l=n[d])!=null||(n[d]={}),n[d][c]=u,n},{});return Object.entries(r).reduce((n,[a,o])=>(n[a]=sa(o,e),n),{})}function td(s,e,t){return oe(s,ed(e,t))}const id="CMCD";function sd(s,e={}){if(!s)return"";const t=sa(s,e);return`${id}=${encodeURIComponent(t)}`}const ra=/CMCD=[^&#]+/;function rd(s,e,t){const i=sd(e,t);if(!i)return s;if(ra.test(s))return s.replace(ra,i);const r=s.includes("?")?"&":"?";return`${s}${r}${i}`}class nd{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=r=>{try{this.apply(r,{ot:Te.MANIFEST,su:!this.initialized})}catch(n){S.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=r=>{try{const n=r.frag,a=this.hls.levels[n.level],o=this.getObjectType(n),l={d:n.duration*1e3,ot:o};(o===Te.VIDEO||o===Te.AUDIO||o==Te.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(r,l)}catch(n){S.warn("Could not generate segment CMCD data.",n)}},this.hls=e;const t=this.config=e.config,{cmcd:i}=t;i!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||Xu(),this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.includeKeys=i.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHED,this.onMediaDetached,this),e.on(p.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHED,this.onMediaDetached,this),e.off(p.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var i,r;this.audioBuffer=(i=t.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(r=t.tracks.video)==null?void 0:r.buffer}createData(){var e;return{v:1,sf:ds.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){oe(t,this.createData());const i=t.ot===Te.INIT||t.ot===Te.VIDEO||t.ot===Te.MUXED;this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);const{includeKeys:r}=this;r&&(t=Object.keys(t).reduce((n,a)=>(r.includes(a)&&(n[a]=t[a]),n),{})),this.useHeaders?(e.headers||(e.headers={}),td(e.headers,t)):e.url=rd(e.url,t)}getObjectType(e){const{type:t}=e;if(t==="subtitle")return Te.TIMED_TEXT;if(e.sn==="initSegment")return Te.INIT;if(t==="audio")return Te.AUDIO;if(t==="main")return this.hls.audioTracks.length?Te.VIDEO:Te.MUXED}getTopBandwidth(e){let t=0,i;const r=this.hls;if(e===Te.AUDIO)i=r.audioTracks;else{const n=r.maxAutoLevel,a=n>-1?n+1:r.levels.length;i=r.levels.slice(0,a)}for(const n of i)n.bitrate>t&&(t=n.bitrate);return t>0?t:NaN}getBufferLength(e){const t=this.hls.media,i=e===Te.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!t?NaN:se.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,i=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}}const ad=3e5;class od{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=S.log.bind(S,"[content-steering]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.ERROR,this.onError,this))}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter(i=>i!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:i}=t;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:i}=t;if((i==null?void 0:i.action)===pe.SendAlternateToPenaltyBox&&i.flags===Ie.MoveAllAlternatesMatchingHost){const r=this.levels;let n=this.pathwayPriority,a=this.pathwayId;if(t.context){const{groupId:o,pathwayId:l,type:c}=t.context;o&&r?a=this.getPathwayForGroupId(o,c,a):l&&(a=l)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!n&&r&&(n=r.reduce((o,l)=>(o.indexOf(l.pathwayId)===-1&&o.push(l.pathwayId),o),[])),n&&n.length>1&&(this.updatePathwayPriority(n),i.resolved=this.pathwayId!==a),i.resolved||S.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${r&&r.length} priorities: ${JSON.stringify(n)} penalized: ${JSON.stringify(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){const i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i}return t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t;const i=this.penalizedPathways,r=performance.now();Object.keys(i).forEach(n=>{r-i[n]>ad&&delete i[n]});for(let n=0;n<e.length;n++){const a=e[n];if(a in i)continue;if(a===this.pathwayId)return;const o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,zr(t),this.hls.trigger(p.LEVELS_UPDATED,{levels:t});const c=this.hls.levels[o];l&&c&&this.levels&&(c.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&c.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${c.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,i){const r=this.getLevelsForPathway(i).concat(this.levels||[]);for(let n=0;n<r.length;n++)if(t===ee.AUDIO_TRACK&&r[n].hasAudioGroup(e)||t===ee.SUBTITLE_TRACK&&r[n].hasSubtitleGroup(e))return r[n].pathwayId;return i}clonePathways(e){const t=this.levels;if(!t)return;const i={},r={};e.forEach(n=>{const{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=n;if(t.some(u=>u.pathwayId===a))return;const c=this.getLevelsForPathway(o).map(u=>{const d=new ae(u.attrs);d["PATHWAY-ID"]=a;const h=d.AUDIO&&`${d.AUDIO}_clone_${a}`,f=d.SUBTITLES&&`${d.SUBTITLES}_clone_${a}`;h&&(i[d.AUDIO]=h,d.AUDIO=h),f&&(r[d.SUBTITLES]=f,d.SUBTITLES=f);const m=aa(u.uri,d["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),g=new st({attrs:d,audioCodec:u.audioCodec,bitrate:u.bitrate,height:u.height,name:u.name,url:m,videoCodec:u.videoCodec,width:u.width});if(u.audioGroups)for(let y=1;y<u.audioGroups.length;y++)g.addGroupId("audio",`${u.audioGroups[y]}_clone_${a}`);if(u.subtitleGroups)for(let y=1;y<u.subtitleGroups.length;y++)g.addGroupId("text",`${u.subtitleGroups[y]}_clone_${a}`);return g});t.push(...c),na(this.audioTracks,i,l,a),na(this.subtitleTracks,r,l,a)})}loadSteeringManifest(e){const t=this.hls.config,i=t.loader;this.loader&&this.loader.destroy(),this.loader=new i(t);let r;try{r=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(r.protocol!=="data:"){const u=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;r.searchParams.set("_HLS_pathway",this.pathwayId),r.searchParams.set("_HLS_throughput",""+u)}const n={responseType:"json",url:r.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},c={onSuccess:(u,d,h,f)=>{this.log(`Loaded steering manifest: "${r}"`);const m=u.data;if(m.VERSION!==1){this.log(`Steering VERSION ${m.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=m.TTL;const{"RELOAD-URI":g,"PATHWAY-CLONES":y,"PATHWAY-PRIORITY":v}=m;if(g)try{this.uri=new self.URL(g,r).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${g}`);return}this.scheduleRefresh(this.uri||h.url),y&&this.clonePathways(y);const T={steeringManifest:m,url:r.toString()};this.hls.trigger(p.STEERING_MANIFEST_LOADED,T),v&&this.updatePathwayPriority(v)},onError:(u,d,h,f)=>{if(this.log(`Error loading steering manifest: ${u.code} ${u.text} (${d.url})`),this.stopLoad(),u.code===410){this.enabled=!1,this.log(`Steering manifest ${d.url} no longer available`);return}let m=this.timeToLoad*1e3;if(u.code===429){const g=this.loader;if(typeof(g==null?void 0:g.getResponseHeader)=="function"){const y=g.getResponseHeader("Retry-After");y&&(m=parseFloat(y)*1e3)}this.log(`Steering manifest ${d.url} rate limited`);return}this.scheduleRefresh(this.uri||d.url,m)},onTimeout:(u,d,h)=>{this.log(`Timeout loading steering manifest (${d.url})`),this.scheduleRefresh(this.uri||d.url)}};this.log(`Requesting steering manifest: ${r}`),this.loader.load(n,l,c)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var i;const r=(i=this.hls)==null?void 0:i.media;if(r&&!r.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}}function na(s,e,t,i){s&&Object.keys(e).forEach(r=>{const n=s.filter(a=>a.groupId===r).map(a=>{const o=oe({},a);return o.details=void 0,o.attrs=new ae(o.attrs),o.url=o.attrs.URI=aa(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[r],o.attrs["PATHWAY-ID"]=i,o});s.push(...n)})}function aa(s,e,t,i){const{HOST:r,PARAMS:n,[t]:a}=i;let o;e&&(o=a==null?void 0:a[e],o&&(s=o));const l=new self.URL(s);return r&&!o&&(l.host=r),n&&Object.keys(n).sort().forEach(c=>{c&&l.searchParams.set(c,n[c])}),l.href}const ld=/^age:\s*[\d.]+\s*$/im;class oa{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new Dt,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null,this.stats=null}abortInternal(){const e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const i=this.loader=new self.XMLHttpRequest,r=this.stats;r.loading.first=0,r.loaded=0,r.aborted=!1;const n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!this.stats.aborted)return n(i,t.url)}).catch(a=>(i.open("GET",t.url,!0),n(i,t.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(a=>{this.callbacks.onError({code:i.status,text:a.message},t,i,r)}):this.openAndSendXhr(i,t,e)}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,!0);const r=t.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=i.loadPolicy;if(r)for(const o in r)e.setRequestHeader(o,r[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=n&&z(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:i}=this;if(!e||!t)return;const r=t.readyState,n=this.config;if(!i.aborted&&r>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),r===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const a=t.status,o=t.responseType!=="text";if(a>=200&&a<300&&(o&&t.response||t.responseText!==null)){i.loading.end=Math.max(self.performance.now(),i.loading.first);const l=o?t.response:t.responseText,c=t.responseType==="arraybuffer"?l.byteLength:l.length;if(i.loaded=i.total=c,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first),!this.callbacks)return;const u=this.callbacks.onProgress;if(u&&u(i,e,l,t),!this.callbacks)return;const d={url:t.responseURL,data:l,code:a};this.callbacks.onSuccess(d,i,e,t)}else{const l=n.loadPolicy.errorRetry,c=i.retry,u={url:e.url,data:void 0,code:a};Gt(l,c,!1,u)?this.retry(l):(S.error(`${a} while loading ${e.url}`),this.callbacks.onError({code:a,text:t.statusText},e,t,i))}}}loadtimeout(){var e;const t=(e=this.config)==null?void 0:e.loadPolicy.timeoutRetry,i=this.stats.retry;if(Gt(t,i,!0))this.retry(t);else{var r;S.warn(`timeout while loading ${(r=this.context)==null?void 0:r.url}`);const n=this.callbacks;n&&(this.abortInternal(),n.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:i}=this;this.retryDelay=Bi(e,i.retry),i.retry++,S.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t==null?void 0:t.url}, retrying ${i.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&ld.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}function cd(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const ud=/(\d+)-(\d+)\/(\d+)/;class la{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||md,this.controller=new self.AbortController,this.stats=new Dt}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,i){const r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now();const n=dd(e,this.controller.signal),a=i.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:c,maxLoadTimeMs:u}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=c&&z(c)?c:u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(r,e,this.response)},t.timeout),self.fetch(this.request).then(d=>{this.response=this.loader=d;const h=Math.max(self.performance.now(),r.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(r,e,this.response)},u-(h-r.loading.start)),!d.ok){const{status:f,statusText:m}=d;throw new gd(m||"fetch, bad network response",f,d)}return r.loading.first=h,r.total=fd(d.headers)||r.total,a&&z(t.highWaterMark)?this.loadProgressively(d,r,e,t.highWaterMark,a):o?d.arrayBuffer():e.responseType==="json"?d.json():d.text()}).then(d=>{const h=this.response;if(!h)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first);const f=d[l];f&&(r.loaded=r.total=f);const m={url:h.url,data:d,code:h.status};a&&!z(t.highWaterMark)&&a(r,e,d,h),i.onSuccess(m,r,e,h)}).catch(d=>{if(self.clearTimeout(this.requestTimeout),r.aborted)return;const h=d&&d.code||0,f=d?d.message:null;i.onError({code:h,text:f},e,d?d.details:null,r)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,i,r=0,n){const a=new rn,o=e.body.getReader(),l=()=>o.read().then(c=>{if(c.done)return a.dataLength&&n(t,i,a.flush(),e),Promise.resolve(new ArrayBuffer(0));const u=c.value,d=u.length;return t.loaded+=d,d<r||a.dataLength?(a.push(u),a.dataLength>=r&&n(t,i,a.flush(),e)):n(t,i,u,e),l()}).catch(()=>Promise.reject());return l()}}function dd(s,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(oe({},s.headers))};return s.rangeEnd&&t.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),t}function hd(s){const e=ud.exec(s);if(e)return parseInt(e[2])-parseInt(e[1])+1}function fd(s){const e=s.get("Content-Range");if(e){const i=hd(e);if(z(i))return i}const t=s.get("Content-Length");if(t)return parseInt(t)}function md(s,e){return new self.Request(s.url,e)}class gd extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}}const pd=/\s/,yd={newCue(s,e,t,i){const r=[];let n,a,o,l,c;const u=self.VTTCue||self.TextTrackCue;for(let h=0;h<i.rows.length;h++)if(n=i.rows[h],o=!0,l=0,c="",!n.isEmpty()){var d;for(let g=0;g<n.chars.length;g++)pd.test(n.chars[g].uchar)&&o?l++:(c+=n.chars[g].uchar,o=!1);n.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;const f=Gn(c.trim()),m=ns(e,t,f);s!=null&&(d=s.cues)!=null&&d.getCueById(m)||(a=new u(e,t,f),a.id=m,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),r.push(a))}return s&&r.length&&(r.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),r.forEach(h=>Nr(s,h))),r}},vd={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},ca=de(de({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:oa,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:jl,bufferController:Qc,capLevelController:us,errorController:Ml,fpsController:bu,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:or,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,certLoadPolicy:{default:vd},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},xd()),{},{subtitleStreamController:jc,subtitleTrackController:Xc,timelineController:Eu,audioStreamController:Wc,audioTrackController:Yc,emeController:ht,cmcdController:nd,contentSteeringController:od});function xd(){return{cueHandler:yd,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function Td(s,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const t=gs(s),i=["manifest","level","frag"],r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.forEach(n=>{const a=`${n==="level"?"playlist":n}LoadPolicy`,o=e[a]===void 0,l=[];r.forEach(c=>{const u=`${n}Loading${c}`,d=e[u];if(d!==void 0&&o){l.push(u);const h=t[a].default;switch(e[a]={default:h},c){case"TimeOut":h.maxLoadTimeMs=d,h.maxTimeToFirstByteMs=d;break;case"MaxRetry":h.errorRetry.maxNumRetry=d,h.timeoutRetry.maxNumRetry=d;break;case"RetryDelay":h.errorRetry.retryDelayMs=d,h.timeoutRetry.retryDelayMs=d;break;case"MaxRetryTimeout":h.errorRetry.maxRetryDelayMs=d,h.timeoutRetry.maxRetryDelayMs=d;break}}}),l.length&&S.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(e[a])}`)}),de(de({},t),e)}function gs(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(gs):Object.keys(s).reduce((e,t)=>(e[t]=gs(s[t]),e),{}):s}function Ed(s){const e=s.loader;e!==la&&e!==oa?(S.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1):cd()&&(s.loader=la,s.progressive=!0,s.enableSoftwareAES=!0,S.log("[config]: Progressive streaming enabled, using FetchLoader"))}let ps;class Sd extends Ui{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this),e.on(p.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this),e.off(p.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const i=this.hls.config.preferManagedMediaSource,r=[],n={},a={};let o=!1,l=!1,c=!1;t.levels.forEach(u=>{var d,h;const f=u.attrs;let{audioCodec:m,videoCodec:g}=u;((d=m)==null?void 0:d.indexOf("mp4a.40.34"))!==-1&&(ps||(ps=/chrome|firefox/i.test(navigator.userAgent)),ps&&(u.audioCodec=m=void 0)),m&&(u.audioCodec=m=Mt(m,i)),((h=g)==null?void 0:h.indexOf("avc1"))===0&&(g=u.videoCodec=dl(g));const{width:y,height:v,unknownCodecs:T}=u;if(o||(o=!!(y&&v)),l||(l=!!g),c||(c=!!m),T!=null&&T.length||m&&!Di(m,"audio",i)||g&&!Di(g,"video",i))return;const{CODECS:x,"FRAME-RATE":L,"HDCP-LEVEL":E,"PATHWAY-ID":k,RESOLUTION:C,"VIDEO-RANGE":B}=f,b=`${`${k||"."}-`}${u.bitrate}-${C}-${L}-${x}-${B}-${E}`;if(n[b])if(n[b].uri!==u.url&&!u.attrs["PATHWAY-ID"]){const R=a[b]+=1;u.attrs["PATHWAY-ID"]=new Array(R+1).join(".");const P=new st(u);n[b]=P,r.push(P)}else n[b].addGroupId("audio",f.AUDIO),n[b].addGroupId("text",f.SUBTITLES);else{const R=new st(u);n[b]=R,a[b]=1,r.push(R)}}),this.filterAndSortMediaOptions(r,t,o,l,c)}filterAndSortMediaOptions(e,t,i,r,n){let a=[],o=[],l=e;if((i||r)&&n&&(l=l.filter(({videoCodec:m,videoRange:g,width:y,height:v})=>(!!m||!!(y&&v))&&Al(g))),l.length===0){Promise.resolve().then(()=>{if(this.hls){t.levels.length&&this.warn(`One or more CODECS in variant not supported: ${JSON.stringify(t.levels[0].attrs)}`);const m=new Error("no level with compatible codecs found in manifest");this.hls.trigger(p.ERROR,{type:q.MEDIA_ERROR,details:D.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:m,reason:m.message})}});return}if(t.audioTracks){const{preferManagedMediaSource:m}=this.hls.config;a=t.audioTracks.filter(g=>!g.audioCodec||Di(g.audioCodec,"audio",m)),ua(a)}t.subtitles&&(o=t.subtitles,ua(o));const c=l.slice(0);l.sort((m,g)=>{if(m.attrs["HDCP-LEVEL"]!==g.attrs["HDCP-LEVEL"])return(m.attrs["HDCP-LEVEL"]||"")>(g.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&m.height!==g.height)return m.height-g.height;if(m.frameRate!==g.frameRate)return m.frameRate-g.frameRate;if(m.videoRange!==g.videoRange)return $t.indexOf(m.videoRange)-$t.indexOf(g.videoRange);if(m.videoCodec!==g.videoCodec){const y=Ar(m.videoCodec),v=Ar(g.videoCodec);if(y!==v)return v-y}if(m.uri===g.uri&&m.codecSet!==g.codecSet){const y=Ot(m.codecSet),v=Ot(g.codecSet);if(y!==v)return v-y}return m.averageBitrate!==g.averageBitrate?m.averageBitrate-g.averageBitrate:0});let u=c[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==c.length)){for(let m=0;m<c.length;m++)if(c[m].pathwayId===l[0].pathwayId){u=c[m];break}}this._levels=l;for(let m=0;m<l.length;m++)if(l[m]===u){var d;this._firstLevel=m;const g=u.bitrate,y=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${g}`),((d=this.hls.userConfig)==null?void 0:d.abrEwmaDefaultEstimate)===void 0){const v=Math.min(g,this.hls.config.abrEwmaDefaultEstimateMax);v>y&&y===ca.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=v)}break}const h=n&&!r,f={levels:l,audioTracks:a,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:r,altAudio:!h&&a.some(m=>!!m.url)};this.hls.trigger(p.MANIFEST_PARSED,f),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){const u=new Error("invalid level idx"),d=e<0;if(this.hls.trigger(p.ERROR,{type:q.OTHER_ERROR,details:D.LEVEL_SWITCH_ERROR,level:e,fatal:d,error:u,reason:u.message}),d)return;e=Math.min(e,t.length-1)}const i=this.currentLevelIndex,r=this.currentLevel,n=r?r.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,i===e&&a.details&&r&&n===o)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${o?" with Pathway "+o:""} from level ${i}${n?" with Pathway "+n:""}`);const l={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(p.LEVEL_SWITCHING,l);const c=a.details;if(!c||c.live){const u=this.switchParams(a.uri,r==null?void 0:r.details);this.loadPlaylist(u)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){const e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){t.fatal||!t.context||t.context.type===ee.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===j.MAIN){const i=t.elementaryStreams;if(!Object.keys(i).some(n=>!!i[n]))return;const r=this._levels[t.level];r!=null&&r.loadError&&(this.log(`Resetting level error count of ${r.loadError} on frag buffered`),r.loadError=0)}}onLevelLoaded(e,t){var i;const{level:r,details:n}=t,a=this._levels[r];if(!a){var o;this.warn(`Invalid level index ${r}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=!0);return}r===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0),this.playlistLoaded(r,t,a.details)):(i=t.deliveryDirectives)!=null&&i.skip&&(n.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist();const t=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){let r=i.uri;if(e)try{r=e.addDirectives(r)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}const n=i.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${n?" Pathway "+n:""} ${r}`),this.clearTimer(),this.hls.trigger(p.LEVEL_LOADING,{url:r,level:t,pathwayId:i.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;const i=this._levels.filter((r,n)=>n!==e?!0:(this.steering&&this.steering.removeLevel(r),r===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,r.details&&r.details.fragments.forEach(a=>a.level=-1)),!1));zr(i),this._levels=i,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(p.LEVELS_UPDATED,{levels:i})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:i}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(p.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}function ua(s){const e={};s.forEach(t=>{const i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++})}class bd{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const i in this.keyUriToKeyInfo){const r=this.keyUriToKeyInfo[i].loader;if(r){var t;if(e&&e!==((t=r.context)==null?void 0:t.frag.type))return;r.abort()}}}detach(){for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=D.KEY_LOAD_ERROR,i,r,n){return new Ve({type:q.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:i,networkDetails:r})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){const{sn:i,cc:r}=e;for(let n=0;n<t.length;n++){const a=t[n];if(r<=a.cc&&(i==="initSegment"||a.sn==="initSegment"||i<a.sn)){this.emeController.selectKeySystemFormat(a).then(o=>{a.setKeyFormat(o)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var i,r;t&&e.setKeyFormat(t);const n=e.decryptdata;if(!n){const c=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,c))}const a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if((i=o)!=null&&i.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if((r=o)!=null&&r.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(c=>(n.key=c.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[a]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){const i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const r=this.emeController.loadKey(i);if(r)return(e.keyLoadPromise=r.then(n=>(e.mediaKeySessionContext=n,i))).catch(n=>{throw e.keyLoadPromise=null,n})}return Promise.resolve(i)}loadKeyHTTP(e,t){const i=this.config,r=i.loader,n=new r(i);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,o)=>{const l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},c=i.keyLoadPolicy.default,u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(h,f,m,g)=>{const{frag:y,keyInfo:v,url:T}=m;if(!y.decryptdata||v!==this.keyUriToKeyInfo[T])return o(this.createKeyLoadError(y,D.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),g));v.decryptdata.key=y.decryptdata.key=new Uint8Array(h.data),y.keyLoader=null,v.loader=null,a({frag:y,keyInfo:v})},onError:(h,f,m,g)=>{this.resetLoader(f),o(this.createKeyLoadError(t,D.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),m,de({url:l.url,data:void 0},h)))},onTimeout:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,D.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m))},onAbort:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,D.INTERNAL_ABORTED,new Error("key loading aborted"),m))}};n.load(l,u,d)})}resetLoader(e){const{frag:t,keyInfo:i,url:r}=e,n=i.loader;t.keyLoader===n&&(t.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[r],n&&n.destroy()}}function da(){return self.SourceBuffer||self.WebKitSourceBuffer}function ha(){if(!tt())return!1;const e=da();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function Ad(){if(!ha())return!1;const s=tt();return typeof(s==null?void 0:s.isTypeSupported)=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>s.isTypeSupported(xt(e,"video")))||["mp4a.40.2","fLaC"].some(e=>s.isTypeSupported(xt(e,"audio"))))}function Ld(){var s;const e=da();return typeof(e==null||(s=e.prototype)==null?void 0:s.changeType)=="function"}const Cd=250,si=2,_d=.1,Rd=.05;class Dd{constructor(e,t,i,r){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=i,this.hls=r}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){const{config:i,media:r,stalled:n}=this;if(r===null)return;const{currentTime:a,seeking:o}=r,l=this.seeking&&!o,c=!this.seeking&&o;if(this.seeking=o,a!==e){if(this.moved=!0,o||(this.nudgeRetry=0),n!==null){if(this.stallReported){const y=self.performance.now()-n;S.warn(`playback not stuck anymore @${a}, after ${Math.round(y)}ms`),this.stallReported=!1}this.stalled=null}return}if(c||l){this.stalled=null;return}if(r.paused&&!o||r.ended||r.playbackRate===0||!se.getBuffered(r).length){this.nudgeRetry=0;return}const u=se.bufferInfo(r,a,0),d=u.nextStart||0;if(o){const y=u.len>si,v=!d||t&&t.start<=a||d-a>si&&!this.fragmentTracker.getPartialFragment(a);if(y||v)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var h;if(!(u.len>0)&&!d)return;const v=Math.max(d,u.start||0)-a,T=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,L=(T==null||(h=T.details)==null?void 0:h.live)?T.details.targetduration*2:si,E=this.fragmentTracker.getPartialFragment(a);if(v>0&&(v<=L||E)){r.paused||this._trySkipBufferHole(E);return}}const f=self.performance.now();if(n===null){this.stalled=f;return}const m=f-n;if(!o&&m>=Cd&&(this._reportStall(u),!this.media))return;const g=se.bufferInfo(r,a,i.maxBufferHole);this._tryFixBufferStall(g,m)}_tryFixBufferStall(e,t){const{config:i,fragmentTracker:r,media:n}=this;if(n===null)return;const a=n.currentTime,o=r.getPartialFragment(a);o&&(this._trySkipBufferHole(o)||!this.media)||(e.len>i.maxBufferHole||e.nextStart&&e.nextStart-a<i.maxBufferHole)&&t>i.highBufferWatchdogPeriod*1e3&&(S.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){const{hls:t,media:i,stallReported:r}=this;if(!r&&i){this.stallReported=!0;const n=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(e)})`);S.warn(n.message),t.trigger(p.ERROR,{type:q.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}}_trySkipBufferHole(e){const{config:t,hls:i,media:r}=this;if(r===null)return 0;const n=r.currentTime,a=se.bufferInfo(r,n,0),o=n<a.start?a.start:a.nextStart;if(o){const l=a.len<=t.maxBufferHole,c=a.len>0&&a.len<1&&r.readyState<3,u=o-n;if(u>0&&(l||c)){if(u>t.maxBufferHole){const{fragmentTracker:h}=this;let f=!1;if(n===0){const m=h.getAppendedFrag(0,j.MAIN);m&&o<m.end&&(f=!0)}if(!f){const m=e||h.getAppendedFrag(n,j.MAIN);if(m){let g=!1,y=m.end;for(;y<o;){const v=h.getPartialFragment(y);if(v)y+=v.duration;else{g=!0;break}}if(g)return 0}}}const d=Math.max(o+Rd,n+_d);if(S.warn(`skipping hole, adjusting currentTime from ${n} to ${d}`),this.moved=!0,this.stalled=null,r.currentTime=d,e&&!e.gap){const h=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${d}`);i.trigger(p.ERROR,{type:q.MEDIA_ERROR,details:D.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:h,reason:h.message,frag:e})}return d}}return 0}_tryNudgeBuffer(){const{config:e,hls:t,media:i,nudgeRetry:r}=this;if(i===null)return;const n=i.currentTime;if(this.nudgeRetry++,r<e.nudgeMaxRetry){const a=n+(r+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${n} to ${a}`);S.warn(o.message),i.currentTime=a,t.trigger(p.ERROR,{type:q.MEDIA_ERROR,details:D.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{const a=new Error(`Playhead still not moving while enough data buffered @${n} after ${e.nudgeMaxRetry} nudges`);S.error(a.message),t.trigger(p.ERROR,{type:q.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}}const Id=100;class wd extends Vi{constructor(e,t,i){super(e,t,i,"[stream-controller]",j.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(p.ERROR,this.onError,this),e.on(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(p.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(p.BUFFER_CREATED,this.onBufferCreated,this),e.on(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(p.ERROR,this.onError,this),e.off(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(p.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(p.BUFFER_CREATED,this.onBufferCreated,this),e.off(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying()}startLoad(e){if(this.levels){const{lastCurrentTime:t,hls:i}=this;if(this.stopLoad(),this.setInterval(Id),this.level=-1,!this.startFragRequested){let r=i.startLevel;r===-1&&(i.config.testBandwidth&&this.levels.length>1?(r=0,this.bitrateTest=!0):r=i.firstAutoLevel),i.nextLoadLevel=r,this.level=i.loadLevel,this.loadedmetadata=!1}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=M.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=M.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case M.WAITING_LEVEL:{const{levels:t,level:i}=this,r=t==null?void 0:t[i],n=r==null?void 0:r.details;if(n&&(!n.live||this.levelLastLoaded===r)){if(this.waitForCdnTuneIn(n))break;this.state=M.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=M.IDLE;break}break}case M.FRAG_LOADING_WAITING_RETRY:{var e;const t=self.performance.now(),i=this.retryDate;if(!i||t>=i||(e=this.media)!=null&&e.seeking){const{levels:r,level:n}=this,a=r==null?void 0:r[n];this.resetStartWhenNotLoaded(a||null),this.state=M.IDLE}}break}this.state===M.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:i,media:r}=this;if(t===null||!r&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;const n=e.nextLoadLevel;if(!(i!=null&&i[n]))return;const a=i[n],o=this.getMainFwdBufferInfo();if(o===null)return;const l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){const g={};this.altAudio&&(g.type="video"),this.hls.trigger(p.BUFFER_EOS,g),this.state=M.ENDED;return}e.loadLevel!==n&&e.manualLevel===-1&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;const c=a.details;if(!c||this.state===M.WAITING_LEVEL||c.live&&this.levelLastLoaded!==a){this.level=n,this.state=M.WAITING_LEVEL;return}const u=o.len,d=this.getMaxBufferLength(a.maxBitrate);if(u>=d)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);const h=this.backtrackFragment?this.backtrackFragment.start:o.end;let f=this.getNextFragment(h,c);if(this.couldBacktrack&&!this.fragPrevious&&f&&f.sn!=="initSegment"&&this.fragmentTracker.getState(f)!==he.OK){var m;const y=((m=this.backtrackFragment)!=null?m:f).sn-c.startSN,v=c.fragments[y-1];v&&f.cc===v.cc&&(f=v,this.fragmentTracker.removeFragment(v))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,h)){if(!f.gap){const y=this.audioOnly&&!this.altAudio?te.AUDIO:te.VIDEO,v=(y===te.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;v&&this.afterBufferFlushed(v,y,j.MAIN)}f=this.getNextFragmentLoopLoading(f,c,o,j.MAIN,d)}f&&(f.initSegment&&!f.initSegment.data&&!this.bitrateTest&&(f=f.initSegment),this.loadFragment(f,a,h))}loadFragment(e,t,i){const r=this.fragmentTracker.getState(e);this.fragCurrent=e,r===he.NOT_LOADED||r===he.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,i)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,j.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(t!=null&&t.readyState){let i;const r=this.getAppendedFrag(t.currentTime);r&&r.start>1&&this.flushMainBuffer(0,r.start-1);const n=this.getLevelDetails();if(n!=null&&n.live){const o=this.getMainFwdBufferInfo();if(!o||o.len<n.targetduration*2)return}if(!t.paused&&e){const o=this.hls.nextLoadLevel,l=e[o],c=this.fragLastKbps;c&&this.fragCurrent?i=this.fragCurrent.duration*l.maxBitrate/(1e3*c)+1:i=0}else i=0;const a=this.getBufferedFrag(t.currentTime+i);if(a){const o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();const l=o.maxStartPTS?o.maxStartPTS:o.start,c=o.duration,u=Math.max(a.end,l+Math.min(Math.max(c-this.config.maxFragLookUpTolerance,c*(this.couldBacktrack?.5:.125)),c*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(u,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case M.KEY_LOADING:case M.FRAG_LOADING:case M.FRAG_LOADING_WAITING_RETRY:case M.PARSING:case M.PARSED:this.state=M.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const i=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new Dd(this.config,i,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const e=this.media,t=e?e.currentTime:null;z(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);const i=this.getMainFwdBufferInfo();if(i===null||i.len===0){this.warn(`Main forward buffer length on "seeked" event ${i?i.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(p.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1}onManifestParsed(e,t){let i=!1,r=!1;t.levels.forEach(n=>{const a=n.audioCodec;a&&(i=i||a.indexOf("mp4a.40.2")!==-1,r=r||a.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=i&&r&&!Ld(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:i}=this;if(!i||this.state!==M.IDLE)return;const r=i[t.level];(!r.details||r.details.live&&this.levelLastLoaded!==r||this.waitForCdnTuneIn(r.details))&&(this.state=M.WAITING_LEVEL)}onLevelLoaded(e,t){var i;const{levels:r}=this,n=t.level,a=t.details,o=a.totalduration;if(!r){this.warn(`Levels were reset while loading level ${n}`);return}this.log(`Level ${n} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);const l=r[n],c=this.fragCurrent;c&&(this.state===M.FRAG_LOADING||this.state===M.FRAG_LOADING_WAITING_RETRY)&&c.level!==t.level&&c.loader&&this.abortCurrentFrag();let u=0;if(a.live||(i=l.details)!=null&&i.live){var d;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;u=this.alignPlaylists(a,l.details,(d=this.levelLastLoaded)==null?void 0:d.details)}if(l.details=a,this.levelLastLoaded=l,this.hls.trigger(p.LEVEL_UPDATED,{details:a,level:n}),this.state===M.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=M.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,u),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:i,part:r,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const o=a[i.level],l=o.details;if(!l){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}const c=o.videoCodec,u=l.PTSKnown||!l.live,d=(t=i.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new Cn(this.hls,j.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=r?r.index:-1,g=m!==-1,y=new Gi(i.level,i.sn,i.stats.chunkCount,n.byteLength,m,g),v=this.initPTS[i.cc];f.push(n,d,h,c,i,r,l.totalduration,u,y,v)}onAudioTrackSwitching(e,t){const i=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const n=this.hls;i&&(n.trigger(p.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(p.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const i=t.id,r=!!this.hls.audioTracks[i].url;if(r){const n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=r,this.tick()}onBufferCreated(e,t){const i=t.tracks;let r,n,a=!1;for(const o in i){const l=i[o];if(l.id==="main"){if(n=o,r=l,o==="video"){const c=i[o];c&&(this.videoBuffer=c.buffer)}}else a=!0}a&&r?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:i,part:r}=t;if(i&&i.type!==j.MAIN)return;if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===M.PARSED&&(this.state=M.IDLE);return}const n=r?r.stats:i.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),i.sn!=="initSegment"&&(this.fragPrevious=i),this.fragBufferedComplete(i,r)}onError(e,t){var i;if(t.fatal){this.state=M.ERROR;return}switch(t.details){case D.FRAG_GAP:case D.FRAG_PARSING_ERROR:case D.FRAG_DECRYPT_ERROR:case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(j.MAIN,t);break;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===M.WAITING_LEVEL&&((i=t.context)==null?void 0:i.type)===ee.LEVEL&&(this.state=M.IDLE);break;case D.BUFFER_APPEND_ERROR:case D.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;if(t.details===D.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){const{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!se.getBuffered(e).length){const i=this.state!==M.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,i)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=M.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==te.AUDIO||this.audioOnly&&!this.altAudio){const i=(t===te.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,t,j.MAIN),this.tick()}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let i=this.startPosition;if(i>=0&&t<i){if(e.seeking){this.log(`could not seek to ${i}, already seeking at ${t}`);return}const r=se.getBuffered(e),a=(r.length?r.start(0):0)-i;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${a} to match buffer start`),i+=a,this.startPosition=i),this.log(`seek to target start position ${i} from current time ${t}`),e.currentTime=i}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(i=>{const{hls:r}=this;if(!i||this.fragContextChanged(e))return;t.fragmentError=0,this.state=M.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const n=e.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),r.trigger(p.FRAG_LOADED,i),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;const i="main",{hls:r}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}const{frag:l,part:c,level:u}=o,{video:d,text:h,id3:f,initSegment:m}=n,{details:g}=u,y=this.altAudio?void 0:n.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=M.PARSING,m){if(m!=null&&m.tracks){const x=l.initSegment||l;this._bufferInitSegment(u,m.tracks,x,a),r.trigger(p.FRAG_PARSING_INIT_SEGMENT,{frag:x,id:i,tracks:m.tracks})}const v=m.initPTS,T=m.timescale;z(v)&&(this.initPTS[l.cc]={baseTime:v,timescale:T},r.trigger(p.INIT_PTS_FOUND,{frag:l,id:i,initPTS:v,timescale:T}))}if(d&&g&&l.sn!=="initSegment"){const v=g.fragments[l.sn-1-g.startSN],T=l.sn===g.startSN,x=!v||l.cc>v.cc;if(n.independent!==!1){const{startPTS:L,endPTS:E,startDTS:k,endDTS:C}=d;if(c)c.elementaryStreams[d.type]={startPTS:L,endPTS:E,startDTS:k,endDTS:C};else if(d.firstKeyFrame&&d.independent&&a.id===1&&!x&&(this.couldBacktrack=!0),d.dropped&&d.independent){const B=this.getMainFwdBufferInfo(),_=(B?B.end:this.getLoadPosition())+this.config.maxBufferHole,b=d.firstKeyFramePTS?d.firstKeyFramePTS:L;if(!T&&_<b-this.config.maxBufferHole&&!x){this.backtrack(l);return}else x&&(l.gap=!0);l.setElementaryStreamInfo(d.type,l.start,E,l.start,C,!0)}else T&&L>si&&(l.gap=!0);l.setElementaryStreamInfo(d.type,L,E,k,C),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(d,l,c,a,T||x)}else if(T||x)l.gap=!0;else{this.backtrack(l);return}}if(y){const{startPTS:v,endPTS:T,startDTS:x,endDTS:L}=y;c&&(c.elementaryStreams[te.AUDIO]={startPTS:v,endPTS:T,startDTS:x,endDTS:L}),l.setElementaryStreamInfo(te.AUDIO,v,T,x,L),this.bufferFragmentData(y,l,c,a)}if(g&&f!=null&&(t=f.samples)!=null&&t.length){const v={id:i,frag:l,details:g,samples:f.samples};r.trigger(p.FRAG_PARSING_METADATA,v)}if(g&&h){const v={id:i,frag:l,details:g,samples:h.samples};r.trigger(p.FRAG_PARSING_USERDATA,v)}}_bufferInitSegment(e,t,i,r){if(this.state!==M.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;const{audio:n,video:a,audiovideo:o}=t;if(n){let l=e.audioCodec;const c=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5"),n.metadata.channelCount!==1&&c.indexOf("firefox")===-1&&(l="mp4a.40.5")),l&&l.indexOf("mp4a.40.5")!==-1&&c.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),n.levelCodec=l,n.id="main",this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${n.codec}]`)}a&&(a.levelCodec=e.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),this.hls.trigger(p.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{const u=t[l].initSegment;u!=null&&u.byteLength&&this.hls.trigger(p.BUFFER_APPENDING,{type:l,data:u,frag:i,part:null,chunkMeta:r,parent:i.type})}),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,j.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=M.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const i=e.currentTime;if(se.isBuffered(e,i)?t=this.getAppendedFrag(i):se.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;const r=this.fragPlaying,n=t.level;(!r||t.sn!==r.sn||r.level!==n)&&(this.fragPlaying=t,this.hls.trigger(p.FRAG_CHANGED,{frag:t}),(!r||r.level!==n)&&this.hls.trigger(p.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){const e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){const e=this.media;if(e){const t=e.currentTime,i=this.currentFrag;if(i&&z(t)&&z(i.programDateTime)){const r=i.programDateTime+(t-i.start)*1e3;return new Date(r)}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class be{static get version(){return"1.5.6"}static isMSESupported(){return ha()}static isSupported(){return Ad()}static getMediaSource(){return tt()}static get Events(){return p}static get ErrorTypes(){return q}static get ErrorDetails(){return D}static get DefaultConfig(){return be.defaultConfig?be.defaultConfig:ca}static set DefaultConfig(e){be.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new Qi,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,bo(e.debug||!1,"Hls instance");const t=this.config=Td(be.DefaultConfig,e);this.userConfig=e,t.progressive&&Ed(t);const{abrController:i,bufferController:r,capLevelController:n,errorController:a,fpsController:o}=t,l=new a(this),c=this.abrController=new i(this),u=this.bufferController=new r(this),d=this.capLevelController=new n(this),h=new o(this),f=new pl(this),m=new El(this),g=t.contentSteeringController,y=g?new g(this):null,v=this.levelController=new Sd(this,y),T=new Xl(this),x=new bd(this.config),L=this.streamController=new wd(this,T,x);d.setStreamController(L),h.setStreamController(L);const E=[f,v,L];y&&E.splice(1,0,y),this.networkControllers=E;const k=[c,u,d,h,m,T];this.audioTrackController=this.createController(t.audioTrackController,E);const C=t.audioStreamController;C&&E.push(new C(this,T,x)),this.subtitleTrackController=this.createController(t.subtitleTrackController,E);const B=t.subtitleStreamController;B&&E.push(new B(this,T,x)),this.createController(t.timelineController,k),x.emeController=this.emeController=this.createController(t.emeController,k),this.cmcdController=this.createController(t.cmcdController,k),this.latencyController=this.createController(Sl,k),this.coreComponents=k,E.push(l);const _=l.onErrorOut;typeof _=="function"&&this.on(p.ERROR,_,l)}createController(e,t){if(e){const i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i)}once(e,t,i=this){this._emitter.once(e,t,i)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,i=this,r){this._emitter.off(e,t,i,r)}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(i){if(S.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),!this.triggeringException){this.triggeringException=!0;const r=e===p.ERROR;this.trigger(p.ERROR,{type:q.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:r,event:e,error:i}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){S.log("destroy"),this.trigger(p.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){S.log("attachMedia"),this._media=e,this.trigger(p.MEDIA_ATTACHING,{media:e})}detachMedia(){S.log("detachMedia"),this.trigger(p.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();const t=this.media,i=this.url,r=this.url=yi.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,S.log(`loadSource:${r}`),t&&i&&(i!==r||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(p.MANIFEST_LOADING,{url:e})}startLoad(e=-1){S.log(`startLoad(${e})`),this.started=!0,this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){S.log("stopLoad"),this.started=!1,this.networkControllers.forEach(e=>{e.stopLoad()})}resumeBuffering(){this.started&&this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.startLoad(-1)})}pauseBuffering(){this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.stopLoad()})}swapAudioCodec(){S.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){S.log("recoverMediaError");const e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e){this.levelController.removeLevel(e)}get levels(){const e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){S.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){S.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){S.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){S.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){S.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(S.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){bl(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const i=e.length;for(let r=0;r<i;r++)if(e[r].maxBitrate>=t)return r;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:i}=this;let r;if(t===-1&&e!=null&&e.length?r=e.length-1:r=t,i)for(let n=r;n--;){const a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=i)return n}return r}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}setAudioOption(e){var t;return(t=this.audioTrackController)==null?void 0:t.setAudioOption(e)}setSubtitleOption(e){var t;return(t=this.subtitleTrackController)==null||t.setSubtitleOption(e),null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}be.defaultConfig=void 0;function ys(){const s=document;return!!(s.fullscreenElement||s.mozFullScreenElement||s.webkitFullscreenElement||s.msFullscreenElement)}function fa(s){if(ys())return new Promise(t=>t(null));const e=s;if(e.requestFullscreen)return e==null?void 0:e.requestFullscreen();if(e.mozRequestFullScreen)return e==null?void 0:e.mozRequestFullScreen();if(e.webkitRequestFullScreen)return e==null?void 0:e.webkitRequestFullScreen();if(e.msRequestFullscreen)return e==null?void 0:e.msRequestFullscreen()}function ma(){if(!ys())return new Promise(e=>e(null));const s=document;if(s.exitFullscreen)return s.exitFullscreen();if(s.mozCancelFullScreen)return s.mozCancelFullScreen();if(s.webkitCancelFullScreen)return s.webkitCancelFullScreen();if(s.msExitFullscreen)return s.msExitFullscreen()}function ga(s,e){let t=null;return function(...i){const r=this;t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,s.apply(r,i)},e||1e3)}}const kd={name:"EToggleSwitch",props:{options:{type:Array,required:!0},color:{type:String,default:"brand"},size:{type:String,default:"sm"},defaultValue:{type:[String,Number,Boolean],default:null}},data(){return{value:this.defaultValue||this.options[0].value}},methods:{handleClick(s){this.value=s,this.$emit("input",s),console.log({value:this.value})}}};var Pd=function(){var e=this,t=e._self._c;return t("div",{class:{"e-flex e-items-center e-justify-center e-w-fit e-h-min e-bg-gray-900 e-rounded-md e-e-shadow-md e-transition-colors e-duration-200 e-ease-in-out":!0,"e-p-1":e.size==="sm","e-p-1.5":e.size==="md","e-p-2":e.size==="lg"}},[t("input",{directives:[{name:"model",rawName:"v-model",value:e.value,expression:"value"}],staticClass:"e-hidden",attrs:{id:"toggle",type:"checkbox"},domProps:{checked:Array.isArray(e.value)?e._i(e.value,null)>-1:e.value},on:{change:function(i){var r=e.value,n=i.target,a=!!n.checked;if(Array.isArray(r)){var o=null,l=e._i(r,o);n.checked?l<0&&(e.value=r.concat([o])):l>-1&&(e.value=r.slice(0,l).concat(r.slice(l+1)))}else e.value=a}}}),e._l(e.options,function(i){return t("button",{key:i.value,class:["e-cursor-pointer",{"e-bg-inherit":e.value!==i.value," e-text-gray-100 e-rounded-md e-shadow e-transition e-duration-200 e-ease-in-out":e.value===i.value,"e-py-[.2rem] e-p-1 e-rounded-md":e.size==="sm","e-p-1":e.size==="md","e-p-1.5":e.size==="lg","e-bg-brand-600":e.color==="brand"&&e.value===i.value,"e-bg-gray-600":!["primary","brand"].includes(e.color)&&e.value===i.value,"e-bg-[#629efc] e-text-gray-900 e-font-normal":e.color==="primary"&&e.value===i.value}],on:{click:function(r){return e.handleClick(i.value)}}},[t("span",{staticClass:"e-font-medium",class:{"e-text-xs":e.size==="sm","e-text-sm":e.size==="md","e-text-base":e.size==="lg"}},[e._v(e._s(i.title))])])})],2)},Fd=[],Od=ge(kd,Pd,Fd,!1,null,null,null,null);const vs=Od.exports,Md={name:"EVideoPlayerActions",components:{EToggleSwitch:vs},props:{frames:{type:Array,default:()=>[]},frameIndex:{type:Number,default:0},isLastFrame:{type:Boolean,default:!0},timePerFrame:{type:Number,default:250},isFullscreen:{type:Boolean,default:!1},isPlaying:{type:Boolean,default:!1},infoText:{type:Object,default:()=>({index:"",label:""})},hasLive:{type:Boolean,default:!1},isLive:{type:Boolean,default:!1},disablePlayButton:{type:Boolean,default:!1},isRecordingWidget:{type:Boolean,default:!1},initialSnapshotQuality:{type:[String,Number],default:Lt.auto},showSnapshotQuality:{type:Boolean,default:!1},isVideo:{type:Boolean,default:!1},hasEdgeVideo:{type:Boolean,default:!1},size:{type:String,default:"md"},allowedToChangeSpeed:{type:Boolean,default:!0},allowedToChangeQuality:{type:Boolean,default:!0}},data(){return{recordingType:"jpegs",allowedSpeeds:[.25,.5,.75,1,1.5,2,2.5],selectedSpeed:1,allowedQualities:Object.values(Lt),selectedQuality:"auto"}},computed:{isEdgeVideoEnabled(){return this.recordingType==="video"},switchOptions(){return[{title:"VIDEO",value:"video"},{title:"JPEGS",value:"jpegs"}]}},watch:{isEdgeVideoEnabled(s){this.$emit("toggle-video-mode",s)},isVideo:{handler(s){this.recordingType=s?"video":"jpegs"},immediate:!0}},mounted(){this.initPlayerSettings(),console.log({selectedQuality:this.selectedQuality,selectedSpeedIndex:this.selectedSpeed,allowedSpeeds:this.allowedSpeeds,allowedQualities:this.allowedQualities,selectedQualitySelected:this.allowedQualities.find(s=>s===this.selectedQuality),selectedSpeed:this.allowedSpeeds.find(s=>s===this.allowedSpeeds[this.selectedSpeed])})},methods:{toggleLive(){this.hasLive&&(this.isLive?this.$emit("disable-live-view"):this.$emit("enable-live-view"))},initPlayerSettings(){var t,i;if(!this.allowedToChangeQuality&&!this.allowedToChangeSpeed)return;const s=window.localStorage.getItem("snapshotsPlayerSpeed"),e=window.localStorage.getItem("snapshotsPlayerQuality");e!=="undefined"?this.selectedQuality=(t=this.allowedQualities.find(r=>r===e||r===this.initialSnapshotQuality))!=null?t:"auto":this.selectedQuality="auto",s?this.selectedSpeed=(i=this.allowedSpeeds.find(r=>r===Number.parseFloat(s)))!=null?i:1:this.selectedSpeed=1,this.updateTimePerFrame(),this.updateQuality()},updateFrameIndex(s){let e=this.frameIndex+s;e>=this.frames.length&&(e=this.frames.length-1),e<0&&(e=0),e>=0&&(this.$emit("frame-index-change",{frameIndex:e}),console.log({newIndex:e,$refs:this.$refs}))},updateTimePerFrame(){this.$emit("change",{timePerFrameValue:250/this.selectedSpeed}),this.allowedToChangeSpeed&&window.localStorage.setItem("snapshotsPlayerSpeed",this.selectedSpeed.toString())},updateQuality(){var s;this.$emit("snapshots-quality",this.selectedQuality),this.allowedToChangeQuality&&window.localStorage.setItem("snapshotsPlayerQuality",(s=this.selectedQuality)!=null?s:"auto")},toggleFullscreen(){this.$emit("toggle-fullscreen",{isFullscreen:!this.isFullscreen})},togglePlaying(){this.isLive&&this.frames.length>0&&this.$emit("disable-live-view"),this.$emit("toggle-play-pause",{isPlaying:!(this.isPlaying||this.isLive)})}}},Fh="";var Nd=function(){var e=this,t=e._self._c;return t("div",{staticClass:"e-relative e-flex e-items-center e-justify-between e-pt-2 e-pb-3"},[t("div",{staticClass:"e-w-1/3"},[t("EToggleSwitch",{attrs:{options:e.switchOptions,color:"primary",size:"sm"},on:{input:i=>e.recordingType=i}})],1),t("div",{staticClass:"e-m-auto e-flex e-flex-1 e-justify-center e-items-center e-gap-6"},[t("button",{staticClass:"e-select-none e-duration-200 e-cursor-pointer e-font-medium e-text-lg text-drop-shadow e-text-white hover:hover-filter-drop e-flex e-justify-center e-items-center e-align-middle",attrs:{text:"",icon:""},on:{click:function(i){return e.updateFrameIndex(-10)}}},[e.isVideo?t("svg",{staticClass:"ltr-0 e1mhci4z1",attrs:{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","data-name":"Back10","aria-hidden":"true"}},[t("path",{attrs:{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M11.0198 2.04817C13.3222 1.8214 15.6321 2.39998 17.5557 3.68532C19.4794 4.97066 20.8978 6.88324 21.5694 9.09717C22.241 11.3111 22.1242 13.6894 21.2388 15.8269C20.3534 17.9643 18.7543 19.7286 16.714 20.8192C14.6736 21.9098 12.3182 22.2592 10.0491 21.8079C7.77999 21.3565 5.73759 20.1323 4.26989 18.3439C2.80219 16.5555 2 14.3136 2 12L0 12C-2.74181e-06 14.7763 0.962627 17.4666 2.72387 19.6127C4.48511 21.7588 6.93599 23.2278 9.65891 23.7694C12.3818 24.3111 15.2083 23.8918 17.6568 22.5831C20.1052 21.2744 22.0241 19.1572 23.0866 16.5922C24.149 14.0273 24.2892 11.1733 23.4833 8.51661C22.6774 5.85989 20.9752 3.56479 18.6668 2.02238C16.3585 0.479973 13.5867 -0.214321 10.8238 0.0578004C8.71195 0.265799 6.70517 1.02858 5 2.2532V1H3V5C3 5.55228 3.44772 6 4 6H8V4H5.99999C7.45608 2.90793 9.19066 2.22833 11.0198 2.04817ZM2 4V7H5V9H1C0.447715 9 0 8.55228 0 8V4H2ZM14.125 16C13.5466 16 13.0389 15.8586 12.6018 15.5758C12.1713 15.2865 11.8385 14.8815 11.6031 14.3609C11.3677 13.8338 11.25 13.2135 11.25 12.5C11.25 11.7929 11.3677 11.1758 11.6031 10.6488C11.8385 10.1217 12.1713 9.71671 12.6018 9.43388C13.0389 9.14463 13.5466 9 14.125 9C14.7034 9 15.2077 9.14463 15.6382 9.43388C16.0753 9.71671 16.4116 10.1217 16.6469 10.6488C16.8823 11.1758 17 11.7929 17 12.5C17 13.2135 16.8823 13.8338 16.6469 14.3609C16.4116 14.8815 16.0753 15.2865 15.6382 15.5758C15.2077 15.8586 14.7034 16 14.125 16ZM14.125 14.6501C14.5151 14.6501 14.8211 14.4637 15.043 14.0909C15.2649 13.7117 15.3759 13.1814 15.3759 12.5C15.3759 11.8186 15.2649 11.2916 15.043 10.9187C14.8211 10.5395 14.5151 10.3499 14.125 10.3499C13.7349 10.3499 13.4289 10.5395 13.207 10.9187C12.9851 11.2916 12.8741 11.8186 12.8741 12.5C12.8741 13.1814 12.9851 13.7117 13.207 14.0909C13.4289 14.4637 13.7349 14.6501 14.125 14.6501ZM8.60395 15.8554V10.7163L7 11.1405V9.81956L10.1978 9.01928V15.8554H8.60395Z",fill:"currentColor"}})]):t("v-icon",[e._v(" fa-angle-double-left ")])],1),t("button",{staticClass:"lg:fa-2xl fa-xl fa-solid disabled:e-opacity-30 e-select-none e-duration-200 e-cursor-pointer text-drop-shadow e-text-white hover:hover-filter-drop e-flex e-justify-center e-items-center e-align-middle",class:{"e-mx-2 e-ml-4":e.size!=="sm","e-border-double e-border-0 e-border-[12*1.8]":e.isPlaying,"e-ml-3 e-mx-1":e.size==="sm","fa-play":!e.isPlaying||e.disablePlayButton||e.isLastFrame||e.isLive,"fa-pause":e.isPlaying},attrs:{"aria-label":e.isLive?"play":e.isPlaying?"pause":"play",disabled:e.disablePlayButton||e.isLastFrame||e.isLive,title:e.isPlaying?"pause":"play"},on:{click:function(i){return e.$emit("toggle-play-pause")}}}),t("button",{staticClass:"e-select-none disabled:e-opacity-30 e-duration-200 e-cursor-pointer e-font-medium e-text-lg text-drop-shadow e-text-white hover:hover-filter-drop e-flex e-justify-center e-items-center e-align-middle",attrs:{text:"",icon:"",disabled:e.isLive||e.isLastFrame,dark:""},on:{click:function(i){return e.updateFrameIndex(10)}}},[e.isVideo?t("svg",{staticClass:"ltr-0 e1mhci4z1",attrs:{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","data-name":"Forward10","aria-hidden":"true"}},[t("path",{attrs:{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M6.4443 3.68532C8.36795 2.39998 10.6778 1.8214 12.9802 2.04817C14.8093 2.22833 16.5439 2.90793 18 4H16V6H20C20.5523 6 21 5.55229 21 5V1H19V2.2532C17.2948 1.02859 15.2881 0.2658 13.1762 0.057802C10.4133 -0.214319 7.64154 0.479975 5.33316 2.02238C3.02478 3.56479 1.32262 5.85989 0.516718 8.51661C-0.289188 11.1733 -0.148981 14.0273 0.913451 16.5922C1.97588 19.1572 3.8948 21.2744 6.34325 22.5831C8.79169 23.8918 11.6182 24.3111 14.3411 23.7694C17.064 23.2278 19.5149 21.7588 21.2761 19.6127C23.0374 17.4666 24 14.7763 24 12L22 12C22 14.3136 21.1978 16.5555 19.7301 18.3439C18.2624 20.1323 16.22 21.3565 13.9509 21.8079C11.6818 22.2592 9.32641 21.9098 7.28604 20.8192C5.24567 19.7286 3.64657 17.9643 2.76121 15.8269C1.87585 13.6894 1.75901 11.3111 2.4306 9.09718C3.10219 6.88324 4.52065 4.97067 6.4443 3.68532ZM22 4V7H19V9H23C23.5523 9 24 8.55229 24 8V4H22ZM12.6018 15.5758C13.0389 15.8586 13.5466 16 14.125 16C14.7034 16 15.2078 15.8586 15.6382 15.5758C16.0753 15.2865 16.4116 14.8815 16.6469 14.3609C16.8823 13.8338 17 13.2135 17 12.5C17 11.7929 16.8823 11.1759 16.6469 10.6488C16.4116 10.1217 16.0753 9.71671 15.6382 9.43389C15.2078 9.14463 14.7034 9 14.125 9C13.5466 9 13.0389 9.14463 12.6018 9.43389C12.1713 9.71671 11.8385 10.1217 11.6031 10.6488C11.3677 11.1759 11.25 11.7929 11.25 12.5C11.25 13.2135 11.3677 13.8338 11.6031 14.3609C11.8385 14.8815 12.1713 15.2865 12.6018 15.5758ZM15.043 14.0909C14.8211 14.4637 14.5151 14.6501 14.125 14.6501C13.7349 14.6501 13.429 14.4637 13.207 14.0909C12.9851 13.7117 12.8741 13.1814 12.8741 12.5C12.8741 11.8186 12.9851 11.2916 13.207 10.9187C13.429 10.5395 13.7349 10.3499 14.125 10.3499C14.5151 10.3499 14.8211 10.5395 15.043 10.9187C15.2649 11.2916 15.3759 11.8186 15.3759 12.5C15.3759 13.1814 15.2649 13.7117 15.043 14.0909ZM8.60395 10.7163V15.8554H10.1978V9.01929L7 9.81956V11.1405L8.60395 10.7163Z",fill:"currentColor"}})]):t("v-icon",[e._v(" fa-angle-double-right")])],1)]),t("div",{staticClass:"e-flex e-items-center e-gap-4 e-w-1/3 e-justify-end"},[t("button",{staticClass:"e-relative e-flex e-items-center e-gap-2 e-justify-center e-px-3 e-py-1 e-font-medium e-text-xs lg:e-leading-6 e-shadow e-rounded-md e-bg-gray-900 lg:e-text-sm e-transition e-ease-in-out e-duration-150",on:{click:function(i){return i.preventDefault(),e.toggleLive.apply(null,arguments)}}},[e.hasLive&&e.isLive?t("span",{staticClass:"e-relative e-flex e-h-2 e-w-2"},[t("span",{staticClass:"e-animate-ping e-absolute e-inline-flex e-h-full e-w-full e-rounded-full e-bg-brand-400 e-opacity-75"}),t("span",{staticClass:"e-relative e-inline-flex e-rounded-full e-h-2 e-w-2 e-bg-brand-500"})]):t("span",{staticClass:"e-relative e-inline-flex e-rounded-full e-h-2 e-w-2 e-bg-slate-500"}),t("span",{class:{"e-text-brand-500":e.hasLive&&e.isLive,"e-text-gray-200":!e.hasLive||!e.isLive}},[e._v(" LIVE ")])]),t("label",{staticClass:"xl:e-flex e-justify-center e-items-center e-gap-2 e-hidden",attrs:{for:"playbackSpeedSelect"}},[t("span",{staticClass:"e-text-sm e-font-semibold"},[e._v(" playback speed x ")]),t("select",{directives:[{name:"model",rawName:"v-model",value:e.selectedSpeed,expression:"selectedSpeed"}],staticClass:"e-bg-none e-px-1 e-text-white e-font-semibold e-w-fit e-py-0 e-shadow-sm e-flex e-justify-center e-items-center",class:{"e-opacity-50 e-cursor-default":e.isLive},attrs:{id:"playbackSpeedSelect",disabled:e.isLive},on:{change:[function(i){var r=Array.prototype.filter.call(i.target.options,function(n){return n.selected}).map(function(n){var a="_value"in n?n._value:n.value;return a});e.selectedSpeed=i.target.multiple?r:r[0]},e.updateTimePerFrame]}},e._l(e.allowedSpeeds,function(i){return t("option",{key:i,staticClass:"e-bg-gray-900",domProps:{value:i}},[e._v(" "+e._s(i)+" ")])}),0)]),e.showSnapshotQuality?t("label",{staticClass:"xl:e-flex e-justify-center e-items-center e-gap-2 e-hidden",attrs:{for:"qualitySelect"}},[t("span",{staticClass:"fas fa-gear"}),t("select",{directives:[{name:"model",rawName:"v-model",value:e.selectedQuality,expression:"selectedQuality"}],staticClass:"e-bg-none e-px-1 e-text-white e-font-semibold e-w-fit e-py-0 e-shadow-sm e-flex e-justify-center e-items-center",class:{"e-opacity-50 e-cursor-default":e.isLive},attrs:{id:"qualitySelect",disabled:e.isLive},on:{change:[function(i){var r=Array.prototype.filter.call(i.target.options,function(n){return n.selected}).map(function(n){var a="_value"in n?n._value:n.value;return a});e.selectedQuality=i.target.multiple?r:r[0]},e.updateQuality]}},e._l(e.allowedQualities,function(i){return t("option",{key:i,staticClass:"e-bg-gray-900",domProps:{value:i}},[e._v(" "+e._s(i)+" ")])}),0)]):e._e(),t("button",{ref:"fullScreenCustomBtn",staticClass:"e-text-xl fa-2xl fa-solid e-cursor-pointer",class:{"fa-expand":!e.isFullscreen,"fa-compress":e.isFullscreen},on:{click:e.toggleFullscreen}})])])},Bd=[],$d=ge(Md,Nd,Bd,!1,null,null,null,null);const Ud=$d.exports,Gd={name:"EVideoPlayerProgressBar",props:{frames:{type:Array,default:()=>[]},events:{type:Array,default:()=>[]},preloadedFrames:{type:Array,default:()=>[]},frameIndex:{type:Number,default:0},ticks:{type:Boolean,default:!0},size:{type:String,default:"md"}},data(){return{hovered:!1,progressBar:null,isDraggingCursor:!1,mousePosition:{x:0,y:0},updateRefTimeout:null}},computed:{hoveredFrameData(){return this.frames[this.hoveredFrameIndex]||{}},mouseToWidthRatio(){var s,e,t;return this.mousePosition.x/((t=(e=(s=this.progressBar)==null?void 0:s.getBoundingClientRect())==null?void 0:e.width)!=null?t:1)},tooltipPosition(){var t,i,r;let s=this.size==="sm"?"65":"155",e;return this.mousePosition.x<Number(s)/2?e="7%":((r=(i=(t=this.progressBar)==null?void 0:t.getBoundingClientRect())==null?void 0:i.width)!=null?r:0)-this.mousePosition.x<Number(s)/2?e="93%":e=`${100*this.mouseToWidthRatio}%`,{width:`${s}px`,left:e,pointerEvents:"none",bottom:"6px"}},hoverBarStyle(){return{width:`${100*this.mouseToWidthRatio}%`}},progressStyle(){return{width:`${100*((this.isDraggingCursor?this.hoveredFrameIndex:this.frameIndex)/(this.frames.length-1))}%`}},hoveredFrameIndex(){return Math.round(this.mouseToWidthRatio*(this.frames.length-1))},preloadedChunks(){const s=[...this.preloadedFrames];return s.sort((e,t)=>e>t?1:-1),s.reduce((e,t)=>{if(!e.length)return[[t,t]];const[i,r]=e.slice(-1)[0]||[0,0];return t-r>1?[...e,[t,t]]:[...e.slice(0,-1),[i,t]]},[])}},mounted(){this.updateRefTimeout=setTimeout(()=>{this.updateRefs()})},beforeDestroy(){clearTimeout(this.updateRefTimeout)},methods:{getMousePosition(s){var t;if(!this.progressBar)return{x:0,y:0};const e=(t=this.progressBar)==null?void 0:t.getBoundingClientRect();return{x:s.clientX-e.x,y:s.clientY-e.y}},onMouseEnter(){this.hovered=!0},onMouseMove(s){this.mousePosition=this.getMousePosition(s)},onMouseLeave(){this.hovered=!1,this.isDraggingCursor=!1},onCursorMouseDown(){this.isDraggingCursor=!0},onCursorMouseUp(){this.isDraggingCursor=!1},onProgressBarClick(){this.$emit("change",{frameIndex:this.hoveredFrameIndex}),this.$emit("frame-index-change",{frameIndex:this.hoveredFrameIndex}),this.$emit("seek",this.hoveredFrameIndex)},updateRefs(){this.progressBar=this.$refs.progressBar},getChunkStyle(s,e){const[t,i]=[100*s/(this.frames.length-1),100*e/(this.frames.length-1)];return{left:`${t}%`,width:`${i-t}%`}}}},Oh="";var Hd=function(){var e=this,t=e._self._c;return t("div",{ref:"progressBar",staticClass:"e-relative e-z-[2] e-cursor-pointer e-w-full e-py-2 e-pt-3",on:{click:e.onProgressBarClick,mouseenter:e.onMouseEnter,mousemove:e.onMouseMove,mouseleave:e.onMouseLeave}},[t("div",{staticClass:"e-transition-opacity e-cursor-pointer e-duration-200"},[t("div",{staticClass:"e-bg-video-player-progress-bar-base-bg e-w-full e-h-[7px] e-absolute"}),e._l(e.preloadedChunks,function([i,r]){return t("span",{key:r,staticClass:"e-z-[1] e-bg-video-player-progress-bar-chunk-bg e-h-[7px] e-absolute",style:e.getChunkStyle(i,r)})}),t("div",{staticClass:"e-transition-background e-duration-200 e-h-[7px] e-absolute",class:{"e-bg-video-player-progress-bar-base-bg":!e.hovered,"e-bg-video-player-progress-bar-hover-bg":e.hovered},style:e.hoverBarStyle}),e.ticks&&e.frames.length<300?t("div",{staticClass:"e-flex e-justify-between e-items-center e-z-[3] e-w-full e-h-[7px] e-absolute"},e._l(e.frames,function(i,r){return t("div",{key:r,staticClass:"player-progress__tick e-h-[7px] e-bg-[#0064b1] e-w-[1px]"})}),0):e._e(),t("div",{staticClass:"e-h-[7px] e-absolute e-bg-video-player-progress-bar-progress-bg e-duration-200 e-ease-out e-z-[2]",style:e.progressStyle},[t("span",{staticClass:"e-right-0 e-h-[12px] e-w-[12px] e-opacity-0 e-z-[3] e-absolute e-border-2 e-border-solid e-border-white e-border-opacity-100 e-rounded-full e-transition-opacity e-duration-200 e-bg-red-500 e-transform e-translate-x-[3px] e-translate-y-[-3px]",on:{pointerdown:e.onCursorMouseDown,pointerup:e.onCursorMouseUp}})])],2),t("div",{staticClass:"player-progress-tooltip-shadow e-absolute e-duration-200 e-transition-opacity -e-translate-x-1/2 -e-translate-y-[150%] e-select-none e-text-white e-font-medium e-mt-2",class:{"e-opacity-0":!e.hovered,"e-opacity-100":e.hovered},style:e.tooltipPosition},[e._t("tooltip",null,{hoveredTimestamp:e.hoveredFrameData.timestamp,selectedFrame:e.hoveredFrameData.src}),e._v(" "+e._s(e.hoveredFrameData.label)+" ")],2)])},Vd=[],Kd=ge(Gd,Hd,Vd,!1,null,"92f9461c",null,null);const zd=Kd.exports,Wd={name:"EVideoThumbnailPreview",props:{targetTimestamp:{type:[Date,String,void 0],default:void 0},aspectRatio:{type:Number,default:16/9},height:{type:Number,default:175},thumbnailsUrls:{type:Array,default:()=>[]},selectedFrame:{type:String,default:""},timezone:{type:String,default:"UTC"}},data(){return{thumbnailWidth:0,thumbnailHeight:0,numberOfThumbnails:0,placeholderUrl:"data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="}},computed:{targetThumbnailIndex(){if(this.thumbnailsUrls.length===0||!this.targetTimestamp)return 0;const s=ve(new Date(this.targetTimestamp)),e=ve(s).startOf("hour"),t=s.diff(e,"seconds"),i=Math.floor(t/3600*this.thumbnailsUrls.length);return i<0?0:i>=this.thumbnailsUrls.length?this.thumbnailsUrls.length-1:i},thumbnailStyle(){return{height:`${this.height}px`,maxHeight:`${this.height}px`,aspectRatio:this.aspectRatio}}},watch:{targetTimestamp:{immediate:!0,async handler(s,e){const t=ve(s).startOf("hour").toString(),i=ve(e).startOf("hour").toString();if(t===i&&s)return;const r=ve.tz(t,this.timezone).startOf("hour").format("YYYY-MM-DDTHH:mm:ss[Z]");console.log({formattedHour:r}),this.$emit("download-thumbnail",r)}}},methods:{}},Mh="";var Yd=function(){var e=this,t=e._self._c;return t("div",{staticClass:"video-thumbnail"},[t("img",{staticClass:"video-thumbnail__img e-absolute -e-translate-x-1/4 -e-translate-y-[105%] e-rounded-[.5rem] img-shadow",style:e.thumbnailStyle,attrs:{src:e.selectedFrame||e.thumbnailsUrls[e.targetThumbnailIndex]||e.placeholderUrl,alt:"thumbnail"}})])},jd=[],qd=ge(Wd,Yd,jd,!1,null,null,null,null);const Xd=qd.exports,Zd={name:"EVideoPlayerControls",components:{EVideoPlayerActions:Ud,EVideoPlayerProgressBar:zd,EVideoPlayerThumbnailPreview:Xd},props:{size:{type:String,default:"md"},withProgressBar:{type:Boolean,default:!0},frames:{type:Array,default:()=>[]},events:{type:Array,default:()=>[]},frameIndex:{type:Number,default:0},preloadedFrames:{type:Array,default:()=>[]},withThumbnailPreview:{type:Boolean,default:!0},withPlayerActions:{type:Boolean,default:!0},isFullScreen:{type:Boolean,default:!1},isPlaying:{type:Boolean,default:!1},isLive:{type:Boolean,default:!1},currentTime:{type:String,default:""},videoLength:{type:String,default:""},thumbnailsUrls:{type:Array,default:()=>[]},timezone:{type:String,default:"UTC"}},data(){return{isFocused:!1}},computed:{containerClasses(){return this.size==="sm"?"e-px-2":"e-px-5"},isLastFrame(){return this.frameIndex===this.frames.length-1}}};var Qd=function(){var e=this,t=e._self._c;return t("div",{staticClass:"player__footer w-100",class:e.containerClasses,on:{mouseenter:function(i){e.isFocused=!0},mouseleave:function(i){e.isFocused=!1}}},[t("div",{staticClass:"player__footer__background"}),e.withProgressBar?t("EVideoPlayerProgressBar",e._b({attrs:{frames:e.frames,events:e.events,"frame-index":e.frameIndex,"preloaded-frames":e.preloadedFrames,timezone:e.timezone},on:{change:i=>e.$emit("on-state-change",i),seek:i=>e.$emit("on-progress-bar-seek",i),"frame-index-change":i=>e.$emit("frame-index-change",i),"marker-active":i=>e.$emit("marker-active",i),"marker-reset":i=>e.$emit("marker-reset",i),"marker-selected":i=>e.$emit("marker-selected",i)},scopedSlots:e._u([{key:"tooltip",fn:function({hoveredTimestamp:i}){return[e.withThumbnailPreview?t("EVideoPlayerThumbnailPreview",{attrs:{timezone:e.timezone,"target-timestamp":i,"thumbnails-urls":e.thumbnailsUrls},on:{"download-thumbnail":r=>e.$emit("download-thumbnail",r)}}):e._e()]}}],null,!1,3363812299)},"EVideoPlayerProgressBar",e.$attrs,!1)):e._e(),e.withPlayerActions?t("EVideoPlayerActions",{attrs:{"is-playing":e.isPlaying,"is-last-frame":e.isLastFrame,"is-fullscreen":e.isFullScreen,"is-live":e.isLive,frames:e.frames,"show-snapshot-quality":!0,"has-edge-video":!0,"is-video":!0,"frame-index":e.frameIndex,"has-live":!0},on:{"frame-index-change":i=>e.$emit("frame-index-change",i),"enable-live-view":function(i){return e.$emit("enable-live-view")},"disable-live-view":function(i){return e.$emit("disable-live-view")},change:function(i){return e.$emit("on-state-change",i)},"toggle-fullscreen":function(i){return e.$emit("toggle-fullscreen")},"toggle-video-mode":i=>e.$emit("toggle-video-mode",i),"toggle-play-pause":function(i){return e.$emit("toggle-play-pause")}}}):e._e()],1)},Jd=[],eh=ge(Zd,Qd,Jd,!1,null,null,null,null);const th=eh.exports,ih={name:"EZoomable",props:{ignorePointerEvents:{type:Boolean,default:!1},withOverlay:{type:Boolean,default:!0}},data(){return{scale:1,minScale:1,maxScale:20,top:0,left:0,isPanning:!1,panStart:{x:0,y:0},isPinching:!1,previousPinchDistance:0,pinchDistance:0,pointers:{},transform:"matrix(1, 0, 0, 1, 0, 0)"}},computed:{contentStyle(){return{transform:this.transform}},isZoomed(){return this.scale>1}},watch:{contentStyle:{handler(s){this.$emit("apply-zoomable-style",{imgStyle:s})},immediate:!0,deep:!0}},methods:{updateZoomScale(){this.scale>this.maxScale?this.scale=this.maxScale:this.scale<this.minScale&&(this.scale=this.minScale)},handleZoom(s){s.preventDefault();const e=this.$refs.container.getBoundingClientRect(),t=this.$refs.content.getBoundingClientRect();if(!e||!t)return;const i=s.clientX,r=s.clientY,n=Math.max(-1,Math.min(1,s.wheelDelta||-s.detail)),a=this.scale;this.scale+=n/10,this.updateZoomScale();const o=((i-t.left)/t.width).toFixed(2),l=((r-t.top)/t.height).toFixed(2);this.left=Math.round(i-e.left-o*(t.width*this.scale/a)),this.top=Math.round(r-e.top-l*(t.height*this.scale/a));const c=0,u=0-e.width*(this.scale-1),d=0-e.height*(this.scale-1),h=0;this.left<u?this.left=u:this.left>c&&(this.left=c),this.top<d?this.top=d:this.top>h&&(this.top=h),this.updateTransform()},handleMouseDown(s){this.isZoomed&&(this.isPanning=!0,this.panStart={x:s.clientX,y:s.clientY})},handleMouseUp(){this.isPanning=!1},handleMouseLeave(){this.isPanning=!1},handleMouseMove(s){if(!this.isPanning||!this.isZoomed)return;const e=s.clientX-this.panStart.x,t=s.clientY-this.panStart.y;this.left+=e,this.top+=t,this.applyBoundsCorrection(),this.panStart={x:s.clientX,y:s.clientY},this.updateTransform()},applyBoundsCorrection(){const s=this.$refs.container.getBoundingClientRect(),e=this.$refs.content.getBoundingClientRect();if(!s||!e)return;const[t,i,r,n]=[s.top-e.top,e.right-s.right,e.bottom-s.bottom,s.left-e.left].map(a=>a<0?a:0);this.left+=n-i,this.top+=t-r},updateTransform(){this.transform=`matrix(${this.scale}, 0, 0, ${this.scale}, ${this.left}, ${this.top})`},getPointersDistance(s,e){return Math.hypot(e.clientX-s.clientX,e.clientY-s.clientY)},getPointersMidPoint(s,e){return{x:s.clientX+(e.clientX-s.clientX)/2,y:s.clientY+(e.clientY-s.clientY)/2}},updatePointerEvent(s){this.pointers[s.pointerId]=s},clearPointerEvent(s){this.$delete(this.pointers,s.pointerId)},updatePinchDistance(){const s=Object.values(this.pointers);s.length===2&&(this.pinchDistance=this.getPointersDistance(...s))},handlePointerDown(s){this.ignorePointerEvents||(this.updatePointerEvent(s),this.isPinching=Object.values(this.pointers).length===2,this.isPinching?(this.isPanning=!1,this.updatePinchDistance()):this.handleMouseDown(s))},handlePointerMove(s){if(!this.ignorePointerEvents)if(this.updatePointerEvent(s),this.isPinching){this.previousPinchDistance=this.pinchDistance,this.updatePinchDistance();const e=this.pinchDistance/this.previousPinchDistance;this.scale*=e,this.updateZoomScale();const t=Object.values(this.pointers),i=this.getPointersMidPoint(...t);this.left=i.x-(i.x-this.left)*e,this.top=i.y-(i.y-this.top)*e,this.applyBoundsCorrection(),this.updateTransform()}else this.handleMouseMove(s)},handlePointerUp(s){this.ignorePointerEvents||(this.clearPointerEvent(s),this.previousPinchDistance=0,this.pinchDistance=0,this.isPanning=!1,this.isPinching=!1)}}},Nh="";var sh=function(){var e=this,t=e._self._c;return t("div",{ref:"container",staticClass:"e-w-full e-h-full"},[t("div",{staticClass:"e-w-full e-h-full",class:{"e-cursor-grab":e.isZoomed,"e-cursor-grabbing":e.isPanning},on:{mousewheel:e.handleZoom,mousedown:e.handleMouseDown,mouseup:e.handleMouseUp,mouseleave:e.handleMouseLeave,mousemove:e.handleMouseMove,pointerdown:e.handlePointerDown,pointermove:e.handlePointerMove,pointerup:e.handlePointerUp,pointercancel:e.handlePointerUp,pointerout:e.handlePointerUp,pointerleave:e.handlePointerUp}},[t("div",{ref:"content",staticClass:"e-w-full e-h-full e-transform-0 e-touch-none",style:e.contentStyle},[e._t("default")],2),e.withOverlay?t("div",{staticClass:"e-absolute e-w-full e-h-full e-bottom-0 e-left-0 e-overflow-hidden"},[e._t("overlay")],2):e._e()])])},rh=[],nh=ge(ih,sh,rh,!1,null,"3fb6736d",null,null);const xs=nh.exports,Bh="",ah={name:"EVideoPlayerOverlayAnimation",props:{isPlaying:{type:Boolean,default:!1}}};var oh=function(){var e=this,t=e._self._c;return t("div",{staticClass:"image-player-overlay d-flex align-center justify-center"},[t("div",{staticClass:"image-player-overlay__wrapper"},[e.isPlaying?t("svg",{attrs:{height:"100%",viewBox:"-1 0 36 36",width:"100%"}},[t("path",{attrs:{d:"M 12,26 18.5,22 18.5,14 12,10 z M 18.5,22 25,18 25,18 18.5,14 z"}})]):t("svg",{attrs:{height:"100%",viewBox:"0.5 0 36 36",width:"100%"}},[t("path",{attrs:{d:"M 12,26 16,26 16,10 12,10 z M 21,26 25,26 25,10 21,10 z"}})])])])},lh=[],ch=ge(ah,oh,lh,!1,null,null,null,null);const uh=ch.exports,Ts=new Intl.NumberFormat(void 0,{minimumIntegerDigits:2}),pa=["play","pause","ended","loadeddata","waiting","playing","timeupdate","canplay","canplaythrough","statechanged","error"],Es=s=>{const e=Math.floor(s%60),t=Math.floor(s/60)%60,i=Math.floor(s/3600);return i===0?`${t}:${Ts.format(e)}`:`${i}:${Ts.format(t)}:${Ts.format(e)}`},dh={name:"VideoPlayer",components:{ESpinner:pi,EVideoPlayerControls:th,EZoomable:xs,EVideoPlayerOverlayAnimation:uh},props:{targetTimestamp:{type:[String,Date],default:void 0},sources:{type:[Array,String],required:!0},videoListeners:{type:Object,default:()=>({})},videoOptions:{type:Object,default:()=>({})},isHls:{type:Boolean,default:!1},streamingToken:{type:String,default:""},isLiveView:{type:Boolean,default:!1},pauseOnClick:{type:Boolean,default:!0},isHlsLoading:{type:Boolean,default:!1},isPlaying:{type:Boolean,default:!1},preloadedInterval:{type:Object,default:()=>({})},selectedResolution:{type:[Number,void 0],default:void 0},isLive:{type:Boolean,default:!1},isZoomable:{type:Boolean,default:!1},zoomableIgnorePointerEvents:{type:Boolean,default:!1},blurBackground:{type:Boolean,default:!1},isRecordings:{type:Boolean,default:!1},progressBarEvents:{type:Array,default:()=>[]},progressBarFrames:{type:Array,default:()=>[]},progressBarFrameIndex:{type:Number,default:0},progressBarPreloadedFrames:{type:Array,default:()=>[]},thumbnailsUrls:{type:Array,default:()=>[]},timezone:{type:String,default:"UTC"},playPauseAnimation:{type:Boolean,default:!0},disablePlayPauseAnimation:{type:Boolean,default:!1},isWebRtc:{type:Boolean,default:!1}},data(){return{playing:!1,percentagePlayed:0,videoLength:"0:00",duration:0,videoDuration:0,currentTime:"0:00",realtime:0,isScrubbing:!1,wasPaused:!1,isFullscreen:!1,isFinished:!1,isLoading:!0,isError:!1,player:new be,playbackRetries:0}},computed:{sourceItems(){return Array.isArray(this.sources)?this.sources:[{src:this.sources}]},hasStartedOrFinished(){return(this.isFinished||this.realtime<=.1)&&!this.isLoading&&!this.isLooped()},withControls(){const s=this.videoOptions;return(s==null?void 0:s.controls)===!1?"hide":""}},watch:{selectedResolution(){if(!this.isHls)return;const s=this.sources[0];this.player.loadSource(s.src),this.isLoading=!0,this.isPlaying&&this.play()},isPlaying:{immediate:!0,handler(s){this.isHls&&(s?(this.isLiveView&&this.initHls(),this.$emit("hls-play")):this.$emit("hls-pause"))}},targetTimestamp:{immediate:!0,handler(s){var n,a;if(!this.isHls)return;const e=this.$refs.player,t=(n=this.preloadedInterval)==null?void 0:n.start,i=(a=this.preloadedInterval)==null?void 0:a.end;if(!(t&&i))return;const r=ve(s).isBetween(ve(t),ve(i),void 0,"[]");e.currentTime=0,r||this.initHls()}},isHlsLoading(s){s?setTimeout(()=>{this.isHlsLoading&&(this.isLoading=!0)},this.isPlaying?500:3e3):this.isLoading=!1}},mounted(){this.isHls&&this.initHls(),this.bindEvents(),this.initializePlayer(),this.initializeFullscreenListeners()},beforeDestroy(){this.unbindEvents(),this.destroyPlayer(),this.removeFullscreenListeners()},methods:{initHls(){var t,i,r,n,a;const s=this.$refs.player,e=this.sources[0];(t=this.player)!=null&&t.stopLoad&&this.player.stopLoad(),be.isSupported()&&(this.isLoading=!0,this.player=new be({startPosition:0,xhrSetup:o=>{this.streamingToken&&o.setRequestHeader("Authorization",`Bearer ${this.streamingToken}`)}}),(i=this.player)==null||i.loadSource(e.src),(r=this.player)==null||r.attachMedia(s),(n=this.player)==null||n.on(be.Events.MANIFEST_PARSED,()=>{this.playing&&s.play()}),(a=this.player)==null||a.on(be.Events.ERROR,this.handleHlsError))},onContainerClick(){this.pauseOnClick&&this.togglePlay()},handle404Error(){this.isWebRtc||(this.isError=!0,this.isLoading=!1,this.playing=!1)},handleHlsError(s,e){var a;if(!e.fatal)return;const t=e.type===be.ErrorTypes.NETWORK_ERROR,i=e.type===be.ErrorTypes.MEDIA_ERROR,r=t&&((a=e.networkDetails)==null?void 0:a.status)===404,n=()=>{this.player.destroy(),this.videoListeners.error?this.videoListeners.error():this.handle404Error()};if(r){n();return}if(t){console.error("A network error occurred:",e),this.player.startLoad();return}i&&(console.error("A media error occurred:",e),this.player.recoverMediaError()),n()},bindEvents(){const s=this.$refs.player;pa.forEach(e=>{if(this.isLive){const t=this.$refs.timelineContainer;this.percentagePlayed=1e4,t==null||t.style.setProperty("--progress-position",this.percentagePlayed.toString())}else s.addEventListener(e,()=>this.bindVideoEvent(e),!0)})},unbindEvents(){const s=this.$refs.player;pa.forEach(e=>{s.removeEventListener(e,()=>this.bindVideoEvent(e),!0)})},bindVideoEvent(s){const e=this.$refs.player;if(!e)return;const t=this.$refs.timelineContainer;s==="loadeddata"&&(this.videoLength=Es(e.duration)),t&&(s==="timeupdate"&&(this.percentagePlayed=(e==null?void 0:e.currentTime)/(e==null?void 0:e.duration)*100,t==null||t.style.setProperty("--progress-position",this.percentagePlayed.toString())),this.$emit(s,{event,player:e}))},initializePlayer(){const s=this.$refs.player;s&&(s.autoplay&&this.setPlaying(!0),document.addEventListener("mouseup",this.handleScrubbingOnMouseEnd),document.addEventListener("keydown",this.handleKeyDown))},destroyPlayer(){this.player&&(this.player.stopLoad(),this.player.destroy()),window.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("mouseup",this.handleScrubbingOnMouseEnd)},removeFullscreenListeners(){document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled?(document.removeEventListener("fullscreenchange",this.handleFullscreenChange),document.removeEventListener("webkitfullscreenchange",this.handleFullscreenChange),document.removeEventListener("mozfullscreenchange",this.handleFullscreenChange),document.removeEventListener("MSFullscreenChange",this.handleFullscreenChange)):console.log("Fullscreen API is not supported in this browser.")},initializeFullscreenListeners(){document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled?(document.addEventListener("fullscreenchange",this.handleFullscreenChange),document.addEventListener("webkitfullscreenchange",this.handleFullscreenChange),document.addEventListener("mozfullscreenchange",this.handleFullscreenChange),document.addEventListener("MSFullscreenChange",this.handleFullscreenChange)):console.log("Fullscreen API is not supported in this browser.")},handleFullscreenChange(){this.isFullscreen=document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement||window.innerWidth==screen.width&&window.innerHeight==screen.height},isLooped(){return this.$refs.player.loop},handleScrubbingOnMouseEnd(s){this.isScrubbing&&this.toggleScrubbing(s)},handleEnded(){this.isFinished=!0,this.playing=!1},handleLoading(){this.isLoading=!1},async play(){const s=this.$refs.player;if(s&&this.isHls)try{await s.play(),this.setPlaying(!0)}catch(e){console.error(e),this.playbackRetries+=1,this.initHls()}},pause(){const s=this.$refs.player;s&&(s.pause(),this.setPlaying(!1))},async togglePlay(){this.playing?this.pause():await this.play()},setPlaying(s){this.playing=s},seekToPercentage(s){const e=this.$refs.player;if(!e)return;const t=s/100*e.duration;e.currentTime=t},convertTimeToDuration(s){return[parseInt(s/60%60,10),parseInt(s%60,10)].join(":").replace(/\b(\d)\b/g,"0$1")},closeFullscreenMode(){document.fullscreenElement&&(ma().then(()=>{this.isFullscreen=!1,console.log("Exited fullscreen")}),this.isFullscreen=!1)},openFullscreenMode(){const s=this.$refs.videoContainer;s&&(fa(s).then(()=>{this.isFullscreen=!0}),this.isFullscreen=!0)},toggleFullscreenMode(){console.log("executed",{isFullscreen:this.isFullscreen}),this.isFullscreen?this.closeFullscreenMode():this.openFullscreenMode()},getDuration(){const s=this.$refs.player;this.videoLength=Es(s.duration),this.videoDuration=s.duration},handleTimeUpdate(){const s=this.$refs.player,e=this.$refs.timelineContainer;if(!s||!e)return;this.currentTime=Es(s.currentTime),this.realtime=s.currentTime;const t=Number(this.realtime)/Number(this.videoDuration);e.style.setProperty("--progress-position",t.toString())},handleTimelineUpdate(s){const e=this.$refs.player;if(!document.body.contains(e))return;const t=this.$refs.timelineContainer,i=t.getBoundingClientRect(),r=Math.min(Math.max(0,s.x-i.x),i.width)/i.width;t.style.setProperty("--preview-position",r.toString()),this.isScrubbing&&(s.preventDefault(),t.style.setProperty("--progress-position",r.toString()))},skip(s=5){const e=this.$refs.player;e.currentTime+=s},async toggleScrubbing(s){const e=this.$refs.timelineContainer,t=this.$refs.videoContainer,i=this.$refs.player;if(!i)return;const r=e.getBoundingClientRect(),n=Math.min(Math.max(0,s.x-r.x),r.width)/r.width;if(this.isScrubbing=(s.buttons&1)===1,t.classList.toggle("scrubbing",this.isScrubbing),this.isScrubbing){this.wasPaused=i.paused,await i.pause(),this.handleTimelineUpdate(s);return}if(this.realtime=n*this.videoDuration,i.currentTime=n*this.videoDuration,this.wasPaused)return;const a=i.play();a!==void 0&&a.then(()=>this.handleTimelineUpdate(s)).catch(console.error)},handleKeyDown(s){var t;const e=(t=document.activeElement)==null?void 0:t.tagName.toLowerCase();if(e!=="input")switch(s.key.toLowerCase()){case" ":if(e==="button")return;this.togglePlay();break;case"k":this.togglePlay();break;case"escape":s.preventDefault(),this.closeFullscreenMode(),this.isFullscreen=!1;break;case"f":this.openFullscreenMode(),this.isFullscreen=!0;break}}}},$h="";var hh=function(){var e=this,t=e._self._c;return t("div",{ref:"videoContainer",staticClass:"video-container paused",attrs:{"data-volume-level":"high"}},[e.isZoomable?t("EZoomable",{attrs:{"ignore-pointer-events":e.zoomableIgnorePointerEvents},on:{"apply-zoomable-style":function(i){return e.$emit("apply-zoomable-style",i)}},scopedSlots:e._u([{key:"overlay",fn:function(){return[e._t("zoomable-overlay")]},proxy:!0}],null,!0)},[t("div",{staticClass:"e-w-full e-h-full e-relative"},[e.blurBackground?t("img",{staticClass:"e-absolute e-block e-w-full e-scale-150 e-z-[-1] e-inset-0 e-m-auto e-blur-video-poster",attrs:{src:e.videoOptions.poster,alt:"background-image"},on:{error:function(i){return e.$emit("poster-error",i)}}}):e._e()]),t("video",e._g(e._b({ref:"player",staticClass:"e-w-full e-h-full e-absolute e-inset-0 e-z-50",attrs:{controls:!1,preload:"auto"},on:{ended:e.handleEnded,click:e.onContainerClick,loadedmetadata:e.getDuration,timeupdate:e.handleTimeUpdate,loadeddata:e.handleLoading}},"video",e.videoOptions,!1),e.videoListeners),[e.isWebRtc?e._e():e._l(e.sourceItems,function(i){return t("source",e._g({key:i.src,attrs:{src:i.src,type:i.type},on:{error:e.handle404Error}},e.videoListeners))})],2)]):t("video",e._g(e._b({ref:"player",staticClass:"e-w-full e-h-full",attrs:{controls:!1,preload:"auto"},on:{ended:e.handleEnded,click:e.onContainerClick,loadedmetadata:e.getDuration,timeupdate:e.handleTimeUpdate,loadeddata:e.handleLoading}},"video",e.videoOptions,!1),e.videoListeners),[e.isWebRtc?e._e():e._l(e.sourceItems,function(i){return t("source",e._g({key:i.src,attrs:{src:i.src,type:i.type},on:{error:e.handle404Error}},e.videoListeners))})],2),e.isLoading?t("div",{staticClass:"spinner-container"},[t("ESpinner",{attrs:{color:!e.isHls&&!e.isWebRtc,size:e.isHls||e.isWebRtc?"7xl":"9xl",opacity:"0.6",dark:!0}})],1):e._e(),e._t("default"),e.playPauseAnimation&&!e.disablePlayPauseAnimation?t("EVideoPlayerOverlayAnimation",{attrs:{"is-playing":e.isPlaying}}):e._e(),e.isError?t("div",{staticClass:"spinner-container e-gap-3"},[t("i",{staticClass:"fa-solid fa-video-slash fa-2xl e-align-middle"}),t("span",[e._v("This video file cannot be played.")])]):e._e(),e.isRecordings?t("EVideoPlayerControls",{attrs:{"is-playing":e.playing,"is-live":e.isLive,"current-time":e.currentTime,"video-length":e.videoLength,"is-fullscreen":e.isFullscreen,frames:e.progressBarFrames,events:e.progressBarEvents,"frame-index":e.progressBarFrameIndex,"preloaded-frames":e.progressBarPreloadedFrames,"thumbnails-urls":e.thumbnailsUrls,timezone:e.timezone},on:{"download-thumbnail":i=>e.$emit("download-thumbnail",i),"toggle-play-pause":e.togglePlay,"toggle-fullscreen":e.toggleFullscreenMode,"timeline-update":e.handleTimelineUpdate,"enable-live-view":function(i){return e.$emit("enable-live-view")},"toggle-video-mode":i=>e.$emit("toggle-video-mode",i),"frame-index-change":i=>e.$emit("frame-index-change",i)}}):t("div",{class:["video-controls-container",e.withControls]},[t("div",{staticClass:"controls"},[t("button",{ref:"playPauseBtn",staticClass:"play-pause-btn fa-lg fa-solid",class:{"fa-play":!e.playing,"fa-pause":e.playing},attrs:{title:e.playing?"pause":"play"},on:{click:e.togglePlay}}),t("div",{staticClass:"duration-container"},[t("div",{ref:"currentTimeElem",staticClass:"current-time"},[e._v(" "+e._s(e.currentTime)+" ")]),e._v(" / "),t("div",{ref:"totalTimeElem",staticClass:"total-time"},[e._v(e._s(e.videoLength))])]),t("div",{ref:"timelineContainer",staticClass:"timeline-container",on:{mousemove:e.handleTimelineUpdate,mousedown:e.toggleScrubbing}},[t("div",{staticClass:"timeline"},[t("div",{staticClass:"thumb-indicator"})])]),t("button",{ref:"fullScreenBtn",staticClass:"full-screen-btn fa-solid",class:{"fa-expand":!e.isFullscreen,"fa-compress":e.isFullscreen},on:{click:e.toggleFullscreenMode}})])])],2)},fh=[],mh=ge(dh,hh,fh,!1,null,"207d017d",null,null);const ya=mh.exports,ri=s=>{const e=I.utcFormat("%_d")(s),i={1:"st",2:"nd",3:"rd"}[e.charAt(1)]||"th";return`${e}${i}`},va=s=>new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate()+1)).getUTCDate()===1?"":I.utcFormat("%-d")(s),St=s=>["0"," 0","00"].includes(I.utcFormat("%H")(s))?"":`${I.utcFormat("%H")(s)}h`,je=s=>{const e=I.utcFormat("%H:%M")(s);return e==="00:00"?"":e},Ss=s=>I.utcFormat("%M:%S")(s),xa=s=>`${I.utcFormat("%Hh%Mm")(s)}`,bs=s=>{const e=je(s),t=ri(s),i=I.utcFormat("%B")(s);return e||`${i} ${t}`},As=s=>{const e=je(s),t=Number.parseInt(I.utcFormat("%H")(s)),i=ri(s),r=I.utcFormat("%B")(s);return e&&t%6===0?`${r} ${i} ${e}`:bs(s)},bt=s=>e=>{const t=I.utcFormat("%H")(e);return!(I.utcFormat("%M")(e)==="00"&&Number.parseInt(t)%s===0)},Ls=s=>e=>{const t=I.utcFormat("%M")(e);return Number.parseInt(t)%s!==0},Ta=s=>e=>{const t=I.utcFormat("%M")(e),i=I.utcFormat("%S")(e);return Number.parseInt(t)%s!==0&&Number.parseInt(i)===0},K={_10_seconds:25e-6,_20_seconds:1e-4,_30_seconds:15e-5,_1_minute:3e-4,_2_minutes:75e-5,_5_minutes:.002,_15_minutes:.005,_30_minutes:.01,_1_hour:.025,_2_hours:.05,_3_hours:.1,_4_hours:.15,_6_hours:.25,_1_day:1,_2_days:2,_1_month:8,_1_month_abbr:13,_1_month_letter:22,_3_months:33,_2_year:48,_5_years:120,_20_years:480,_75_years:1800,_300_years:7200,infinity:1/0},gh={[mt.overview]:[{precision:K._30_seconds,interval:I.utcMinute.every(2),format:xa},{precision:K._1_minute,interval:I.utcMinute.every(5),format:xa},{precision:K._2_minutes,interval:I.utcMinute.every(10),format:bs},{precision:K._5_minutes,interval:I.utcMinute.every(20),format:As},{precision:K._15_minutes,interval:I.utcHour,format:As},{precision:K._30_minutes,interval:I.utcHour.every(2),format:As},{precision:K._2_hours,interval:I.utcHour.every(6),format:s=>{const e=je(s),t=ri(s),i=I.utcFormat("%B")(s);return e||`${i} ${t}`}},{precision:K._3_hours,interval:I.utcHour.every(12),format:bs},{precision:K._6_hours,interval:I.utcHour.every(24),format:s=>{const e=ri(s);return`${I.utcFormat("%b")(s)} ${e}`}},{precision:K._2_days,interval:I.utcMonth,format:s=>{const t=s.getUTCMonth()===0&&s.getUTCDate()===1?"%Y – %B":"%B";return I.utcFormat(t)(s)}},{precision:K._2_year,interval:I.utcYear.every(2),format:"%Y"},{precision:K._5_years,interval:I.utcYear.every(5),format:"%Y"},{precision:K._20_years,interval:I.utcYear.every(20),format:"%Y"},{precision:K._75_years,interval:I.utcYear.every(75),format:"%Y"},{precision:K._300_years,interval:I.utcYear.every(300),format:"%Y"},{precision:K.infinity,interval:I.utcMonth.every(12),format:"%Y"}],[mt.detailed]:[{precision:K._10_seconds,interval:I.utcSecond.every(10),format:Ss},{precision:K._20_seconds,interval:(Aa=I.utcSecond.every(20))==null?void 0:Aa.filter(Ta(2)),format:Ss},{precision:K._30_seconds,interval:(La=I.utcSecond.every(30))==null?void 0:La.filter(Ta(2)),format:Ss},{precision:K._1_minute,interval:I.utcMinute.filter(Ls(5)),format:je},{precision:K._2_minutes,interval:(Ca=I.utcMinute.every(2))==null?void 0:Ca.filter(Ls(10)),format:je},{precision:K._5_minutes,interval:(_a=I.utcMinute.every(5))==null?void 0:_a.filter(Ls(20)),format:je},{precision:K._15_minutes,interval:(Ra=I.utcMinute.every(15))==null?void 0:Ra.filter(bt(1)),format:je},{precision:K._30_minutes,interval:(Da=I.utcMinute.every(30))==null?void 0:Da.filter(bt(2)),format:je},{precision:K._1_hour,interval:I.utcHour.filter(bt(6)),format:St},{precision:K._2_hours,interval:(Ia=I.utcHour.every(2))==null?void 0:Ia.filter(bt(6)),format:St},{precision:K._3_hours,interval:(wa=I.utcHour.every(3))==null?void 0:wa.filter(bt(12)),format:St},{precision:K._4_hours,interval:I.utcHour.every(4),format:St},{precision:K._6_hours,interval:I.utcHour.every(6),format:St},{precision:K._1_day,interval:I.utcDay,format:va},{precision:K._2_days,interval:I.utcDay.every(2),format:va},{precision:K._1_month,interval:I.utcMonth,format:"%B"},{precision:K._1_month_abbr,interval:I.utcMonth,format:"%b"},{precision:K._1_month_letter,interval:I.utcMonth,format:s=>I.utcFormat("%B")(s).charAt(0)},{precision:K._3_months,interval:I.utcMonth.every(3),format:"Q%q"},{precision:K._2_year,interval:I.utcMonth.every(6),format:"%Y"},{precision:K._5_years,interval:I.utcYear.every(2),format:"%Y"},{precision:K._20_years,interval:I.utcYear.every(4),format:"%Y"},{precision:K._75_years,interval:I.utcYear.every(25),format:"%Y"},{precision:K._300_years,interval:I.utcYear.every(100),format:"%Y"},{precision:K.infinity,interval:I.utcYear.every(500),format:""}],[mt.detailedBackground]:[{precision:K._10_seconds,interval:I.utcSecond,format:""},{precision:K._20_seconds,interval:I.utcSecond.every(5),format:""},{precision:K._30_seconds,interval:I.utcSecond.every(10),format:""},{precision:K._1_minute,interval:I.utcSecond.every(20),format:""},{precision:K._2_minutes,interval:I.utcSecond.every(30),format:""},{precision:K._5_minutes,interval:I.utcMinute,format:""},{precision:K._15_minutes,interval:I.utcMinute.every(3),format:""},{precision:K._30_minutes,interval:I.utcMinute.every(6),format:""},{precision:K._1_hour,interval:I.utcMinute.every(15),format:""},{precision:K._2_hours,interval:I.utcMinute.every(30),format:""},{precision:K._3_hours,interval:I.utcHour,format:""},{precision:K._4_hours,interval:I.utcHour,format:""},{precision:K._6_hours,interval:I.utcMinute.every(120),format:""},{precision:K._1_day,interval:I.utcHour.every(8),format:""},{precision:K._2_days,interval:I.utcHour.every(12),format:""},{precision:K._1_month,interval:I.utcDay.filter(s=>{const e=s.getUTCDate(),t=new Date(s.getUTCFullYear(),s.getUTCMonth()+1,0).getUTCDate(),i=Math.ceil(t/5);return e===i||e===2*i||e===3*i||e===4*i}),format:""},{precision:K._1_month_abbr,interval:I.utcDay.filter(s=>{const e=s.getUTCDate(),t=new Date(s.getUTCFullYear(),s.getUTCMonth()+1,0).getUTCDate(),i=Math.ceil(t/4);return e===i||e===2*i||e===3*i}),format:""},{precision:K._1_month_letter,interval:I.utcDay.filter(s=>{const e=s.getUTCDate(),t=new Date(s.getUTCFullYear(),s.getUTCMonth()+1,0).getUTCDate(),i=Math.ceil(t/2);return e===i}),format:""},{precision:K._3_months,interval:I.utcMonth,format:""},{precision:K._3_months,interval:I.utcMonth,format:""},{precision:K._2_year,interval:I.utcYear,format:""},{precision:K._5_years,interval:I.utcYear.every(2),format:""},{precision:K._20_years,interval:I.utcYear.every(5),format:""},{precision:K._75_years,interval:I.utcYear.every(20),format:""},{precision:K._300_years,interval:I.utcYear.every(100),format:""},{precision:K.infinity,interval:I.utcYear.every(500),format:""}]},ni={bind(s,e){const{value:t}=e;if(typeof t!="function"){console.error("Invalid callback function provided to v-resize-observer");return}const i=new ResizeObserver(r=>{r[0]&&t(r[0])});i.observe(s),s.__resizeObserver__=i},unbind(s){s.__resizeObserver__&&(s.__resizeObserver__.disconnect(),delete s.__resizeObserver__)}},Ea=[{name:"resize-observer",definition:ni}],qe={milestone:"e-tl-milestone",milestoneBullet:"e-tl-milestone--bullet",milestoneDot:"e-tl-milestone--dot",milestoneContent:"e-tl-milestone-content",milestoneLine:"e-tl-milestone-line",milestonesContainer:"e-tl-milestones",milestoneHovered:"e-tl-milestone--hovered",milestoneSelected:"e-tl-milestone--selected",milestoneLabel:"e-tl-milestone-label",milestoneDotContainer:"e-tl-milestone-dot-container",milestoneDotLine:"e-tl-milestone-dot-line",milestoneDotDot:"e-tl-milestone-dot-dot",milestoneDotHovered:"e-tl-milestone-dot--hovered"},ph=Ae.extend({name:"ETimeline",directives:{resizeObserver:ni},props:{milestone:{type:Object,required:!0},size:{type:Number,default:18},borderColor:{type:String,default:"#eee"},backgroundColor:{type:String,default:"#aaa"},borderWidth:{type:Number,default:2},transitionDuration:{type:Number,default:500},dot:{type:Boolean,default:!1},dotSize:{type:Number,default:8},lineWidth:{type:Number,default:2},lineHeight:{type:Number,default:28}},data(){return{milestoneClasses:qe,timeouts:[],isInitialRender:!0,isMouseOver:!1}},computed:{transitionStyles(){return this.isInitialRender?{}:{transition:`transform ${this.transitionDuration}ms, width ${this.transitionDuration}ms, height ${this.transitionDuration}ms, padding ${this.transitionDuration}ms, border-radius ${this.transitionDuration}ms`}},sizeStyles(){return this.dot?{}:{width:`${this.size}px`,height:`${this.size}px`}},positionStyles(){return this.dot&&this.isMouseOver?{transform:`translateY(calc(-100% - ${this.lineHeight}px))`}:{}},styles(){return{...this.sizeStyles,...this.positionStyles,backgroundColor:this.backgroundColor,borderColor:this.borderColor,borderWidth:`${this.borderWidth}px`,borderStyle:"solid",...this.transitionStyles}},contentStyles(){return this.transitionStyles},computedTransitionDuration(){return this.isInitialRender?0:this.transitionDuration},labelStyles(){return{transition:`opacity ${this.computedTransitionDuration}ms`}},dotContainerStyles(){return{top:this.isMouseOver?`calc(100% - ${this.borderWidth}px)`:`calc(50% + ${this.dotSize/2}px)`,height:`calc(${this.lineHeight}px + ${this.dotSize}px)`,left:`calc(50% - ${this.lineWidth}px / 2)`,transition:`${this.computedTransitionDuration}ms`}},lineStyles(){return{bottom:`${this.dotSize/2}px`,left:`calc(50% - ${this.lineWidth}px / 2)`,width:`${this.lineWidth}px`,height:this.isMouseOver?`${this.lineHeight}px`:"0",backgroundColor:this.borderColor,transition:`${this.computedTransitionDuration}ms`}},dotStyles(){return{top:`${this.lineHeight}px`,left:`calc(50% - ${this.dotSize}px / 2)`,width:`${this.dotSize}px`,height:`${this.dotSize}px`,backgroundColor:this.borderColor,transition:`${this.computedTransitionDuration}ms`}}},mounted(){this.$nextTick(()=>{this.dot||(this.onMilestoneMouseOver(),this.onMilestoneMouseLeave()),this.isInitialRender=!1})},methods:{onMilestoneMouseOver(s){if(this.isMouseOver=!0,this.dot)return;const e=(s==null?void 0:s.target)||this.$refs.container;if(!e)return;const t=e.children[0];if(!t)return;const i=t.children[0];if(!i)return;const r=i.getBoundingClientRect(),n=e.dataset.timeoutId;n&&(clearTimeout(Number(n)),e.dataset.timeoutId=""),e.dataset.initialWidth||(e.dataset.initialWidth=e.style.width),e.dataset.initialHeight||(e.dataset.initialHeight=e.style.height),e.dataset.initialContentWidth||(e.dataset.initialContentWidth=String(r.width)),e.dataset.initialContentHeight||(e.dataset.initialContentHeight=String(r.height)),e.dataset.transitionStart=String(Date.now()),e.style.width=e.dataset.initialContentWidth+"px",e.style.height=e.dataset.initialContentHeight+"px",e.style.borderRadius="0.5em",e.classList.add(qe.milestoneHovered),t.style.opacity="1",t.style.width=e.dataset.initialContentWidth+"px",t.style.height=e.dataset.initialContentHeight+"px"},onMilestoneMouseMove(){this.timeouts.forEach(s=>clearTimeout(s)),this.isMouseOver=!0},onMilestoneMouseLeave(s){if(this.dot){this.timeouts.push(setTimeout(()=>{this.isMouseOver=!1},this.transitionDuration+100));return}const e=(s==null?void 0:s.target)||this.$refs.container;if(!e)return;e.style.width=e.dataset.initialWidth||"",e.style.height=e.dataset.initialHeight||"",e.style.borderRadius="10em";const t=e.children[0];if(!t)return;t.style.width="0",t.style.height="0",t.style.opacity="0";const i=Date.now()-Number(e.dataset.transitionStart),r=i>this.transitionDuration?this.transitionDuration:i,n=setTimeout(()=>{e.classList.remove(qe.milestoneHovered),e.dataset.timeoutId=""},r);e.dataset.timeoutId=String(n),this.timeouts.push(n)},onMilestoneClick(s,e){this.$emit("milestone-click",e)}}}),Uh="";var yh=function(){var e=this,t=e._self._c;return t("div",{ref:"container",class:{[e.milestoneClasses.milestone]:!0,[e.milestoneClasses.milestoneBullet]:!e.dot,[e.milestoneClasses.milestoneHovered]:e.isMouseOver&&!e.dot,[e.milestoneClasses.milestoneDot]:e.dot,[e.milestoneClasses.milestoneDotHovered]:e.isMouseOver&&e.dot},style:e.styles,attrs:{tabindex:"0"},on:{mouseover:i=>e.onMilestoneMouseOver(i,e.milestone),mousemove:e.onMilestoneMouseMove,mouseleave:i=>e.onMilestoneMouseLeave(i,e.milestone),click:i=>e.onMilestoneClick(i,e.milestone)}},[t("div",{class:e.milestoneClasses.milestoneContent,style:e.contentStyles},[e._t("content",function(){return[t("span",[e._v(" "+e._s(e.milestone.text)+" ")])]})],2),e.dot?t("div",{class:e.milestoneClasses.milestoneDotContainer,style:e.dotContainerStyles},[t("div",{class:e.milestoneClasses.milestoneDotLine,style:e.lineStyles}),t("div",{class:e.milestoneClasses.milestoneDotDot,style:e.dotStyles})]):t("div",{class:e.milestoneClasses.milestoneLabel,style:e.labelStyles},[e._t("label")],2)])},vh=[],xh=ge(ph,yh,vh,!1,null,null,null,null);const Th=xh.exports,$={eventGroup:"event-group",eventGroupBg:"event-group-bg",eventRect:"event-rect",eventBarContainer:"event-bar-container",eventBarContainerHovered:"event-bar-container--hovered",eventBarContainerSelected:"event-bar-container--selected",eventBar:"event-bar",eventBarHoverZone:"event-bar-hover-zone",eventBarCap:"event-bar-cap",eventRectText:"event-rect-text",eventRectHovered:"event-rect--hovered",eventRectSelected:"event-rect--selected",labelGroup:"label-g",labelBg:"label-bg",labelBgFill:"label-bg-fill",labelText:"label-text",loadingIndicator:"loading-indicator",xAxis:"x-axis",selectedTimestampCursor:"selected-timestamp-cursor",marker:"marker",markerLabel:"marker-label",markerLine:"marker-line",markerDragged:"marker--dragged",milestone:"milestone",milestoneLine:"milestone-line",milestonesContainer:"milestones",milestoneHovered:"milestone--hovered",barChartGroup:"bar-chart-group",lineGraphGroup:"line-graph-group",lineGraphGroupLabel:"line-graph-group-label",lineGraphPath:"line-graph-path",lineGraphHoverZone:"line-graph-hover-zone",lineGraphDot:"line-graph-dot",curtain:"curtain",forbiddenInterval:"forbidden-interval"},Ge={transparencyGradient:"transparency-gradient",transparencyGradientLight:"transparency-gradient-light",loadingGradient:"loading-gradient",stripedPattern:"stripedPattern"},Eh=Ae.extend({name:"ETimeline",directives:{resizeObserver:ni},components:{ETimelineMilestone:Th},props:{eventsGroups:{type:Object,default:()=>({})},xAxesConfig:{type:Object,default:()=>gh},dark:{type:Boolean,default:!1},startDate:{type:String,default:void 0},endDate:{type:String,default:void 0},selectedTimestamp:{type:String,default:void 0},showEventTooltip:{type:Boolean,default:!0},disableZoom:{type:Boolean,default:!1},insertZerosAtInterval:{type:String,default:void 0},flattenLineGraphEnds:{type:Boolean,default:!0},curtains:{type:Boolean,default:!1},showLabels:{type:Boolean,default:!0},rectMinWidth:{type:Number,default:1},barHeight:{type:Number,default:18},barYPadding:{type:Number,default:0},barXPadding:{type:Number,default:0},chartMinHeight:{type:Number,default:60},minZoom:{type:Number,default:1e-4},maxZoom:{type:Number,default:85e4},minDate:{type:String,default:void 0},maxDate:{type:String,default:void 0},minVisibleDate:{type:String,default:void 0},maxVisibleDate:{type:String,default:void 0},cursorTimestamp:{type:[String,void 0],default:void 0},selectedClass:{type:[String,void 0],default:void 0},panOnDateClick:{type:Boolean,default:!1},panTransitionDuration:{type:Number,default:800},selectedDate:{type:String,default:""},autoResize:{type:Boolean,default:!0},markers:{type:Array,default:()=>[]},stickyMarkers:{type:Boolean,default:!0},fitMarkersOnChange:{type:Boolean,default:!1},fitMarkersTransitionDuration:{type:Number,default:800},zoomToBoundariesTransitionDuration:{type:Number,default:0},milestoneBulletSize:{type:Number,default:18},milestonesFirst:{type:Boolean,default:!0}},data(){return{tooltip:null,cursor:null,timeline:null,wrapperDiv:null,selectedTimestampCursor:null,svg:null,axesContainer:null,xAxes:{},timeScale:null,initialTimeScale:null,currentTimeScaleDensity:null,zoomBehavior:null,isMouseDown:!1,axisHeight:22,isHoveringEvent:!1,hoveredEvent:null,isHoveringTimeline:!1,hoveredTimestamp:null,eventTooltipStyle:{},hoveredEventType:null,utcOffset:0,lastTransform:{x:0,k:1},transformDiff:{translation:0,scale:1},yScale:null,hoveredCounts:[],countsByTimestamp:{},dotsByTimestamp:{},visibleFrom:null,visibleTo:null,curtainHandleWidth:5,leftCurtainWidth:50,rightCurtainWidth:50,isHoveringCurtain:!1,isDraggingCurtain:!1,characterWidth:7.5,textPadding:5,debouncedOnResize:()=>{},isFirstPaint:!0,timeouts:[],groupsVisibility:{},markersPositions:{},markersDragBehavior:null,initialMarkerDragMouseOffset:0,selectedMilestoneId:null,isInitialized:!1,lastValidTransform:I.zoomIdentity}},computed:{combinedBarsHeight(){return Object.values(this.barGroups).reduce((s,e)=>s+(e.height||this.barChartHeight),0)},combinedMilestonesHeight(){return Object.values(this.milestonesGroups).reduce((s,e)=>s+(e.height||this.barChartHeight),0)},milestonesYOffset(){return this.milestonesFirst?0:this.combinedBarsHeight+(this.hasChart?this.chartHeight:0)},chartsYOffset(){return this.hasMilestones&&this.milestonesFirst?this.combinedMilestonesHeight:0},barsYOffset(){return(this.hasChart?this.chartHeight:0)+(this.hasMilestones&&this.milestonesFirst?this.combinedMilestonesHeight:0)},hasMilestones(){return Object.keys(this.milestonesGroups).length>0},barChartHeight(){return this.barHeight+this.barYPadding},classes(){return{wrapper:{"e-border-gray-700 e-timeline--dark":this.dark,"e-border-gray-300":!this.dark,"e-timeline--dragging":this.isInteractingWithCurtain},background:this.dark?"e-bg-gray-900":"e-bg-gray-50",tooltipSlot:this.dark?"e-bg-gray-900 e-text-white e-border-gray-700":"e-bg-gray-100 e-text-gray-700 e-border-gray-300",eventTooltipSlot:this.dark?"e-bg-gray-900 e-text-white e-border-gray-700":"e-bg-gray-100 e-text-gray-700 e-border-gray-300"}},lineGraphGroups(){return Object.entries(this.filteredEventsGroups).reduce((s,[e,t])=>t.chartType===ke.lineGraph?{...s,[e]:t}:s,{})},chartHeight(){if(!this.showLabels)return this.chartMinHeight;const e=(Object.keys(this.lineGraphGroups).length+Object.keys(this.barChartGroups).length)*this.barChartHeight;return Math.max(this.chartMinHeight,e)},barGroups(){return Object.entries(this.filteredEventsGroups).reduce((s,[e,t])=>!t.chartType||[ke.bars,ke.dots].includes(t.chartType)?{...s,[e]:t}:s,{})},barChartGroups(){return Object.entries(this.filteredEventsGroups).reduce((s,[e,t])=>t.chartType===ke.barChart?{...s,[e]:t}:s,{})},milestonesGroups(){return Object.entries(this.filteredEventsGroups).reduce((s,[e,t])=>t.chartType===ke.milestones?{...s,[e]:t}:s,{})},hasChart(){return Object.keys(this.lineGraphGroups).length+Object.keys(this.barChartGroups).length>0},labelRectWidth(){return Object.values(this.eventsGroups).reduce((t,i)=>{var r;return Math.max(t,(r=i.label)==null?void 0:r.length)},0)*this.characterWidth+2*this.textPadding},combinedXAxesHeight(){const s=Object.keys(this.xAxesConfig).length-1;return this.axisHeight*s},timelineHeight(){const s=Object.values(this.milestonesGroups).reduce((r,n)=>r+(n.height||this.barChartHeight),0),e=Object.keys(this.barGroups).length,t=this.barChartHeight*e,i=this.hasChart?this.chartHeight:0;return this.combinedXAxesHeight+i+t+s},filteredEventsGroups(){const s=Object.entries(this.eventsGroups).filter(([e,t])=>this.getCurrentGroupVisibility(e));return Object.fromEntries(s)},allEventsSorted(){const s=Object.values(this.filteredEventsGroups).map(e=>e.events).flat();return this.getSortedEvents(s)},oldestEvent(){let s;return this.allEventsSorted.length>1?s=this.allEventsSorted[0]:s={timestamp:new Date(new Date().getTime()-864e5)},s},latestEvent(){let s;return this.allEventsSorted.length>1?s=this.allEventsSorted[this.allEventsSorted.length-1]:s={timestamp:new Date},s},allLineChartTimestamps(){const s=new Set;return Object.values(this.lineGraphGroups).forEach(e=>{e.events.forEach(t=>{s.add(t.timestamp)})}),Array.from(s).sort()},placeholderLineChartGroup(){return this.fillTimeGaps(this.allLineChartTimestamps.map(s=>({timestamp:s,count:0})))},filledGapsLineGraphGroups(){return Object.entries(this.lineGraphGroups).reduce((s,[e,t])=>({...s,[e]:{...t,events:this.fillEvents(t.events)}}),{})},isInteractingWithCurtain(){return this.isHoveringCurtain||this.isDraggingCurtain},flattenedCounts(){return[...Object.values(this.lineGraphGroups),...Object.values(this.barChartGroups)].map(s=>s.events).flat()},hiddenGroupsLabels(){return Object.entries(this.groupsVisibility).reduce((s,[e,t])=>t?s:[...s,e],[])},minHoverZone(){return this.showLabels?this.labelRectWidth:0},sortedMarkers(){return this.isInitialized?[...this.markers].sort((s,e)=>new Date(s.timestamp).getTime()>new Date(e.timestamp).getTime()?1:-1):[]}},watch:{dark(){this.handleDarkModeChange()},selectedTimestamp(){this.repositionSelectedTimestampCursor()},markers(){this.updateMarkers(),this.fitMarkersOnChange&&this.zoomToFitMarkers()},startDate(){this.zoomToStartAndEndDates()},minDate(){this.updateForbiddenIntervals()},maxDate(){this.updateForbiddenIntervals()},endDate(){this.zoomToStartAndEndDates()},eventsGroups(){this.updateAndRedrawTimeline()},cursorTimestamp(){if(this.cursorTimestamp){this.hoveredTimestamp=this.cursorTimestamp;const s=this.tzStringToDate(this.hoveredTimestamp),e=this.timeScale(s);this.cursor.style.left=e+"px",this.isHoveringTimeline=!0}else this.isHoveringTimeline=!1},selectedDate(s){s&&this.panToTimestamp(s)},groupsVisibility(){this.updateAndRedrawTimeline()}},created(){this.debouncedOnResize=ga(this.handleResize,100)},mounted(){this.initTimeline()},beforeDestroy(){this.clearTimeline(),document.removeEventListener("mouseup",this.handleDocumentMouseUp)},methods:{updateTimeline(){this.initOrUpdateSvg(),this.updateXAxes(),this.updateYScaleDomain(),this.updateForbiddenIntervals(),this.drawEventsGroups(),this.updateCurtains(),this.repositionSelectedTimestampCursor(),this.updateMarkers(),this.registerEventsListeners(),this.isInitialized=!0},initTimeline(s,e){if(this.initRefs(),!this.timeline||this.timeline.offsetWidth===0){this.timeouts.push(setTimeout(this.initTimeline,500));return}this.initOrUpdateSvg(),this.initDefs(),this.initUtcOffset(),this.initTimeScale(s,e),this.initXAxes(),this.initYScale(),this.initZoomBehavior(),this.initForbiddenIntervals(),this.drawEventsGroups(),this.curtains&&(this.initCurtains(),this.emitCurtainChange()),this.initSelectedTimestampCursor(),this.updateMarkers(),this.registerEventsListeners(),this.emitVisibleInterval(gt.initial),this.selectedDate&&this.panOnDateClick&&this.panToTimestamp(this.selectedDate),this.isInitialized=!0},initRefs(){this.tooltip=this.$refs.tooltip,this.cursor=this.$refs.cursor,this.timeline=this.$refs.timelineContainer,this.selectedTimestampCursor=this.$refs.selectedTimestamp,this.wrapperDiv=this.$refs.wrapperDiv},initOrUpdateSvg(){this.svg||(this.svg=I.select(this.timeline).append("svg")),this.svg.attr("width",this.timeline.offsetWidth).attr("height",this.timelineHeight)},initDefs(){const s=this.svg.append("defs");Object.entries(this.filteredEventsGroups).forEach(([t,i])=>{const{color:r,chartType:n}=i,a=s.append("linearGradient").attr("id",`${Ge.loadingGradient}-${t}`).attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");a.append("stop").attr("offset","0%").attr("stop-color",r).attr("stop-opacity","0"),a.append("stop").attr("offset","50%").attr("stop-color",r).attr("stop-opacity","0.6"),a.append("stop").attr("offset","100%").attr("stop-color",r).attr("stop-opacity","0"),[ke.lineGraph,ke.barChart].includes(n)&&[{id:Ge.transparencyGradientLight,stop:38,opacity:.3},{id:Ge.transparencyGradient,stop:130,opacity:.4}].forEach(({id:l,stop:c,opacity:u})=>{const d=s.append("linearGradient").attr("id",`${l}-${t}`).attr("x1","0%").attr("x2","0%").attr("y1","0%").attr("y2","100%");d.append("stop").attr("offset","0%").style("stop-color",r).style("stop-opacity",u),d.append("stop").attr("offset",`${c}%`).style("stop-color",r).style("stop-opacity",0)})}),s.append("pattern").attr("id",Ge.stripedPattern).attr("width",6).attr("height",4).attr("patternUnits","userSpaceOnUse").attr("patternTransform","rotate(45)").append("rect").attr("width",2).attr("height",6).attr("transform","translate(0,0)").attr("fill","#ddd")},initUtcOffset(){const s=this.startDate||this.oldestEvent.timestamp||this.oldestEvent.startDate;this.utcOffset=ve.parseZone(s).utcOffset()},initTimeScale(s,e){const t=s||this.startDate||this.oldestEvent.timestamp||this.oldestEvent.startDate,i=e||this.endDate||this.latestEvent.timestamp||this.latestEvent.endDate;this.timeScale=I.scaleTime().domain([this.tzStringToDate(t),this.tzStringToDate(i)]).range([0,this.timeline.offsetWidth]),this.initialTimeScale=this.timeScale.copy(),this.updateCurrentTimeScaleDensity()},initXAxes(){let s=0;const e=5;for(const t in this.xAxesConfig){const i=this.createAxis(t);this.xAxes[t]=i,this.svg.append("g").classed($.xAxis,!0).classed(`${$.xAxis}-${t}`,!0).attr("transform",`translate(0, ${s||e})`).call(i),this.translateTicksText(t),s+=this.axisHeight}this.updateXAxes()},updateXAxes(){let s=0;const e=5;for(const t in this.xAxesConfig){const i=this.xAxes[t];i.tickSizeOuter(0),i.tickSizeInner(this.timelineHeight),this.svg.select(`.${$.xAxis}-${t}`).attr("transform",`translate(0, ${s||e})`).call(i),this.translateTicksText(t),s+=this.axisHeight}},initYScale(){this.yScale=I.scaleLinear().range([this.chartHeight,0]),this.updateYScaleDomain()},updateYScaleDomain(){const[s,e]=this.timeScale.domain(),t=this.flattenedCounts.filter(r=>{const n=new Date(r.startDate||r.timestamp),a=new Date(r.endDate||r.timestamp);return a>=s&&a<=e||n>=s&&n<=e}),i=I.max(t,r=>r.count);this.yScale.domain([0,i])},initZoomBehavior(){this.disableZoom||(this.zoomBehavior=I.zoom().on("zoom",this.handleZoom).scaleExtent([this.minZoom,this.maxZoom]),this.svg.call(this.zoomBehavior),this.svg.call(this.zoomBehavior.transform,I.zoomIdentity))},zoomToFitMarkers(){const s=this.markers.map(u=>new Date(u.timestamp).getTime());if(s.length<2)return;const e=Math.min(...s),t=Math.max(...s),i=this.initialTimeScale.domain().map(u=>u.getTime()),r=i[1]-i[0],n=t-e,a=.1*n,o=n+2*a;let l=r/o;const c=this.zoomBehavior.scaleExtent();l=Math.min(Math.max(l,c[0]),c[1]),this.svg.transition().duration(this.fitMarkersTransitionDuration/2).call(this.zoomBehavior.scaleTo,l).on("end",()=>this.translateMarkersIntoView(e,t,l))},translateMarkersIntoView(s,e,t){const i=this.timeScale(new Date(s)),r=this.timeScale(new Date(e)),n=(i+r)/2,o=this.svg.node().getBoundingClientRect().width/2-n,l=I.zoomTransform(this.svg.node());this.svg.transition().duration(this.fitMarkersTransitionDuration/2).call(this.zoomBehavior.transform,I.zoomIdentity.translate(l.x+o,l.y).scale(t))},initSelectedTimestampCursor(){this.svg.append("line").attr("class",$.selectedTimestampCursor).style("stroke","red").style("stroke-width","1px").style("opacity",0).attr("x1",0).attr("x2",0).attr("y1",0),this.repositionSelectedTimestampCursor()},updateMarkers(){if(!this.markers.length)return;const s=12,e=200;this.sortedMarkers.forEach((t,i,r)=>{const n=typeof t.timestamp=="string"?this.tzStringToDate(t.timestamp):t.timestamp,a=this.timeScale(n);let o=!1;const l=this.stickyMarkers?Math.max(a,i*s):a;if(i<r.length-1){const c=r[i+1],u=typeof c.timestamp=="string"?this.tzStringToDate(c.timestamp):c.timestamp,d=this.timeScale(u);o=(this.stickyMarkers?Math.max(d,(i+1)*s):a)-l<e+s}this.markersPositions={...this.markersPositions,[t.id]:{isHidden:o,position:l}}}),this.initMarkersDragBehavior()},updateAndRedrawTimeline(){this.updateTimeline()},clearTimeline(){this.svg&&this.svg.remove(),this.countsByTimestamp={}},repositionSelectedTimestampCursor(){const s=this.svg.select(`.${$.selectedTimestampCursor}`);if(!this.selectedTimestamp){s.style("opacity",0);return}const e=this.tzStringToDate(this.selectedTimestamp),t=this.timeScale(e);isNaN(t)?s.style("opacity",0):s.attr("x1",t).attr("x2",t).style("opacity",.5),s.attr("y2",this.timelineHeight)},updateCurrentTimeScaleDensity(){const s=this.timeScale.invert(0).getTime(),e=this.timeScale.invert(1).getTime(),t=36e5,i=(e-s)/t;isNaN(i)||(this.currentTimeScaleDensity=i)},registerEventsListeners(){document.addEventListener("mouseup",this.handleDocumentMouseUp),this.svg.on("mousedown",this.handleMouseDown),this.svg.on("mousemove",this.handleMouseMove),this.svg.on("click",this.handleClick),this.svg.on("mouseleave",this.handleMouseLeave)},emitVisibleInterval(s){const e=this.timeScale.invert(0),t=this.timeScale.invert(this.timeline.offsetWidth);if(this.visibleFrom&&this.visibleFrom.getTime()===e.getTime()&&this.visibleTo&&this.visibleTo.getTime()===t.getTime())return;this.visibleFrom=e,this.visibleTo=t;const i=this.dateToTzString(this.visibleFrom),r=this.dateToTzString(this.visibleTo);this.$emit("visible-interval-change",{fromDate:i,toDate:r,trigger:s,transform:this.transformDiff})},createAxis(s){const e=this.xAxesConfig[s],t=this.getAxisTicksConfig(e);return I.axisBottom(this.timeScale).ticks(t.interval).tickFormat(t.formatFn).tickSizeOuter(0).tickSizeInner(this.timelineHeight)},getAxisTicksConfig(s){const{interval:e,format:t}=s.find(r=>r.precision>=this.currentTimeScaleDensity&&r.interval);return{formatFn:r=>typeof t=="function"?t(r):I.timeFormat(t)(r),interval:e}},onResize(s){this.isFirstPaint?(this.handleResize(s),this.isFirstPaint=!1):this.debouncedOnResize(s)},handleResize({contentRect:s}){this.svg&&(this.svg.attr("width",s.width),this.updateAndRedrawTimeline())},handleDarkModeChange(){if(!this.showLabels)return;const s=this;this.svg.selectAll(`.${$.labelBg}`).each(function(){I.select(this).style("fill",s.dark?"black":"white")}),this.svg.selectAll(`.${$.labelBgFill}`).each(function(){const e=I.select(this),t=e.node().dataset.color;e.style("fill",s.getLabelBackgroundColor(t)).style("stroke",s.getTextFillColor(t)).style("stroke-width",.25)}),this.svg.selectAll(`.${$.labelText}`).each(function(){const e=I.select(this),t=e.node().dataset.color;e.style("fill",s.getTextFillColor(t))})},handleMouseDown(){this.isMouseDown=!0},handleDocumentMouseUp(s){this.isMouseDown=!1},handleMouseLeave(){this.isHoveringTimeline=!1,this.$emit("hovered-timestamp",void 0)},handleMouseMove(s){if(this.isMouseDown)return;const e=s.offsetX;if(e<=this.minHoverZone){this.isHoveringTimeline=!1;return}const t=this.timeScale.invert(e);this.hoveredTimestamp=this.dateToTzString(t),this.isHoveringTimeline=!0,this.$emit("hovered-timestamp",this.hoveredTimestamp),this.cursor.style.left=e+"px",this.tooltip&&(this.eventTooltipStyle={left:`${e}px`,bottom:`${this.timeline.getBoundingClientRect().height}px`,zIndex:100})},handleClick(s){const e=s.offsetX;if(e<=this.minHoverZone)return;const t=this.timeScale.invert(e),i=this.dateToTzString(t);this.$emit("date-clicked",i),this.isHoveringEvent&&this.$emit("event-clicked",{event:this.hoveredEvent,type:this.hoveredEventType}),this.panOnDateClick&&this.panToTimestamp(i)},handleMarkerClick(s){this.$emit("marker-clicked",s),this.panOnDateClick&&this.panToTimestamp(s.timestamp)},handleLineMouseOver(s,e,t){this.hoveredCounts=Object.entries(this.countsByTimestamp[`${e.timestamp}`]).reduce((i,r)=>{const[n,a]=r;return[...i,{type:n,count:a}]},[]),this.hoveredEvent=e,this.isHoveringEvent=!0,this.$emit("event-mouseover",{eventData:e,eventType:t,hoveredCounts:this.hoveredCounts})},handleLineMouseOut(){this.isHoveringEvent=!1,this.hoveredCounts=[],this.$emit("event-mouseout")},handleBarMouseOver(s,e,t){s.offsetX<=this.minHoverZone||(this.hoveredEvent=e,this.hoveredEventType=t,this.isHoveringEvent=!0,this.$emit("event-mouseover",{eventData:e,eventType:t}))},handleBarMouseOut(){this.isHoveringEvent=!1,this.hoveredEvent=null,this.$emit("event-mouseout")},handleLabelMouseOver(s){I.selectAll(`.${$.lineGraphGroup}-${s}`).classed(`${$.lineGraphGroup}--highlighted`,!0),I.selectAll(`.${$.lineGraphGroupLabel}`).classed(`${$.lineGraphGroupLabel}--highlighted`,!0)},handleLabelMouseLeave(s){I.selectAll(`.${$.lineGraphGroup}-${s}`).classed(`${$.lineGraphGroup}--highlighted`,!1),I.selectAll(`.${$.lineGraphGroupLabel}`).classed(`${$.lineGraphGroupLabel}--highlighted`,!1)},isZoomAllowed(s){const e=this.initialTimeScale.copy(),t=s.transform.rescaleX(e).domain(),i=this.minVisibleDate?this.tzStringToDate(this.minVisibleDate):void 0,r=this.maxVisibleDate?this.tzStringToDate(this.maxVisibleDate):void 0;return(!i||t[0]>=i)&&(!r||t[1]<=r)},handleZoom(s){if(!this.isZoomAllowed(s)){s.sourceEvent.preventDefault(),this.svg.call(this.zoomBehavior.transform,this.lastValidTransform);return}this.lastValidTransform=s.transform;const e=s.transform.rescaleX(this.initialTimeScale);this.timeScale.domain(e.domain()),this.updateCurrentTimeScaleDensity(),this.updateYScaleDomain();const t=s.transform.k/this.lastTransform.k;this.transformDiff={scale:t,translation:s.transform.x-this.lastTransform.x},this.lastTransform={...s.transform};for(const i in this.xAxes)this.rescaleAxis(i,e),this.translateTicksText(i);this.updateEventsBars(),this.updateLineGraphs(),this.updateBarChart(),this.updateLineGraphHoverZones(),this.updateMilestonesPositions(),this.repositionSelectedTimestampCursor(),this.updateForbiddenIntervals(),this.updateMarkers(),this.emitVisibleInterval(gt.zoom),this.curtains&&this.emitCurtainChange()},panToTimestamp(s){const e=this.tzStringToDate(s),t=this.timeScale(e),i=I.zoomTransform(this.svg.node()),r=i.x-t+this.timeline.offsetWidth/2;this.svg.transition().duration(this.panTransitionDuration).call(this.zoomBehavior.transform,I.zoomIdentity.translate(r,0).scale(i.k)),this.emitVisibleInterval(gt.autoPan)},emitCurtainChange(){const{startDate:s,endDate:e}=this.calculateDateRangeFromCurtains();this.$emit("curtain-range-change",{startDate:new Date(s).toISOString(),endDate:new Date(e).toISOString()})},calculateDateRangeFromCurtains(){const s=this.timeline.offsetWidth,e=this.timeScale.domain(),t=e[1].getTime()-e[0].getTime(),i=(this.leftCurtainWidth-this.curtainHandleWidth*2)/s*t,r=(this.rightCurtainWidth+this.curtainHandleWidth*2)/s*t,n=new Date(e[0].getTime()+i),a=new Date(e[1].getTime()-r);return{startDate:n,endDate:a}},handleDragStart(){this.isDraggingCurtain=!0},handleDragEnd(){this.isDraggingCurtain=!1},handleLeftDrag(s){s.sourceEvent.stopPropagation();const e=Math.min(s.x,this.timeline.offsetWidth-this.rightCurtainWidth);this.leftCurtainWidth=Math.max(0,e),this.svg.select(`.${$.curtain}--left`).attr("width",this.leftCurtainWidth),this.emitCurtainChange()},handleRightDrag(s){s.sourceEvent.stopPropagation();const e=this.timeline.offsetWidth,t=Math.min(this.timeline.offsetWidth-s.x,this.timeline.offsetWidth-this.leftCurtainWidth),i=e-t;this.rightCurtainWidth=Math.max(0,t),this.svg.select(`.${$.curtain}--right`).attr("width",this.rightCurtainWidth).attr("x",i),this.emitCurtainChange()},zoomToStartAndEndDates(){const s=this.startDate||this.oldestEvent.timestamp||this.oldestEvent.startDate,e=this.endDate||this.latestEvent.timestamp||this.latestEvent.endDate,t=this.tzStringToDate(s),i=this.tzStringToDate(e);this.initialTimeScale.domain([t,i]);const r=I.zoomTransform(this.svg.node()),n=i.getTime()-t.getTime(),o=this.initialTimeScale.range().map(f=>this.initialTimeScale.invert(f)).reduce((f,m)=>m.getTime()-f,0)/n*r.k,c=-(this.initialTimeScale(t)*o),[u,d]=this.zoomBehavior.scaleExtent(),h=Math.max(u,Math.min(d,o));this.svg.transition().duration(this.zoomToBoundariesTransitionDuration).call(this.zoomBehavior.transform,I.zoomIdentity.translate(c,0).scale(h))},rescaleAxis(s,e){const t=this.xAxes[s],i=this.getAxisTicksConfig(this.xAxesConfig[s]);t.scale(e).ticks(i.interval).tickFormat(i.formatFn).tickSizeOuter(0),this.svg.select(`.${$.xAxis}-${s}`).call(t)},translateTicksText(s){this.svg.select(`.${$.xAxis}-${s}`).selectAll(".tick text").each(function(){let e=I.select(this),t=e.node().getBBox();e.attr("x",t.height/2).attr("y",0).style("text-anchor","start")})},updateEventsBars(){const s=`.${$.eventGroup} > rect.${$.eventRect}`,e=`${s}:not(.${$.eventRect}--dot)`;this.svg.selectAll(s).attr("x",this.getEventRectX),this.svg.selectAll(e).attr("width",this.getEventRectWidth);const t=`.${$.eventGroup} > text.${$.eventRectText}`;this.svg.selectAll(t).attr("x",i=>this.getEventRectX(i)+this.textPadding).text(this.getEventText)},updateBarChart(){const s=Object.keys(this.barChartGroups).length;Object.keys(this.barChartGroups).forEach((e,t)=>{const i=h=>(this.getEventRectWidth(h)-this.barXPadding*2)/s,r=h=>this.yScale.range()[0]-this.yScale(h.count),n=h=>this.getEventRectX(h)+this.barXPadding+t*i(h),a=h=>this.yScale(h.count),o=`.${$.eventBarContainer}-${e}`,l=this.svg.selectAll(o),c=`.${$.barChartGroup} rect.${$.eventBarHoverZone}`;l.selectAll(c).attr("x",n).attr("width",i);const u=`.${$.barChartGroup} rect.${$.eventBar}`;l.selectAll(u).attr("x",n).attr("width",i).attr("y",a).attr("height",r);const d=`.${$.barChartGroup} rect.${$.eventBarCap}`;l.selectAll(d).attr("x",n).attr("width",i).attr("y",a)})},updateLineGraphs(){Object.entries(this.lineGraphGroups).forEach(([s])=>{const e=I.area().x(t=>this.timeScale(this.tzStringToDate(t.timestamp))).y0(this.timelineHeight).y1(t=>this.yScale(t.count)).curve(I.curveMonotoneX);this.svg.selectAll(`.${$.lineGraphPath}-${s}`).attr("d",t=>e(t))})},updateLineGraphHoverZones(){Object.keys(this.lineGraphGroups).forEach(s=>{const e=this;this.svg.selectAll(`.${$.lineGraphDot}-${s}`).each(function(t){I.select(this).attr("cx",e.timeScale(e.tzStringToDate(t.timestamp))).attr("cy",e.yScale(t.count))}),this.svg.selectAll(`.${$.lineGraphHoverZone}-${s}`).each(function(t){const i=e.timeScale(e.tzStringToDate(t.timestamp).getTime())-15;I.select(this).attr("x",i).attr("y",0).attr("width",30).attr("height",e.chartHeight)})})},getEventRectX(s){return isNaN(this.timeScale(this.tzStringToDate(s.startDate||s.timestamp)))?0:this.timeScale(this.tzStringToDate(s.startDate||s.timestamp))},getEventRectWidth(s){if(!s)return 0;if(s.startDate&&s.endDate){const e=new Date(s.startDate),t=new Date(s.endDate),i=this.timeScale(t)-this.timeScale(e);return Math.max(i,this.rectMinWidth)}else{const e=1/(this.currentTimeScaleDensity*3600);return Math.max(e,this.rectMinWidth)}},getEventText(s){var i;const t=(this.getEventRectWidth(s)-this.textPadding)/this.characterWidth;return t<4?"":((i=s.text)==null?void 0:i.length)<=t?s.text:`${s.text.slice(0,t-3)}...`},getElementLeftPosition(s){if(!s)return 0;const e=window.getComputedStyle(s);return parseInt(e.left)},isTimestampAllowedForMarker(s,e){return(this.minDate?s>=this.tzStringToDate(this.minDate):!0)&&(this.maxDate?s<=this.tzStringToDate(this.maxDate):!0)&&(e.minDate?s>=this.tzStringToDate(e.minDate):!0)&&(e.maxDate?s<=this.tzStringToDate(e.maxDate):!0)},handleMarkerDrag({marker:s,markerElement:e,dragEvent:t}){if(!s.isDraggable)return;t.type==="start"&&(this.initialMarkerDragMouseOffset=t.x-e.node().querySelector(`.${$.markerLine}`).getBoundingClientRect().left,e.classed($.markerDragged,!0));const i=t.x-this.initialMarkerDragMouseOffset,r=this.timeScale.invert(i-this.svg.node().getBoundingClientRect().left),n=this.timeScale(r),a=this.isTimestampAllowedForMarker(r,s);if(t.type==="drag"&&a&&e.attr("style",`left: ${n}px`),t.type==="end"&&a){const o=s.id||s.timestamp;this.markersPositions={...this.markersPositions,[o]:{...this.markersPositions[o],position:n}},e.classed($.markerDragged,!1)}t.type!=="start"&&this.$emit(`marker-drag-${t.type}`,{marker:s,newTimestamp:r.toISOString()})},removeMarkersDragBehavior(){this.markersDragBehavior&&(this.markersDragBehavior.on("start",null).on("drag",null).on("end",null),I.selectAll(`.${$.marker}`).call(this.markersDragBehavior))},initMarkersDragBehavior(){this.removeMarkersDragBehavior();const s=this;this.markersDragBehavior=I.drag().on("start",function(e,t){var i;(i=e.sourceEvent)==null||i.preventDefault(),s.handleMarkerDrag({marker:t,markerElement:I.select(this),dragEvent:e})}).on("drag",function(e,t){s.handleMarkerDrag({marker:t,markerElement:I.select(this),dragEvent:e})}).on("end",function(e,t){s.handleMarkerDrag({marker:t,markerElement:I.select(this),dragEvent:e})}),I.selectAll(`.${$.marker}`).data(this.sortedMarkers).call(this.markersDragBehavior)},initCurtains(){this.createCurtains(),this.updateCurtains()},createCurtains(){this.curtains&&(this.svg.append("rect").classed(`${$.curtain} ${$.curtain}--left`,!0).attr("fill","rgba(0, 0, 0, 0.5)").on("mouseenter",()=>this.isHoveringCurtain=!0).on("mouseleave",()=>this.isHoveringCurtain=!1).call(I.drag().on("start",this.handleDragStart).on("drag",this.handleLeftDrag).on("end",this.handleDragEnd)),this.svg.append("rect").classed(`${$.curtain} ${$.curtain}--right`,!0).attr("fill","rgba(0, 0, 0, 0.5)").on("mouseenter",()=>this.isHoveringCurtain=!0).on("mouseleave",()=>this.isHoveringCurtain=!1).call(I.drag().on("start",this.handleDragStart).on("drag",this.handleRightDrag).on("end",this.handleDragEnd)),this.updateCurtains())},updateCurtains(){const s=this.timeline.offsetWidth,e=this.timelineHeight;this.svg.select(`.${$.curtain}--left`).attr("width",this.leftCurtainWidth).attr("height",e+this.curtainHandleWidth*2).attr("y",-this.curtainHandleWidth).attr("x",-this.curtainHandleWidth),this.svg.select(`.${$.curtain}--right`).attr("x",s-this.rightCurtainWidth+this.curtainHandleWidth).attr("y",-this.curtainHandleWidth).attr("width",this.rightCurtainWidth+this.curtainHandleWidth*2).attr("height",e+this.curtainHandleWidth*2)},initForbiddenIntervals(){this.minDate&&this.svg.append("rect").attr("class",`${$.forbiddenInterval} ${$.forbiddenInterval}--min`),this.maxDate&&this.svg.append("rect").attr("class",`${$.forbiddenInterval} ${$.forbiddenInterval}--max`),this.updateForbiddenIntervals()},updateForbiddenIntervals(){const s=this.minDate?this.tzStringToDate(this.minDate).getTime():null,e=this.maxDate?this.tzStringToDate(this.maxDate).getTime():null;if(s){const t=this.timeScale(s);this.svg.select(`.${$.forbiddenInterval}--min`).attr("x",0).attr("y",0).attr("width",t>0?t:0).attr("height",this.timelineHeight).attr("fill",`url(#${Ge.stripedPattern})`)}if(e){const t=this.timeline.offsetWidth-this.timeScale(e),i=this.timeScale(e);this.svg.select(`.${$.forbiddenInterval}--max`).attr("x",i>0?i:0).attr("y",0).attr("width",t>0?t:0).attr("height",this.timelineHeight).attr("fill",`url(#${Ge.stripedPattern})`)}},drawEventsGroups(){this.svg.selectAll(`g.${$.eventGroup}`).remove(),this.svg.selectAll(`.${$.barChartGroup}`).remove(),this.svg.selectAll(`.${$.lineGraphGroup}`).remove(),this.svg.selectAll(`.${$.lineGraphGroupLabel}`).remove(),this.svg.selectAll(`.${$.loadingIndicator}`).remove(),this.drawLineGraphEventsGroups(),this.drawBarEventsGroups(),this.drawBarChartEventsGroups(),this.drawMilestonesPlaceholder()},drawLineGraphEventsGroups(){const s=this.combinedXAxesHeight+this.chartsYOffset,e=this.insertZerosAtInterval?this.filledGapsLineGraphGroups:this.lineGraphGroups;Object.entries(e).forEach(([t,i])=>{const r=this.svg.append("g").classed(`${$.lineGraphGroup} ${$.lineGraphGroup}-${t}`,!0).attr("transform",`translate(0,${s})`),{color:n,events:a}=i;this.drawLineGraph({events:a,gElement:r,color:n,type:t}),this.drawLineGraphHoverZones({events:a,gElement:r,color:n,type:t})}),Object.entries(this.lineGraphGroups).forEach(([t,i],r)=>{const{color:n,isLoading:a,label:o}=i,l=this.chartHeight-this.barChartHeight*(r+1),c=s+this.chartHeight-this.barChartHeight,u=this.svg.append("g").classed($.lineGraphGroupLabel,!0).attr("transform",`translate(0,${s})`).on("mouseover",()=>this.handleLabelMouseOver(t)).on("mouseleave",()=>this.handleLabelMouseLeave(t));this.drawProgressIndicator({type:t,color:n,isLoading:a,yPosition:c}),this.drawTextLabel({color:n,label:o,type:t,yPosition:l,gElement:u})})},drawLineGraph({events:s,gElement:e,color:t,type:i}){const r=I.area().x(a=>this.timeScale(this.tzStringToDate(a.timestamp))).y0(this.timelineHeight).y1(a=>this.yScale(a.count)).curve(I.curveMonotoneX),n=`clip-${i}`;e.append("defs").append("clipPath").attr("id",n).append("rect").attr("width",this.timeline.offsetWidth).attr("height",this.chartHeight),e.append("path").datum(s).classed(`${$.lineGraphPath}-${i}`,!0).attr("fill",`url(#${Ge.transparencyGradientLight}-${i})`).attr("stroke",t).attr("stroke-linejoin","round").attr("stroke-linecap","round").attr("stroke-width",1).attr("d",a=>r(a)).attr("clip-path",`url(#${n})`)},drawLineGraphHoverZones({events:s,gElement:e,color:t,type:i}){s.forEach(r=>{const n=`${r.timestamp}`;this.countsByTimestamp[n]={...this.countsByTimestamp[n]||{},[i]:r.count};const a=e.append("circle").classed(`${$.lineGraphDot} ${$.lineGraphDot}-${i}`,!0).attr("cx",this.timeScale(this.tzStringToDate(r.timestamp))).attr("cy",this.yScale(r.count)).attr("r",1.5).attr("fill",t).attr("stroke-width",0).datum(r);this.dotsByTimestamp[n]=[...this.dotsByTimestamp[n]||[],a],e.append("rect").classed(`${$.lineGraphHoverZone}-${i}`,!0).attr("x",this.timeScale(this.tzStringToDate(r.timestamp))-15).attr("y",0).attr("width",30).attr("height",this.chartHeight).attr("fill","transparent").datum(r).on("mouseover",o=>{this.handleLineMouseOver(o,r,i),this.dotsByTimestamp[n].forEach(l=>l.classed(`${$.lineGraphDot}--active`,!0))}).on("mouseout",()=>{this.handleLineMouseOut(),this.dotsByTimestamp[n].forEach(o=>o.classed(`${$.lineGraphDot}--active`,!1))})})},drawSingleBarEventsGroup({type:s,eventsGroup:e,index:t=0,milestone:i,height:r,dots:n,dotsSize:a}){const{color:o,bgColor:l,label:c,events:u,isLoading:d}=e;let h=t*this.barChartHeight+this.combinedXAxesHeight+this.barsYOffset;i&&(h=this.getMilestoneGroupYPosition(s)),this.drawProgressIndicator({yPosition:h,type:s,color:o,isLoading:d});const f=this.svg.append("g").attr("data-color",o).classed($.eventGroup,!0).classed(`${$.eventGroup}-${s}`,!0);if(this.drawBackground({color:l||o,gElement:f,yPosition:h,height:r}),i||n){const m=n?.5:2,g=h+this.barChartHeight/2;f.append("line").classed(qe.milestoneLine,!0).attr("x1",0).attr("x2",this.timeline.offsetWidth).attr("y1",g).attr("y2",g).style("stroke",o).style("stroke-width",m)}this.drawBars({events:u,color:o,gElement:f,yPosition:h,type:s,dots:n,dotsSize:a}),c&&this.drawTextLabel({color:o,label:c,type:s,gElement:f,yPosition:h,height:r})},drawBarEventsGroups(){Object.entries(this.barGroups).forEach(([s,e],t)=>this.drawSingleBarEventsGroup({type:s,eventsGroup:e,index:t,dots:e.chartType===ke.dots,dotsSize:e.dotsSize||3}))},drawMilestonesPlaceholder(){Object.entries(this.milestonesGroups).forEach(([s,e])=>this.drawSingleBarEventsGroup({type:s,eventsGroup:{...e,events:[],isLoading:!1},milestone:!0,height:e.height})),this.updateMilestonesPositions()},getMilestoneClass(s){return{[qe.milestoneSelected]:[s.id,s.timestamp].includes(this.selectedMilestoneId)}},getMilestoneColors(s,e){return{background:s||e,border:this.getTextFillColor(s||e,.25)}},getMilestoneGroupYPosition(s){let e=0;for(const[t,i]of Object.entries(this.milestonesGroups)){if(t===s)break;e+=i.height||this.barChartHeight}return this.combinedXAxesHeight+this.milestonesYOffset+e},updateMilestonesPositions(){Object.entries(this.milestonesGroups).forEach(([s,e])=>{const t=this.getMilestoneGroupYPosition(s),i=this.svg.select(`g.${$.eventGroup}-${s}`),r=2,a=(e.height||this.barChartHeight)/2,o=t+a-r/2;i.attr("x1",0).attr("x2",this.timeline.offsetWidth).select(`.${qe.milestoneLine}`).attr("y1",o).attr("y2",o);const l=I.select(`.${qe.milestonesContainer}-${s}`);l.style("top",`${t}px`).style("height",`${e.height||this.barChartHeight}px`);const c=l.selectAll(`.${qe.milestone}`).data(this.getSortedEvents(e.events));c.exit().remove(),c.enter().append("div").merge(c).style("left",u=>`${this.timeScale(this.tzStringToDate(u.timestamp))}px`).style("top",`${o}px`)})},drawBarChartEventsGroups(){const s=this.combinedXAxesHeight,e=this.barChartGroups;Object.entries(e).forEach(([t,i],r)=>{const n=this.svg.append("g").classed(`${$.barChartGroup} ${$.barChartGroup}-${t}`,!0).attr("transform",`translate(0,${s})`),{color:a,events:o}=i;this.drawBarsChart({events:o,color:a,gElement:n,yOffset:s,type:t,index:r})})},drawProgressIndicator({yPosition:s,type:e,isLoading:t}){this.svg.append("rect").classed(`${$.loadingIndicator} ${$.loadingIndicator}-${e}`,!0).attr("x",0).attr("y",s).attr("width",this.timeline.offsetWidth/3).attr("height",this.barChartHeight).attr("fill",`url(#${Ge.loadingGradient}-${e})`).style("visibility",t?"visible":"hidden")},drawBackground({color:s,yPosition:e,gElement:t,height:i}){t.append("rect").attr("class",$.eventGroupBg).attr("x",0).attr("y",e).attr("width",this.timeline.offsetWidth).attr("height",i||this.barChartHeight).attr("fill",I.color(s).toString()).style("opacity",.1)},drawBars({events:s,gElement:e,yPosition:t,color:i,type:r,dots:n,dotsSize:a}){const o=this,l=t+this.barYPadding/2,c=n?(this.barChartHeight-a)/2:0;e.selectAll($.eventRect).data(s).enter().append("rect").attr("class",u=>$.eventRect+(n?` ${$.eventRect}--dot`:"")+(u.className?` ${u.className}`:"")).attr("x",this.getEventRectX).attr("y",l+c).attr("ry",n?a:1.5).attr("rx",n?a:1.5).attr("width",n?a:this.getEventRectWidth).attr("height",n?a:this.barChartHeight-this.barYPadding).attr("stroke-width",5).attr("cursor","pointer").attr("stroke","#0000").style("fill",u=>u.color||i).on("mouseover",function(u,d){I.select(this).classed($.eventRectHovered,!0),o.handleBarMouseOver(u,d,r)}).on("mouseout",function(){I.select(this).classed($.eventRectHovered,!1),o.handleBarMouseOut()}),e.selectAll($.eventRectText).data(s.filter(u=>!!u.text)).enter().append("text").attr("class",$.eventRectText).attr("x",u=>this.getEventRectX(u)+this.textPadding).attr("y",t+this.barChartHeight/2).attr("dy","0.35em").style("text-anchor","start").style("font-size","12px").style("font-weight",600).style("stroke-linejoin","round").style("paint-order","stroke").style("pointer-events","none").style("fill",u=>this.getTextFillColor(u.color||i,.75)).text(this.getEventText)},drawBarsChart({events:s,gElement:e,color:t,yOffset:i,type:r,index:n}){const a=this,o=Object.keys(this.barChartGroups).length,l=f=>(this.getEventRectWidth(f)-this.barXPadding*2)/o,c=f=>this.yScale.range()[0]-this.yScale(f.count),u=f=>this.getEventRectX(f)+this.barXPadding+n*l(f),d=f=>this.yScale(f.count),h=e.selectAll($.eventBarContainer).data(s).enter().append("g").attr("class",`${$.eventBarContainer} ${$.eventBarContainer}-${r}`);h.append("rect").attr("class",f=>$.eventBarHoverZone+(f.className?` ${f.className}`:"")).attr("x",u).attr("y",-i).attr("width",l).attr("height",this.yScale.range()[0]+i).attr("fill",f=>f.color||t).attr("fill-opacity",0),h.append("rect").attr("class",f=>$.eventBar+(f.className?` ${f.className}`:"")).attr("x",u).attr("y",d).attr("width",l).attr("height",c).attr("stroke-width",5).attr("cursor","pointer").attr("stroke","#0000").attr("fill",`url(#${Ge.transparencyGradient}-${r})`),h.append("rect").attr("class",f=>$.eventBarCap+(f.className?` ${f.className}`:"")).attr("x",u).attr("y",d).attr("width",l).attr("height",2).attr("stroke-width",0).style("fill",f=>f.color||t),h.on("mouseover",function(f,m){const g=I.select(this);a.onBarChartBarMouseOver(g,t),a.handleBarMouseOver(f,m,r)}).on("mouseout",function(){const f=I.select(this);a.onBarChartBarMouseOut(f,r),a.handleBarMouseOut()}).on("click",function(){e.selectAll(`.${$.eventBarContainerSelected}`).classed($.eventBarContainerSelected,!1),I.select(this).classed($.eventBarContainerSelected,!0)})},onBarChartBarMouseOver(s,e){s.classed($.eventBarContainerHovered,!0),s.selectAll(`.${$.eventBarHoverZone}`).attr("fill-opacity",.2);const i=s.selectAll(`.${$.eventBar}`);i.attr("fill",e),i.attr("fill-opacity",.5)},onBarChartBarMouseOut(s,e){s.classed($.eventBarContainerHovered,!1),s.selectAll(`.${$.eventBarHoverZone}`).attr("fill-opacity",0);const i=s.selectAll(`.${$.eventBar}`);i.attr("fill",`url(#${Ge.transparencyGradient}-${e})`),i.attr("fill-opacity",1)},drawTextLabel({gElement:s,yPosition:e,color:t,label:i,type:r,height:n}){if(!this.showLabels)return;const a={x:-5,y:e,w:this.labelRectWidth,h:n||this.barChartHeight,radius:3},o=s.append("g").attr("class",`${$.labelGroup} ${$.labelGroup}-${r}`).style("cursor","pointer").on("click",()=>this.toggleGroupVisibility(r));o.append("rect").attr("class",$.labelBg).attr("data-color",t).attr("x",a.x).attr("y",a.y).attr("width",a.w).attr("height",a.h).attr("rx",a.radius).attr("ry",a.radius).style("fill",this.dark?"#131a29":"white"),o.append("rect").attr("class",$.labelBgFill).attr("data-color",t).attr("x",a.x).attr("y",a.y).attr("width",a.w).attr("height",a.h).attr("rx",a.radius).attr("ry",a.radius).style("fill",this.getLabelBackgroundColor(t)).style("stroke",this.getTextFillColor(t)).style("stroke-width",.25),o.append("text").attr("class",$.labelText).attr("data-color",t).attr("x",5).attr("y",e+(n||this.barChartHeight)/2).attr("dy","0.35em").style("text-anchor","start").style("font-size","12px").style("font-weight",500).style("stroke-linejoin","round").style("paint-order","stroke").style("fill",this.getTextFillColor(t)).text(i)},getTextFillColor(s,e=0){var t,i;return(this.dark?(t=I.color(s))==null?void 0:t.brighter(1.5+e):(i=I.color(s))==null?void 0:i.darker(2+e)).toString()},getLabelBackgroundColor(s){let e=I.color(s);return e.opacity=this.dark?.2:.5,e.toString()},getCurrentGroupVisibility(s){var i;const e=this.groupsVisibility[s];if(e!==void 0)return e;const t=(i=this.eventsGroups[s])==null?void 0:i.isHidden;return t!==void 0?!t:!0},toggleGroupVisibility(s){this.groupsVisibility={...this.groupsVisibility,[s]:!this.getCurrentGroupVisibility(s)}},getExternalLabelStyles(s){const e=this.eventsGroups[s].color;return{background:this.getLabelBackgroundColor(e),color:this.getTextFillColor(e)}},getExternalLabelWrapperStyles(s){const e=this.eventsGroups[s].color;return{borderColor:this.getTextFillColor(e)}},getMarkerClass(s){var e;return{"marker--hidden":(e=this.markersPositions[s==null?void 0:s.id])==null?void 0:e.isHidden,"marker--draggable":s==null?void 0:s.isDraggable,...s.className?{[s==null?void 0:s.className]:!0}:{}}},getMarkerContainerStyle(s){var e;return{left:`${(e=this.markersPositions[s.id])==null?void 0:e.position}px`}},getMarkerLabelStyle(s){return{background:s.color,color:s.textColor||""}},getMarkerLineStyle(s){return{background:s.color,height:`${this.timelineHeight+24}px`}},tzStringToDate(s){return ve(s).add(this.utcOffset,"minutes").toDate()},dateToTzString(s){const e=new Date(s).getTimezoneOffset();return ve(s).add(e,"minutes").utcOffset(this.utcOffset,!0).format()},getCurrentTimeBounds(){const s=this.timeScale.domain();return{startDate:s[0],endDate:s[1]}},getFormattedTimestamp(s){return ve.parseZone(s).format("YYYY-MM-DDTHH:mm:ss")},fillTimeGaps(s){if(s.length<=1)return s;const e=this.insertZerosAtInterval,t=n=>n.clone().add(1,e),i=n=>n.clone().subtract(1,e);let r=[];for(let n=0;n<s.length;n++){const a=s[n];if(r.push(a),n===s.length-1)break;const o=s[n+1],l=ve(a.timestamp),c=ve(o.timestamp);if(c.diff(l,e)>1){const u=t(l).toISOString(),d=i(c).toISOString();r.push({timestamp:u,count:0}),u!==d&&r.push({timestamp:d,count:0})}}if(this.flattenLineGraphEnds){const n=ve(s[0].timestamp),a=ve(s[s.length-1].timestamp),o=i(n).toISOString(),l=t(a).toISOString();r=[{timestamp:o,count:0},...r,{timestamp:l,count:0}]}return r},fillEvents(s){return this.placeholderLineChartGroup.map(e=>s.find(i=>i.timestamp===e.timestamp)||e)},onMilestoneClick(s,e){this.panOnDateClick&&this.panToTimestamp(s.timestamp),this.selectedMilestoneId=s.id||s.timestamp,this.$emit("milestone-click",{milestone:s,milestoneType:e})},getSortedEvents(s){return[...s].sort((e,t)=>new Date(e.timestamp||e.startDate)>new Date(t.timestamp||t.startDate)?1:-1)}}}),Gh="";var Sh=function(){var e=this,t=e._self._c;return t("div",{ref:"wrapperDiv",staticClass:"e-relative e-timeline e-border e-rounded",class:e.classes.wrapper},[t("div",{staticClass:"e-timeline__background e-w-full e-h-full e-absolute e-top-0 e-rounded",class:e.classes.background}),e._l(e.sortedMarkers,function(i){return t("div",{key:i.id,staticClass:"marker e-absolute e-h-full e-top-0",class:e.getMarkerClass(i),style:e.getMarkerContainerStyle(i),attrs:{"data-id":i.id},on:{click:function(r){return e.handleMarkerClick(i)}}},[t("div",{staticClass:"marker-label e-absolute"},[t("div",{staticClass:"marker-label-text",style:e.getMarkerLabelStyle(i)},[e._t(`marker.${i.id}`,function(){return[e._v(" "+e._s(i.label)+" ")]},{marker:i})],2)]),t("div",{staticClass:"marker-line e-absolute e-pointer-events-none",style:e.getMarkerLineStyle(i)})])}),e.autoResize?t("div",{directives:[{name:"resize-observer",rawName:"v-resize-observer",value:e.onResize,expression:"onResize"}],ref:"timelineContainer",staticClass:"e-timeline__svg-container e-relative e-h-13 e-rounded e-select-none e-overflow-x-hidden"}):t("div",{ref:"timelineContainer",staticClass:"e-timeline__svg-container e-relative e-h-13 e-rounded e-select-none e-overflow-x-hidden"}),e._l(e.milestonesGroups,function(i,r){return t("div",{key:`${r}`,staticClass:"e-timeline-milestones"},[t("div",{class:`e-tl-milestones e-tl-milestones-${r}`},e._l(e.getSortedEvents(i.events),function(n,a){return t("ETimelineMilestone",{key:`${n.milestoneType}-${a}`,class:e.getMilestoneClass(n),attrs:{"data-timestamp":n.timestamp,milestone:n,dot:i.dots,size:n.size||e.milestoneBulletSize,"transition-duration":i.milestonesTransitionDuration,"line-height":i.milestonesLineHeight,"dot-size":i.milestonesDotSize,"background-color":e.getMilestoneColors(n.color,i.color).background,"border-color":e.getMilestoneColors(n.color,i.color).border},on:{"milestone-click":function(o){return e.onMilestoneClick(n,r)}},scopedSlots:e._u([{key:"content",fn:function(){return[e._t(`milestoneContent.${n.milestoneType}`,function(){return[t("span",{staticClass:"e-px-2"},[e._v(" "+e._s(n.text)+" ")])]},{milestone:n,index:a})]},proxy:!0},{key:"label",fn:function(){return[e._t(`milestoneLabel.${n.milestoneType}`,null,{milestone:n})]},proxy:!0}],null,!0)})}),1)])}),t("div",{directives:[{name:"show",rawName:"v-show",value:e.isHoveringTimeline&&!e.isInteractingWithCurtain,expression:"isHoveringTimeline && !isInteractingWithCurtain"}],ref:"cursor",staticClass:"e-timeline__cursor e-absolute e-bg-green-600 e-w-px e-h-full e-top-0 e-pointer-events-none"}),t("div",{staticClass:"external-labels-container e-flex"},e._l(e.hiddenGroupsLabels,function(i){return t("div",{key:i,staticClass:"external-label",class:e.classes.background,style:e.getExternalLabelWrapperStyles(i),on:{click:function(r){return e.toggleGroupVisibility(i)}}},[t("div",{staticClass:"external-label__content",style:e.getExternalLabelStyles(i)},[e._v(" "+e._s(i)+" ")])])}),0),t("div",{key:"tooltip",ref:"tooltip",staticClass:"e-absolute",style:e.eventTooltipStyle},[e._t("tooltip",function(){return[t("div",{directives:[{name:"show",rawName:"v-show",value:e.isHoveringTimeline&&!e.isHoveringEvent&&!e.isInteractingWithCurtain&&!e.cursorTimestamp,expression:`
|
|
27
27
|
isHoveringTimeline &&
|
|
28
28
|
!isHoveringEvent &&
|
|
29
29
|
!isInteractingWithCurtain &&
|