@visio-io/design-system 1.10.91 → 1.10.92
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.cjs.js +1 -1
- package/dist/index.es.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -145,7 +145,7 @@ Schedule: ${c.map(g=>rs(g))} pos: ${this.timelinePos}`),d.length&&this.log(`Remo
|
|
|
145
145
|
`).split(`
|
|
146
146
|
`),u=[],d=e?tK(e.baseTime,e.timescale):0;let f="00:00.000",h=0,p=0,m,g=!0;a.oncue=function(y){const v=n[r];let C=n.ccOffset;const S=(h-d)/9e4;if(v!=null&&v.new&&(p!==void 0?C=n.ccOffset=v.start:KY(n,r,S)),S){if(!e){m=new Error("Missing initPTS for VTT MPEGTS");return}C=S-n.presentationOffset}const w=y.endTime-y.startTime,T=fo((y.startTime+C-p)*9e4,o*9e4)/9e4;y.startTime=Math.max(T,0),y.endTime=Math.max(T+w,0);const I=y.text.trim();y.text=decodeURIComponent(encodeURIComponent(I)),y.id||(y.id=Nv(y.startTime,y.endTime,I)),y.endTime>0&&u.push(y)},a.onparsingerror=function(y){m=y},a.onflush=function(){if(m){i(m);return}s(u)},c.forEach(y=>{if(g)if(I0(y,"X-TIMESTAMP-MAP=")){g=!1,y.slice(16).split(",").forEach(v=>{I0(v,"LOCAL:")?f=v.slice(6):I0(v,"MPEGTS:")&&(h=parseInt(v.slice(7)))});try{p=qY(f)/1e3}catch(v){m=v}return}else y===""&&(g=!1);a.parse(y+`
|
|
147
147
|
`)}),a.flush()}const k0="stpp.ttml.im1t",JM=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,eA=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,XY={left:"start",center:"center",right:"end",start:"start",end:"end"};function $E(t,e,n,r){const o=jt(new Uint8Array(t),["mdat"]);if(o.length===0){r(new Error("Could not parse IMSC1 mdat"));return}const s=o.map(a=>Eo(a)),i=eK(e.baseTime,1,e.timescale);try{s.forEach(a=>n(ZY(a,i)))}catch(a){r(a)}}function ZY(t,e){const o=new DOMParser().parseFromString(t,"text/xml").getElementsByTagName("tt")[0];if(!o)throw new Error("Invalid ttml");const s={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},i=Object.keys(s).reduce((f,h)=>(f[h]=o.getAttribute(`ttp:${h}`)||s[h],f),{}),a=o.getAttribute("xml:space")!=="preserve",c=jE(P0(o,"styling","style")),u=jE(P0(o,"layout","region")),d=P0(o,"body","[begin]");return[].map.call(d,f=>{const h=tA(f,a);if(!h||!f.hasAttribute("begin"))return null;const p=M0(f.getAttribute("begin"),i),m=M0(f.getAttribute("dur"),i);let g=M0(f.getAttribute("end"),i);if(p===null)throw VE(f);if(g===null){if(m===null)throw VE(f);g=p+m}const y=new Fv(p-e,g-e,h);y.id=Nv(y.startTime,y.endTime,y.text);const v=u[f.getAttribute("region")],C=c[f.getAttribute("style")],S=QY(v,C,c),{textAlign:w}=S;if(w){const T=XY[w];T&&(y.lineAlign=T),y.align=w}return yn(y,S),y}).filter(f=>f!==null)}function P0(t,e,n){const r=t.getElementsByTagName(e)[0];return r?[].slice.call(r.querySelectorAll(n)):[]}function jE(t){return t.reduce((e,n)=>{const r=n.getAttribute("xml:id");return r&&(e[r]=n),e},{})}function tA(t,e){return[].slice.call(t.childNodes).reduce((n,r,o)=>{var s;return r.nodeName==="br"&&o?n+`
|
|
148
|
-
`:(s=r.childNodes)!=null&&s.length?tA(r,e):e?n+r.textContent.trim().replace(/\s+/g," "):n+r.textContent},"")}function QY(t,e,n){const r="http://www.w3.org/ns/ttml#styling";let o=null;const s=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],i=t!=null&&t.hasAttribute("style")?t.getAttribute("style"):null;return i&&n.hasOwnProperty(i)&&(o=n[i]),s.reduce((a,c)=>{const u=D0(e,r,c)||D0(t,r,c)||D0(o,r,c);return u&&(a[c]=u),a},{})}function D0(t,e,n){return t&&t.hasAttributeNS(e,n)?t.getAttributeNS(e,n):null}function VE(t){return new Error(`Could not parse ttml timestamp ${t}`)}function M0(t,e){if(!t)return null;let n=XM(t);return n===null&&(JM.test(t)?n=JY(t,e):eA.test(t)&&(n=eX(t,e))),n}function JY(t,e){const n=JM.exec(t),r=(n[4]|0)+(n[5]|0)/e.subFrameRate;return(n[1]|0)*3600+(n[2]|0)*60+(n[3]|0)+r/e.frameRate}function eX(t,e){const n=eA.exec(t),r=Number(n[1]);switch(n[2]){case"h":return r*3600;case"m":return r*60;case"ms":return r*1e3;case"f":return r/e.frameRate;case"t":return r/e.tickRate}return r}class ph{constructor(e,n){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=n}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,n,r){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=n,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}class tX{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=UE(),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(W.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(W.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(W.MANIFEST_LOADING,this.onManifestLoading,this),e.on(W.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(W.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(W.FRAG_LOADING,this.onFragLoading,this),e.on(W.FRAG_LOADED,this.onFragLoaded,this),e.on(W.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(W.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(W.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(W.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(W.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(W.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(W.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(W.MANIFEST_LOADING,this.onManifestLoading,this),e.off(W.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(W.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(W.FRAG_LOADING,this.onFragLoading,this),e.off(W.FRAG_LOADED,this.onFragLoaded,this),e.off(W.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(W.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(W.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(W.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(W.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new ph(this,"textTrack1"),n=new ph(this,"textTrack2"),r=new ph(this,"textTrack3"),o=new ph(this,"textTrack4");this.cea608Parser1=new BE(1,e,n),this.cea608Parser2=new BE(3,r,o)}addCues(e,n,r,o,s){let i=!1;for(let a=s.length;a--;){const c=s[a],u=nX(c[0],c[1],n,r);if(u>=0&&(c[0]=Math.min(c[0],n),c[1]=Math.max(c[1],r),i=!0,u/(r-n)>.5))return}if(i||s.push([n,r]),this.config.renderTextTracksNatively){const a=this.captionsTracks[e];this.Cues.newCue(a,n,r,o)}else{const a=this.Cues.newCue(null,n,r,o);this.hls.trigger(W.CUES_PARSED,{type:"captions",cues:a,track:e})}}onInitPtsFound(e,{frag:n,id:r,initPTS:o,timescale:s,trackId:i}){const{unparsedVttFrags:a}=this;r===lt.MAIN&&(this.initPTS[n.cc]={baseTime:o,timescale:s,trackId:i}),a.length&&(this.unparsedVttFrags=[],a.forEach(c=>{this.initPTS[c.frag.cc]?this.onFragLoaded(W.FRAG_LOADED,c):this.hls.trigger(W.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:c.frag,error:new Error("Subtitle discontinuity domain does not match main")})}))}getExistingTrack(e,n){const{media:r}=this;if(r)for(let o=0;o<r.textTracks.length;o++){const s=r.textTracks[o];if(HE(s,{name:e,lang:n,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return s}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:n,captionsTracks:r,media:o}=this,{label:s,languageCode:i}=n[e],a=this.getExistingTrack(s,i);if(a)r[e]=a,wc(r[e]),zM(r[e],o);else{const c=this.createTextTrack("captions",s,i);c&&(c[e]=!0,r[e]=c)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const n=this.captionsProperties[e];if(!n)return;const r=n.label,o={_id:e,label:r,kind:"captions",default:n.media?!!n.media.default:!1,closedCaptions:n.media};this.nonNativeCaptionsTracks[e]=o,this.hls.trigger(W.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[o]})}createTextTrack(e,n,r){const o=this.media;if(o)return o.addTextTrack(e,n,r)}onMediaAttaching(e,n){this.media=n.media,n.mediaSource||this._cleanTracks()}onMediaDetaching(e,n){const r=!!n.transferMedia;if(this.media=null,r)return;const{captionsTracks:o}=this;Object.keys(o).forEach(s=>{wc(o[s]),delete o[s]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=UE(),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 n=e.textTracks;if(n)for(let r=0;r<n.length;r++)wc(n[r])}onSubtitleTracksUpdated(e,n){const r=n.subtitleTracks||[],o=r.some(s=>s.textCodec===k0);if(this.config.enableWebVTT||o&&this.config.enableIMSC1){if(RM(this.tracks,r)){this.tracks=r;return}if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){const i=this.media,a=i?qh(i.textTracks):null;if(this.tracks.forEach((c,u)=>{let d;if(a){let f=null;for(let h=0;h<a.length;h++)if(a[h]&&HE(a[h],c)){f=a[h],a[h]=null;break}f&&(d=f)}if(d)wc(d);else{const f=nA(c);d=this.createTextTrack(f,c.name,c.lang),d&&(d.mode="disabled")}d&&this.textTracks.push(d)}),a!=null&&a.length){const c=a.filter(u=>u!==null).map(u=>u.label);c.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${c.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const i=this.tracks.map(a=>({label:a.name,kind:a.type.toLowerCase(),default:a.default,subtitleTrack:a}));this.hls.trigger(W.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:i})}}}onManifestLoaded(e,n){this.config.enableCEA708Captions&&n.captions&&n.captions.forEach(r=>{const o=/(?:CC|SERVICE)([1-4])/.exec(r.instreamId);if(!o)return;const s=`textTrack${o[1]}`,i=this.captionsProperties[s];i&&(i.label=r.name,r.lang&&(i.languageCode=r.lang),i.media=r)})}closedCaptionsForLevel(e){const n=this.hls.levels[e.level];return n==null?void 0:n.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,n){if(this.enabled&&n.frag.type===lt.MAIN){var r,o;const{cea608Parser1:s,cea608Parser2:i,lastSn:a}=this,{cc:c,sn:u}=n.frag,d=(r=(o=n.part)==null?void 0:o.index)!=null?r:-1;s&&i&&(u!==a+1||u===a&&d!==this.lastPartIndex+1||c!==this.lastCc)&&(s.reset(),i.reset()),this.lastCc=c,this.lastSn=u,this.lastPartIndex=d}}onFragLoaded(e,n){const{frag:r,payload:o}=n;if(r.type===lt.SUBTITLE)if(o.byteLength){const s=r.decryptdata,i="stats"in n;if(s==null||!s.encrypted||i){const a=this.tracks[r.level],c=this.vttCCs;c[r.cc]||(c[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),a&&a.textCodec===k0?this._parseIMSC1(r,o):this._parseVTTs(n)}}else this.hls.trigger(W.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,n){const r=this.hls;$E(n,this.initPTS[e.cc],o=>{this._appendCues(o,e.level),r.trigger(W.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},o=>{r.logger.log(`Failed to parse IMSC1: ${o}`),r.trigger(W.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:o})})}_parseVTTs(e){var n;const{frag:r,payload:o}=e,{initPTS:s,unparsedVttFrags:i}=this,a=s.length-1;if(!s[r.cc]&&a===-1){i.push(e);return}const c=this.hls,u=(n=r.initSegment)!=null&&n.data?Ko(r.initSegment.data,new Uint8Array(o)).buffer:o;YY(u,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,d=>{this._appendCues(d,r.level),c.trigger(W.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},d=>{const f=d.message==="Missing initPTS for VTT MPEGTS";f?i.push(e):this._fallbackToIMSC1(r,o),c.logger.log(`Failed to parse VTT cue: ${d}`),!(f&&a>r.cc)&&c.trigger(W.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:d})})}_fallbackToIMSC1(e,n){const r=this.tracks[e.level];r.textCodec||$E(n,this.initPTS[e.cc],()=>{r.textCodec=k0,this._parseIMSC1(e,n)},()=>{r.textCodec="wvtt"})}_appendCues(e,n){const r=this.hls;if(this.config.renderTextTracksNatively){const o=this.textTracks[n];if(!o||o.mode==="disabled")return;e.forEach(s=>WM(o,s))}else{const o=this.tracks[n];if(!o)return;const s=o.default?"default":"subtitles"+n;r.trigger(W.CUES_PARSED,{type:"subtitles",cues:e,track:s})}}onFragDecrypted(e,n){const{frag:r}=n;r.type===lt.SUBTITLE&&this.onFragLoaded(W.FRAG_LOADED,n)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,n){if(!this.enabled||!this.config.enableCEA708Captions)return;const{frag:r,samples:o}=n;if(!(r.type===lt.MAIN&&this.closedCaptionsForLevel(r)==="NONE"))for(let s=0;s<o.length;s++){const i=o[s].bytes;if(i){this.cea608Parser1||this.initCea608Parsers();const a=this.extractCea608Data(i);this.cea608Parser1.addData(o[s].pts,a[0]),this.cea608Parser2.addData(o[s].pts,a[1])}}}onBufferFlushing(e,{startOffset:n,endOffset:r,endOffsetSubtitles:o,type:s}){const{media:i}=this;if(!(!i||i.currentTime<r)){if(!s||s==="video"){const{captionsTracks:a}=this;Object.keys(a).forEach(c=>Cy(a[c],n,r))}if(this.config.renderTextTracksNatively&&n===0&&o!==void 0){const{textTracks:a}=this;Object.keys(a).forEach(c=>Cy(a[c],n,o))}}}extractCea608Data(e){const n=[[],[]],r=e[0]&31;let o=2;for(let s=0;s<r;s++){const i=e[o++],a=127&e[o++],c=127&e[o++];if(a===0&&c===0)continue;if((4&i)!==0){const d=3&i;(d===0||d===1)&&(n[d].push(a),n[d].push(c))}}return n}}function nA(t){return t.characteristics&&/transcribes-spoken-dialog/gi.test(t.characteristics)&&/describes-music-and-sound/gi.test(t.characteristics)?"captions":"subtitles"}function HE(t,e){return!!t&&t.kind===nA(e)&&yy(e,t)}function nX(t,e,n,r){return Math.min(e,r)-Math.max(t,n)}function UE(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}const rX=/\s/,oX={newCue(t,e,n,r){const o=[];let s,i,a,c,u;const d=self.VTTCue||self.TextTrackCue;for(let h=0;h<r.rows.length;h++)if(s=r.rows[h],a=!0,c=0,u="",!s.isEmpty()){var f;for(let g=0;g<s.chars.length;g++)rX.test(s.chars[g].uchar)&&a?c++:(u+=s.chars[g].uchar,a=!1);s.cueStartTime=e,e===n&&(n+=1e-4),c>=16?c--:c++;const p=QM(u.trim()),m=Nv(e,n,p);t!=null&&(f=t.cues)!=null&&f.getCueById(m)||(i=new d(e,n,p),i.id=m,i.line=h+1,i.align="left",i.position=10+Math.min(80,Math.floor(c*8/32)*10),o.push(i))}return t&&o.length&&(o.sort((h,p)=>h.line==="auto"||p.line==="auto"?0:h.line>8&&p.line>8?p.line-h.line:h.line-p.line),o.forEach(h=>WM(t,h))),o}};function sX(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const iX=/(\d+)-(\d+)\/(\d+)/;class GE{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||uX,this.controller=new self.AbortController,this.stats=new mv}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,n,r){const o=this.stats;if(o.loading.start)throw new Error("Loader can only be used once.");o.loading.start=self.performance.now();const s=aX(e,this.controller.signal),i=e.responseType==="arraybuffer",a=i?"byteLength":"length",{maxTimeToFirstByteMs:c,maxLoadTimeMs:u}=n.loadPolicy;this.context=e,this.config=n,this.callbacks=r,this.request=this.fetchSetup(e,s),self.clearTimeout(this.requestTimeout),n.timeout=c&&rt(c)?c:u,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(o,e,this.response))},n.timeout),(jd(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(f=>{var h;this.response=this.loader=f;const p=Math.max(self.performance.now(),o.loading.start);if(self.clearTimeout(this.requestTimeout),n.timeout=u,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(o,e,this.response))},u-(p-o.loading.start)),!f.ok){const{status:g,statusText:y}=f;throw new dX(y||"fetch, bad network response",g,f)}o.loading.first=p,o.total=cX(f.headers)||o.total;const m=(h=this.callbacks)==null?void 0:h.onProgress;return m&&rt(n.highWaterMark)?this.loadProgressively(f,o,e,n.highWaterMark,m):i?f.arrayBuffer():e.responseType==="json"?f.json():f.text()}).then(f=>{var h,p;const m=this.response;if(!m)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),o.loading.end=Math.max(self.performance.now(),o.loading.first);const g=f[a];g&&(o.loaded=o.total=g);const y={url:m.url,data:f,code:m.status},v=(h=this.callbacks)==null?void 0:h.onProgress;v&&!rt(n.highWaterMark)&&v(o,e,f,m),(p=this.callbacks)==null||p.onSuccess(y,o,e,m)}).catch(f=>{var h;if(self.clearTimeout(this.requestTimeout),o.aborted)return;const p=f&&f.code||0,m=f?f.message:null;(h=this.callbacks)==null||h.onError({code:p,text:m},e,f?f.details:null,o)})}getCacheAge(){let e=null;if(this.response){const n=this.response.headers.get("age");e=n?parseFloat(n):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,n,r,o=0,s){const i=new fM,a=e.body.getReader(),c=()=>a.read().then(u=>{if(u.done)return i.dataLength&&s(n,r,i.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));const d=u.value,f=d.length;return n.loaded+=f,f<o||i.dataLength?(i.push(d),i.dataLength>=o&&s(n,r,i.flush().buffer,e)):s(n,r,d.buffer,e),c()}).catch(()=>Promise.reject());return c()}}function aX(t,e){const n={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(yn({},t.headers))};return t.rangeEnd&&n.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1)),n}function lX(t){const e=iX.exec(t);if(e)return parseInt(e[2])-parseInt(e[1])+1}function cX(t){const e=t.get("Content-Range");if(e){const r=lX(e);if(rt(r))return r}const n=t.get("Content-Length");if(n)return parseInt(n)}function uX(t,e){return new self.Request(t.url,e)}class dX extends Error{constructor(e,n,r){super(e),this.code=void 0,this.details=void 0,this.code=n,this.details=r}}const fX=/^age:\s*[\d.]+\s*$/im;class rA{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 mv,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=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,n,r){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=n,this.callbacks=r,this.loadInternal()}loadInternal(){const{config:e,context:n}=this;if(!e||!n)return;const r=this.loader=new self.XMLHttpRequest,o=this.stats;o.loading.first=0,o.loaded=0,o.aborted=!1;const s=this.xhrSetup;s?Promise.resolve().then(()=>{if(!(this.loader!==r||this.stats.aborted))return s(r,n.url)}).catch(i=>{if(!(this.loader!==r||this.stats.aborted))return r.open("GET",n.url,!0),s(r,n.url)}).then(()=>{this.loader!==r||this.stats.aborted||this.openAndSendXhr(r,n,e)}).catch(i=>{var a;(a=this.callbacks)==null||a.onError({code:r.status,text:i.message},n,r,o)}):this.openAndSendXhr(r,n,e)}openAndSendXhr(e,n,r){e.readyState||e.open("GET",n.url,!0);const o=n.headers,{maxTimeToFirstByteMs:s,maxLoadTimeMs:i}=r.loadPolicy;if(o)for(const a in o)e.setRequestHeader(a,o[a]);n.rangeEnd&&e.setRequestHeader("Range","bytes="+n.rangeStart+"-"+(n.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=n.responseType,self.clearTimeout(this.requestTimeout),r.timeout=s&&rt(s)?s:i,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()}readystatechange(){const{context:e,loader:n,stats:r}=this;if(!e||!n)return;const o=n.readyState,s=this.config;if(!r.aborted&&o>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),s.timeout!==s.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),s.timeout=s.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),o===4)){self.clearTimeout(this.requestTimeout),n.onreadystatechange=null,n.onprogress=null;const u=n.status,d=n.responseType==="text"?n.responseText:null;if(u>=200&&u<300){const m=d??n.response;if(m!=null){var i,a;r.loading.end=Math.max(self.performance.now(),r.loading.first);const g=n.responseType==="arraybuffer"?m.byteLength:m.length;r.loaded=r.total=g,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first);const y=(i=this.callbacks)==null?void 0:i.onProgress;y&&y(r,e,m,n);const v={url:n.responseURL,data:m,code:u};(a=this.callbacks)==null||a.onSuccess(v,r,e,n);return}}const f=s.loadPolicy.errorRetry,h=r.retry,p={url:e.url,data:void 0,code:u};if(wp(f,h,!1,p))this.retry(f);else{var c;dn.error(`${u} while loading ${e.url}`),(c=this.callbacks)==null||c.onError({code:u,text:n.statusText},e,n,r)}}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry,n=this.stats.retry;if(wp(e,n,!0))this.retry(e);else{var r;dn.warn(`timeout while loading ${(r=this.context)==null?void 0:r.url}`);const o=this.callbacks;o&&(this.abortInternal(),o.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:n,stats:r}=this;this.retryDelay=vv(e,r.retry),r.retry++,dn.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${n==null?void 0:n.url}, retrying ${r.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 n=this.stats;n.loaded=e.loaded,e.lengthComputable&&(n.total=e.total)}getCacheAge(){let e=null;if(this.loader&&fX.test(this.loader.getAllResponseHeaders())){const n=this.loader.getResponseHeader("age");e=n?parseFloat(n):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}const hX={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},pX=un(un({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:!1,maxBufferSize:60*1e3*1e3,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,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,ignorePlaylistParsingErrors:!1,loader:rA,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:IW,bufferController:gK,capLevelController:Lv,errorController:AW,fpsController:yY,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:tM,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,preserveManualLevelOnError:!1,certLoadPolicy:{default:hX},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}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,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},mX()),{},{subtitleStreamController:DY,subtitleTrackController:xY,timelineController:tX,audioStreamController:fK,audioTrackController:hK,emeController:_c,cmcdController:hY,contentSteeringController:mY,interstitialsController:PY});function mX(){return{cueHandler:oX,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 gX(t,e,n){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 r=wy(t),o=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return o.forEach(i=>{const a=`${i==="level"?"playlist":i}LoadPolicy`,c=e[a]===void 0,u=[];s.forEach(d=>{const f=`${i}Loading${d}`,h=e[f];if(h!==void 0&&c){u.push(f);const p=r[a].default;switch(e[a]={default:p},d){case"TimeOut":p.maxLoadTimeMs=h,p.maxTimeToFirstByteMs=h;break;case"MaxRetry":p.errorRetry.maxNumRetry=h,p.timeoutRetry.maxNumRetry=h;break;case"RetryDelay":p.errorRetry.retryDelayMs=h,p.timeoutRetry.retryDelayMs=h;break;case"MaxRetryTimeout":p.errorRetry.maxRetryDelayMs=h,p.timeoutRetry.maxRetryDelayMs=h;break}}}),u.length&&n.warn(`hls.js config: "${u.join('", "')}" setting(s) are deprecated, use "${a}": ${Cn(e[a])}`)}),un(un({},r),e)}function wy(t){return t&&typeof t=="object"?Array.isArray(t)?t.map(wy):Object.keys(t).reduce((e,n)=>(e[n]=wy(t[n]),e),{}):t}function yX(t,e){const n=t.loader;n!==GE&&n!==rA?(e.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):sX()&&(t.loader=GE,t.progressive=!0,t.enableSoftwareAES=!0,e.log("[config]: Progressive streaming enabled, using FetchLoader"))}const Kh=2,bX=.1,vX=.05,xX=100;class CX extends XD{constructor(e,n){super("gap-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0},this.onMediaWaiting=()=>{var r;(r=this.media)!=null&&r.seeking||(this.waiting=self.performance.now(),this.tick())},this.onMediaEnded=()=>{if(this.hls){var r;this.ended=((r=this.media)==null?void 0:r.currentTime)||1,this.hls.trigger(W.MEDIA_ENDED,{stalled:!1})}},this.hls=e,this.fragmentTracker=n,this.registerListeners()}registerListeners(){const{hls:e}=this;e&&(e.on(W.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(W.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(W.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(W.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(W.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(W.BUFFER_APPENDED,this.onBufferAppended,this))}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}onMediaAttached(e,n){this.setInterval(xX),this.mediaSource=n.mediaSource;const r=this.media=n.media;qr(r,"playing",this.onMediaPlaying),qr(r,"waiting",this.onMediaWaiting),qr(r,"ended",this.onMediaEnded)}onMediaDetaching(e,n){this.clearInterval();const{media:r}=this;r&&(to(r,"playing",this.onMediaPlaying),to(r,"waiting",this.onMediaWaiting),to(r,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}onBufferAppended(e,n){this.buffered=n.timeRanges}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var e;if(!((e=this.media)!=null&&e.readyState)||!this.hasBuffered)return;const n=this.media.currentTime;this.poll(n,this.lastCurrentTime),this.lastCurrentTime=n}poll(e,n){var r,o;const s=(r=this.hls)==null?void 0:r.config;if(!s)return;const i=this.media;if(!i)return;const{seeking:a}=i,c=this.seeking&&!a,u=!this.seeking&&a,d=i.paused&&!a||i.ended||i.playbackRate===0;if(this.seeking=a,e!==n){n&&(this.ended=0),this.moved=!0,a||(this.nudgeRetry=0,s.nudgeOnVideoHole&&!d&&e>n&&this.nudgeOnVideoHole(e,n)),this.waiting===0&&this.stallResolved(e);return}if(u||c){c&&this.stallResolved(e);return}if(d){this.nudgeRetry=0,this.stallResolved(e),!this.ended&&i.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(W.MEDIA_ENDED,{stalled:!1}));return}if(!Dt.getBuffered(i).length){this.nudgeRetry=0;return}const f=Dt.bufferInfo(i,e,0),h=f.nextStart||0,p=this.fragmentTracker;if(a&&p&&this.hls){const I=zE(this.hls.inFlightFragments,e),P=f.len>Kh,M=!h||I||h-e>Kh&&!p.getPartialFragment(e);if(P||M)return;this.moved=!1}const m=(o=this.hls)==null?void 0:o.latestLevelDetails;if(!this.moved&&this.stalled!==null&&p){if(!(f.len>0)&&!h)return;const P=Math.max(h,f.start||0)-e,D=!!(m!=null&&m.live)?m.targetduration*2:Kh,k=mh(e,p);if(P>0&&(P<=D||k)){i.paused||this._trySkipBufferHole(k);return}}const g=s.detectStallWithCurrentTimeMs,y=self.performance.now(),v=this.waiting;let C=this.stalled;if(C===null)if(v>0&&y-v<g)C=this.stalled=v;else{this.stalled=y;return}const S=y-C;if(!a&&(S>=g||v)&&this.hls){var w;if(((w=this.mediaSource)==null?void 0:w.readyState)==="ended"&&!(m!=null&&m.live)&&Math.abs(e-((m==null?void 0:m.edge)||0))<1){if(this.ended)return;this.ended=e||1,this.hls.trigger(W.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(f),!this.media||!this.hls)return}const T=Dt.bufferInfo(i,e,s.maxBufferHole);this._tryFixBufferStall(T,S,e)}stallResolved(e){const n=this.stalled;if(n&&this.hls&&(this.stalled=null,this.stallReported)){const r=self.performance.now()-n;this.log(`playback not stuck anymore @${e}, after ${Math.round(r)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(W.STALL_RESOLVED,{})}}nudgeOnVideoHole(e,n){var r;const o=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(r=this.buffered.audio)!=null&&r.length&&o&&o.length>1&&e>o.end(0)){const s=Dt.bufferedInfo(Dt.timeRangesToArray(this.buffered.audio),e,0);if(s.len>1&&n>=s.start){const i=Dt.timeRangesToArray(o),a=Dt.bufferedInfo(i,n,0).bufferedIndex;if(a>-1&&a<i.length-1){const c=Dt.bufferedInfo(i,e,0).bufferedIndex,u=i[a].end,d=i[a+1].start;if((c===-1||c>a)&&d-u<1&&e-u<2){const f=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${u} -> ${d} buffered index: ${c}`);this.warn(f.message),this.media.currentTime+=1e-6;let h=mh(e,this.fragmentTracker);h&&"fragment"in h?h=h.fragment:h||(h=void 0);const p=Dt.bufferInfo(this.media,e,0);this.hls.trigger(W.ERROR,{type:pt.MEDIA_ERROR,details:ve.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:f,reason:f.message,frag:h,buffer:p.len,bufferInfo:p})}}}}}_tryFixBufferStall(e,n,r){var o,s;const{fragmentTracker:i,media:a}=this,c=(o=this.hls)==null?void 0:o.config;if(!a||!i||!c)return;const u=(s=this.hls)==null?void 0:s.latestLevelDetails,d=mh(r,i);if((d||u!=null&&u.live&&r<u.fragmentStart)&&(this._trySkipBufferHole(d)||!this.media))return;const f=e.buffered,h=this.adjacentTraversal(e,r);(f&&f.length>1&&e.len>c.maxBufferHole||e.nextStart&&(e.nextStart-r<c.maxBufferHole||h))&&(n>c.highBufferWatchdogPeriod*1e3||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}adjacentTraversal(e,n){const r=this.fragmentTracker,o=e.nextStart;if(r&&o){const s=r.getFragAtPos(n,lt.MAIN),i=r.getFragAtPos(o,lt.MAIN);if(s&&i)return i.sn-s.sn<2}return!1}_reportStall(e){const{hls:n,media:r,stallReported:o,stalled:s}=this;if(!o&&s!==null&&r&&n){this.stallReported=!0;const i=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${Cn(e)})`);this.warn(i.message),n.trigger(W.ERROR,{type:pt.MEDIA_ERROR,details:ve.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len,bufferInfo:e,stalled:{start:s}})}}_trySkipBufferHole(e){var n;const{fragmentTracker:r,media:o}=this,s=(n=this.hls)==null?void 0:n.config;if(!o||!r||!s)return 0;const i=o.currentTime,a=Dt.bufferInfo(o,i,0),c=i<a.start?a.start:a.nextStart;if(c&&this.hls){const d=a.len<=s.maxBufferHole,f=a.len>0&&a.len<1&&o.readyState<3,h=c-i;if(h>0&&(d||f)){if(h>s.maxBufferHole){let m=!1;if(i===0){const g=r.getAppendedFrag(0,lt.MAIN);g&&c<g.end&&(m=!0)}if(!m&&e){var u;if(!((u=this.hls.loadLevelObj)!=null&&u.details)||zE(this.hls.inFlightFragments,c))return 0;let y=!1,v=e.end;for(;v<c;){const C=mh(v,r);if(C)v+=C.duration;else{y=!0;break}}if(y)return 0}}const p=Math.max(c+vX,i+bX);if(this.warn(`skipping hole, adjusting currentTime from ${i} to ${p}`),this.moved=!0,o.currentTime=p,!(e!=null&&e.gap)){const m=new Error(`fragment loaded with buffer holes, seeking from ${i} to ${p}`),g={type:pt.MEDIA_ERROR,details:ve.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:m,reason:m.message,buffer:a.len,bufferInfo:a};e&&("fragment"in e?g.part=e:g.frag=e),this.hls.trigger(W.ERROR,g)}return p}}return 0}_tryNudgeBuffer(e){const{hls:n,media:r,nudgeRetry:o}=this,s=n==null?void 0:n.config;if(!r||!s)return 0;const i=r.currentTime;if(this.nudgeRetry++,o<s.nudgeMaxRetry){const a=i+(o+1)*s.nudgeOffset,c=new Error(`Nudging 'currentTime' from ${i} to ${a}`);this.warn(c.message),r.currentTime=a,n.trigger(W.ERROR,{type:pt.MEDIA_ERROR,details:ve.BUFFER_NUDGE_ON_STALL,error:c,fatal:!1,buffer:e.len,bufferInfo:e})}else{const a=new Error(`Playhead still not moving while enough data buffered @${i} after ${s.nudgeMaxRetry} nudges`);this.error(a.message),n.trigger(W.ERROR,{type:pt.MEDIA_ERROR,details:ve.BUFFER_STALLED_ERROR,error:a,fatal:!0,buffer:e.len,bufferInfo:e})}}}function zE(t,e){const n=WE(t.main);if(n&&n.start<=e)return n;const r=WE(t.audio);return r&&r.start<=e?r:null}function WE(t){if(!t)return null;switch(t.state){case Le.IDLE:case Le.STOPPED:case Le.ENDED:case Le.ERROR:return null}return t.frag}function mh(t,e){return e.getAppendedFrag(t,lt.MAIN)||e.getPartialFragment(t)}const SX=.25;function Ty(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function A0(t,e,n,r,o){let s=new t(e,n,"");try{s.value=r,o&&(s.type=o)}catch{s=new t(e,n,Cn(o?un({type:o},r):r))}return s}const gh=(()=>{const t=Ty();try{t&&new t(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class wX{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(W.EVENT_CUE_ENTER,{})},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}_registerListeners(){const{hls:e}=this;e&&(e.on(W.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(W.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(W.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(W.MANIFEST_LOADING,this.onManifestLoading,this),e.on(W.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(W.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(W.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(W.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(W.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(W.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(W.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(W.MANIFEST_LOADING,this.onManifestLoading,this),e.off(W.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(W.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(W.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(W.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}onMediaAttaching(e,n){var r;this.media=n.media,((r=n.overrides)==null?void 0:r.cueRemoval)===!1&&(this.removeCues=!1)}onMediaAttached(){var e;const n=(e=this.hls)==null?void 0:e.latestLevelDetails;n&&this.updateDateRangeCues(n)}onMediaDetaching(e,n){this.media=null,!n.transferMedia&&(this.id3Track&&(this.removeCues&&wc(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const n=this.getID3Track(e.textTracks);return n.mode="hidden",n}getID3Track(e){if(this.media){for(let n=0;n<e.length;n++){const r=e[n];if(r.kind==="metadata"&&r.label==="id3")return zM(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,n){if(!this.media||!this.hls)return;const{enableEmsgMetadataCues:r,enableID3MetadataCues:o}=this.hls.config;if(!r&&!o)return;const{samples:s}=n;this.id3Track||(this.id3Track=this.createTrack(this.media));const i=Ty();if(i)for(let a=0;a<s.length;a++){const c=s[a].type;if(c===yo.emsg&&!r||!o)continue;const u=vM(s[a].data),d=s[a].pts;let f=d+s[a].duration;f>gh&&(f=gh),f-d<=0&&(f=d+SX);for(let p=0;p<u.length;p++){const m=u[p];if(!xM(m)){this.updateId3CueEnds(d,c);const g=A0(i,d,f,m,c);g&&this.id3Track.addCue(g)}}}}updateId3CueEnds(e,n){var r;const o=(r=this.id3Track)==null?void 0:r.cues;if(o)for(let s=o.length;s--;){const i=o[s];i.type===n&&i.startTime<e&&i.endTime===gh&&(i.endTime=e)}}onBufferFlushing(e,{startOffset:n,endOffset:r,type:o}){const{id3Track:s,hls:i}=this;if(!i)return;const{config:{enableEmsgMetadataCues:a,enableID3MetadataCues:c}}=i;if(s&&(a||c)){let u;o==="audio"?u=d=>d.type===yo.audioId3&&c:o==="video"?u=d=>d.type===yo.emsg&&a:u=d=>d.type===yo.audioId3&&c||d.type===yo.emsg&&a,Cy(s,n,r,u)}}onLevelUpdated(e,{details:n}){this.updateDateRangeCues(n,!0)}onLevelPtsUpdated(e,n){Math.abs(n.drift)>.01&&this.updateDateRangeCues(n.details)}updateDateRangeCues(e,n){if(!this.hls||!this.media)return;const{assetPlayerId:r,timelineOffset:o,enableDateRangeMetadataCues:s,interstitialsController:i}=this.hls.config;if(!s)return;const a=Ty();if(r&&o&&!i){const{fragmentStart:g,fragmentEnd:y}=e;let v=this.assetCue;v?(v.startTime=g,v.endTime=y):a&&(v=this.assetCue=A0(a,g,y,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),v&&(v.id=r,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(v),v.addEventListener("enter",this.onEventCueEnter)))}if(!e.hasProgramDateTime)return;const{id3Track:c}=this,{dateRanges:u}=e,d=Object.keys(u);let f=this.dateRangeCuesAppended;if(c&&n){var h;if((h=c.cues)!=null&&h.length){const g=Object.keys(f).filter(y=>!d.includes(y));for(let y=g.length;y--;){var p;const v=g[y],C=(p=f[v])==null?void 0:p.cues;delete f[v],C&&Object.keys(C).forEach(S=>{const w=C[S];if(w){w.removeEventListener("enter",this.onEventCueEnter);try{c.removeCue(w)}catch{}}})}}else f=this.dateRangeCuesAppended={}}const m=e.fragments[e.fragments.length-1];if(!(d.length===0||!rt(m==null?void 0:m.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let g=0;g<d.length;g++){const y=d[g],v=u[y],C=v.startTime,S=f[y],w=(S==null?void 0:S.cues)||{};let T=(S==null?void 0:S.durationKnown)||!1,I=gh;const{duration:P,endDate:M}=v;if(M&&P!==null)I=C+P,T=!0;else if(v.endOnNext&&!T){const k=d.reduce((A,E)=>{if(E!==v.id){const L=u[E];if(L.class===v.class&&L.startDate>v.startDate&&(!A||v.startDate<A.startDate))return L}return A},null);k&&(I=k.startTime,T=!0)}const D=Object.keys(v.attr);for(let k=0;k<D.length;k++){const A=D[k];if(!GW(A))continue;const E=w[A];if(E)T&&!(S!=null&&S.durationKnown)?E.endTime=I:Math.abs(E.startTime-C)>.01&&(E.startTime=C,E.endTime=I);else if(a){let L=v.attr[A];zW(A)&&(L=MD(L));const _=A0(a,C,I,{key:A,data:L},yo.dateRange);_&&(_.id=y,this.id3Track.addCue(_),w[A]=_,i&&(A==="X-ASSET-LIST"||A==="X-ASSET-URL")&&_.addEventListener("enter",this.onEventCueEnter))}}f[y]={cues:w,dateRange:v,durationKnown:T}}}}}class TX{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{const{media:n}=this,r=this.levelDetails;if(!n||!r)return;this.currentTime=n.currentTime;const o=this.computeLatency();if(o===null)return;this._latency=o;const{lowLatencyMode:s,maxLiveSyncPlaybackRate:i}=this.config;if(!s||i===1||!r.live)return;const a=this.targetLatency;if(a===null)return;const c=o-a,u=Math.min(this.maxLatency,a+r.targetduration);if(c<u&&c>.05&&this.forwardBufferLength>1){const f=Math.min(2,Math.max(1,i)),h=Math.round(2/(1+Math.exp(-.75*c-this.edgeStalled))*20)/20,p=Math.min(f,Math.max(1,h));this.changeMediaPlaybackRate(n,p)}else n.playbackRate!==1&&n.playbackRate!==0&&this.changeMediaPlaybackRate(n,1)},this.hls=e,this.config=e.config,this.registerListeners()}get levelDetails(){var e;return((e=this.hls)==null?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){const{config:e}=this;if(e.liveMaxLatencyDuration!==void 0)return e.liveMaxLatencyDuration;const n=this.levelDetails;return n?e.liveMaxLatencyDurationCount*n.targetduration:0}get targetLatency(){const e=this.levelDetails;if(e===null||this.hls===null)return null;const{holdBack:n,partHoldBack:r,targetduration:o}=e,{liveSyncDuration:s,liveSyncDurationCount:i,lowLatencyMode:a}=this.config,c=this.hls.userConfig;let u=a&&r||n;(this._targetLatencyUpdated||c.liveSyncDuration||c.liveSyncDurationCount||u===0)&&(u=s!==void 0?s:i*o);const d=o;return u+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,d)}set targetLatency(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}get liveSyncPosition(){const e=this.estimateLiveEdge(),n=this.targetLatency;if(e===null||n===null)return null;const r=this.levelDetails;if(r===null)return null;const o=r.edge,s=e-n-this.edgeStalled,i=o-r.totalduration,a=o-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(i,s),a)}get drift(){const e=this.levelDetails;return e===null?1:e.drift}get edgeStalled(){const e=this.levelDetails;if(e===null)return 0;const n=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-n,0)}get forwardBufferLength(){const{media:e}=this,n=this.levelDetails;if(!e||!n)return 0;const r=e.buffered.length;return(r?e.buffered.end(r-1):n.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}registerListeners(){const{hls:e}=this;e&&(e.on(W.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(W.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(W.MANIFEST_LOADING,this.onManifestLoading,this),e.on(W.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(W.ERROR,this.onError,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(W.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(W.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(W.MANIFEST_LOADING,this.onManifestLoading,this),e.off(W.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(W.ERROR,this.onError,this))}onMediaAttached(e,n){this.media=n.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}onManifestLoading(){this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:n}){n.advanced&&this.onTimeupdate(),!n.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}onError(e,n){var r;n.details===ve.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&(r=this.levelDetails)!=null&&r.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}changeMediaPlaybackRate(e,n){var r,o;e.playbackRate!==n&&((r=this.hls)==null||r.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${(o=this.targetLatency)==null?void 0:o.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${n}`),e.playbackRate=n)}estimateLiveEdge(){const e=this.levelDetails;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}class EX extends Rv{constructor(e,n){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=n,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(W.MANIFEST_LOADING,this.onManifestLoading,this),e.on(W.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(W.LEVEL_LOADED,this.onLevelLoaded,this),e.on(W.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(W.FRAG_BUFFERED,this.onFragBuffered,this),e.on(W.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(W.MANIFEST_LOADING,this.onManifestLoading,this),e.off(W.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(W.LEVEL_LOADED,this.onLevelLoaded,this),e.off(W.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(W.FRAG_BUFFERED,this.onFragBuffered,this),e.off(W.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(n=>{n.loadError=0,n.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,n){this.resetLevels()}onManifestLoaded(e,n){const r=this.hls.config.preferManagedMediaSource,o=[],s={},i={};let a=!1,c=!1,u=!1;n.levels.forEach(d=>{const f=d.attrs;let{audioCodec:h,videoCodec:p}=d;h&&(d.audioCodec=h=vp(h,r)||void 0),p&&(p=d.videoCodec=aW(p));const{width:m,height:g,unknownCodecs:y}=d,v=(y==null?void 0:y.length)||0;if(a||(a=!!(m&&g)),c||(c=!!p),u||(u=!!h),v||h&&!this.isAudioSupported(h)||p&&!this.isVideoSupported(p)){this.log(`Some or all CODECS not supported "${f.CODECS}"`);return}const{CODECS:C,"FRAME-RATE":S,"HDCP-LEVEL":w,"PATHWAY-ID":T,RESOLUTION:I,"VIDEO-RANGE":P}=f,D=`${`${T||"."}-`}${d.bitrate}-${I}-${S}-${C}-${P}-${w}`;if(s[D])if(s[D].uri!==d.url&&!d.attrs["PATHWAY-ID"]){const k=i[D]+=1;d.attrs["PATHWAY-ID"]=new Array(k+1).join(".");const A=this.createLevel(d);s[D]=A,o.push(A)}else s[D].addGroupId("audio",f.AUDIO),s[D].addGroupId("text",f.SUBTITLES);else{const k=this.createLevel(d);s[D]=k,i[D]=1,o.push(k)}}),this.filterAndSortMediaOptions(o,n,a,c,u)}createLevel(e){const n=new Nd(e),r=e.supplemental;if(r!=null&&r.videoCodec&&!this.isVideoSupported(r.videoCodec)){const o=new Error(`SUPPLEMENTAL-CODECS not supported "${r.videoCodec}"`);this.log(o.message),n.supportedResult=HD(o,[])}return n}isAudioSupported(e){return Od(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return Od(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,n,r,o,s){var i;let a=[],c=[],u=e;const d=((i=n.stats)==null?void 0:i.parsing)||{};if((r||o)&&s&&(u=u.filter(({videoCodec:C,videoRange:S,width:w,height:T})=>(!!C||!!(w&&T))&&yW(S))),u.length===0){Promise.resolve().then(()=>{if(this.hls){let C="no level with compatible codecs found in manifest",S=C;n.levels.length&&(S=`one or more CODECS in variant not supported: ${Cn(n.levels.map(T=>T.attrs.CODECS).filter((T,I,P)=>P.indexOf(T)===I))}`,this.warn(S),C+=` (${S})`);const w=new Error(C);this.hls.trigger(W.ERROR,{type:pt.MEDIA_ERROR,details:ve.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:n.url,error:w,reason:S})}}),d.end=performance.now();return}n.audioTracks&&(a=n.audioTracks.filter(C=>!C.audioCodec||this.isAudioSupported(C.audioCodec)),qE(a)),n.subtitles&&(c=n.subtitles,qE(c));const f=u.slice(0);u.sort((C,S)=>{if(C.attrs["HDCP-LEVEL"]!==S.attrs["HDCP-LEVEL"])return(C.attrs["HDCP-LEVEL"]||"")>(S.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&C.height!==S.height)return C.height-S.height;if(C.frameRate!==S.frameRate)return C.frameRate-S.frameRate;if(C.videoRange!==S.videoRange)return xp.indexOf(C.videoRange)-xp.indexOf(S.videoRange);if(C.videoCodec!==S.videoCodec){const w=BT(C.videoCodec),T=BT(S.videoCodec);if(w!==T)return T-w}if(C.uri===S.uri&&C.codecSet!==S.codecSet){const w=bp(C.codecSet),T=bp(S.codecSet);if(w!==T)return T-w}return C.averageBitrate!==S.averageBitrate?C.averageBitrate-S.averageBitrate:0});let h=f[0];if(this.steering&&(u=this.steering.filterParsedLevels(u),u.length!==f.length)){for(let C=0;C<f.length;C++)if(f[C].pathwayId===u[0].pathwayId){h=f[C];break}}this._levels=u;for(let C=0;C<u.length;C++)if(u[C]===h){var p;this._firstLevel=C;const S=h.bitrate,w=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${u.length} level(s) found, first bitrate: ${S}`),((p=this.hls.userConfig)==null?void 0:p.abrEwmaDefaultEstimate)===void 0){const T=Math.min(S,this.hls.config.abrEwmaDefaultEstimateMax);T>w&&w===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=T)}break}const m=s&&!o,g=this.hls.config,y=!!(g.audioStreamController&&g.audioTrackController),v={levels:u,audioTracks:a,subtitleTracks:c,sessionData:n.sessionData,sessionKeys:n.sessionKeys,firstLevel:this._firstLevel,stats:n.stats,audio:s,video:o,altAudio:y&&!m&&a.some(C=>!!C.url)};d.end=performance.now(),this.hls.trigger(W.MANIFEST_PARSED,v)}get levels(){return this._levels.length===0?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){const n=this._levels;if(n.length===0)return;if(e<0||e>=n.length){const d=new Error("invalid level idx"),f=e<0;if(this.hls.trigger(W.ERROR,{type:pt.OTHER_ERROR,details:ve.LEVEL_SWITCH_ERROR,level:e,fatal:f,error:d,reason:d.message}),f)return;e=Math.min(e,n.length-1)}const r=this.currentLevelIndex,o=this.currentLevel,s=o?o.attrs["PATHWAY-ID"]:void 0,i=n[e],a=i.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=i,r===e&&o&&s===a)return;this.log(`Switching to level ${e} (${i.height?i.height+"p ":""}${i.videoRange?i.videoRange+" ":""}${i.codecSet?i.codecSet+" ":""}@${i.bitrate})${a?" with Pathway "+a:""} from level ${r}${s?" with Pathway "+s:""}`);const c={level:e,attrs:i.attrs,details:i.details,bitrate:i.bitrate,averageBitrate:i.averageBitrate,maxBitrate:i.maxBitrate,realBitrate:i.realBitrate,width:i.width,height:i.height,codecSet:i.codecSet,audioCodec:i.audioCodec,videoCodec:i.videoCodec,audioGroups:i.audioGroups,subtitleGroups:i.subtitleGroups,loaded:i.loaded,loadError:i.loadError,fragmentError:i.fragmentError,name:i.name,id:i.id,uri:i.uri,url:i.url,urlId:0,audioGroupIds:i.audioGroupIds,textGroupIds:i.textGroupIds};this.hls.trigger(W.LEVEL_SWITCHING,c);const u=i.details;if(!u||u.live){const d=this.switchParams(i.uri,o==null?void 0:o.details,u);this.loadPlaylist(d)}}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}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){const n=this.steering.pathways(),r=e.filter(o=>n.indexOf(o)!==-1);if(e.length<1){this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${n}`);return}this.steering.pathwayPriority=r}}onError(e,n){n.fatal||!n.context||n.context.type===Ht.LEVEL&&n.context.level===this.level&&this.checkRetry(n)}onFragBuffered(e,{frag:n}){if(n!==void 0&&n.type===lt.MAIN){const r=n.elementaryStreams;if(!Object.keys(r).some(s=>!!r[s]))return;const o=this._levels[n.level];o!=null&&o.loadError&&(this.log(`Resetting level error count of ${o.loadError} on frag buffered`),o.loadError=0)}}onLevelLoaded(e,n){var r;const{level:o,details:s}=n,i=n.levelInfo;if(!i){var a;this.warn(`Invalid level index ${o}`),(a=n.deliveryDirectives)!=null&&a.skip&&(s.deltaUpdateFailed=!0);return}if(i===this.currentLevel||n.withoutMultiVariant){i.fragmentError===0&&(i.loadError=0);let c=i.details;c===n.details&&c.advanced&&(c=void 0),this.playlistLoaded(o,n,c)}else(r=n.deliveryDirectives)!=null&&r.skip&&(s.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}loadingPlaylist(e,n){super.loadingPlaylist(e,n);const r=this.getUrlWithDirectives(e.uri,n),o=this.currentLevelIndex,s=e.attrs["PATHWAY-ID"],i=e.details,a=i==null?void 0:i.age;this.log(`Loading level index ${o}${(n==null?void 0:n.msn)!==void 0?" at sn "+n.msn+" part "+n.part:""}${s?" Pathway "+s:""}${a&&i.live?" age "+a.toFixed(1)+(i.type&&" "+i.type||""):""} ${r}`),this.hls.trigger(W.LEVEL_LOADING,{url:r,level:o,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:n||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 n;if(this._levels.length===1)return;const r=this._levels.filter((s,i)=>i!==e?!0:(this.steering&&this.steering.removeLevel(s),s===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,s.details&&s.details.fragments.forEach(a=>a.level=-1)),!1));cM(r),this._levels=r,this.currentLevelIndex>-1&&(n=this.currentLevel)!=null&&n.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);const o=r.length-1;this._firstLevel=Math.min(this._firstLevel,o),this._startLevel&&(this._startLevel=Math.min(this._startLevel,o)),this.hls.trigger(W.LEVELS_UPDATED,{levels:r})}onLevelsUpdated(e,{levels:n}){this._levels=n}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:n,maxHdcpLevel:r}=this.hls;this._maxAutoLevel!==n&&(this._maxAutoLevel=n,this.hls.trigger(W.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:n,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))}}function qE(t){const e={};t.forEach(n=>{const r=n.groupId||"";n.id=e[r]=e[r]||0,e[r]++})}function oA(){return self.SourceBuffer||self.WebKitSourceBuffer}function sA(){if(!ba())return!1;const e=oA();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function IX(){if(!sA())return!1;const t=ba();return typeof(t==null?void 0:t.isTypeSupported)=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>t.isTypeSupported(Fd(e,"video")))||["mp4a.40.2","fLaC"].some(e=>t.isTypeSupported(Fd(e,"audio"))))}function kX(){var t;const e=oA();return typeof(e==null||(t=e.prototype)==null?void 0:t.changeType)=="function"}const PX=100;class DX extends Tv{constructor(e,n,r){super(e,n,r,"stream-controller",lt.MAIN),this.audioCodecSwap=!1,this.level=-1,this._forceStartLoad=!1,this._hasEnoughToStart=!1,this.altAudio=0,this.audioOnly=!1,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick()},this.onMediaSeeked=()=>{const o=this.media,s=o?o.currentTime:null;if(s===null||!rt(s)||(this.log(`Media seeked to ${s.toFixed(3)}`),!this.getBufferedFrag(s)))return;const i=this.getFwdBufferInfoAtPos(o,s,lt.MAIN,0);if(i===null||i.len===0){this.warn(`Main forward buffer length at ${s} on "seeked" event ${i?i.len:"empty"})`);return}this.tick()},this.registerListeners()}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(W.MANIFEST_PARSED,this.onManifestParsed,this),e.on(W.LEVEL_LOADING,this.onLevelLoading,this),e.on(W.LEVEL_LOADED,this.onLevelLoaded,this),e.on(W.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(W.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(W.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(W.BUFFER_CREATED,this.onBufferCreated,this),e.on(W.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(W.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(W.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(W.MANIFEST_PARSED,this.onManifestParsed,this),e.off(W.LEVEL_LOADED,this.onLevelLoaded,this),e.off(W.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(W.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(W.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(W.BUFFER_CREATED,this.onBufferCreated,this),e.off(W.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(W.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(W.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}startLoad(e,n){if(this.levels){const{lastCurrentTime:r,hls:o}=this;if(this.stopLoad(),this.setInterval(PX),this.level=-1,!this.startFragRequested){let s=o.startLevel;s===-1&&(o.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=o.firstAutoLevel),o.nextLoadLevel=s,this.level=o.loadLevel,this._hasEnoughToStart=!!n}r>0&&e===-1&&!n&&(this.log(`Override startPosition with lastCurrentTime @${r.toFixed(3)}`),e=r),this.state=Le.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=n?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=Le.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Le.WAITING_LEVEL:{const{levels:e,level:n}=this,r=e==null?void 0:e[n],o=r==null?void 0:r.details;if(o&&(!o.live||this.levelLastLoaded===r&&!this.waitForLive(r))){if(this.waitForCdnTuneIn(o))break;this.state=Le.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=Le.IDLE;break}break}case Le.FRAG_LOADING_WAITING_RETRY:this.checkRetryDate();break}this.state===Le.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){var e;super.onTickEnd(),(e=this.media)!=null&&e.readyState&&this.media.seeking===!1&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:n,levels:r,media:o}=this;if(n===null||!o&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;const s=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(r!=null&&r[s]))return;const i=r[s],a=this.getMainFwdBufferInfo();if(a===null)return;const c=this.getLevelDetails();if(c&&this._streamEnded(a,c)){const g={};this.altAudio===2&&(g.type="video"),this.hls.trigger(W.BUFFER_EOS,g),this.state=Le.ENDED;return}if(!this.buffering)return;e.loadLevel!==s&&e.manualLevel===-1&&this.log(`Adapting to level ${s} from level ${this.level}`),this.level=e.nextLoadLevel=s;const u=i.details;if(!u||this.state===Le.WAITING_LEVEL||this.waitForLive(i)){this.level=s,this.state=Le.WAITING_LEVEL,this.startFragRequested=!1;return}const d=a.len,f=this.getMaxBufferLength(i.maxBitrate);if(d>=f)return;this.backtrackFragment&&this.backtrackFragment.start>a.end&&(this.backtrackFragment=null);const h=this.backtrackFragment?this.backtrackFragment.start:a.end;let p=this.getNextFragment(h,u);if(this.couldBacktrack&&!this.fragPrevious&&p&&Jn(p)&&this.fragmentTracker.getState(p)!==fr.OK){var m;const y=((m=this.backtrackFragment)!=null?m:p).sn-u.startSN,v=u.fragments[y-1];v&&p.cc===v.cc&&(p=v,this.fragmentTracker.removeFragment(v))}else this.backtrackFragment&&a.len&&(this.backtrackFragment=null);if(p&&this.isLoopLoading(p,h)){if(!p.gap){const y=this.audioOnly&&!this.altAudio?xn.AUDIO:xn.VIDEO,v=(y===xn.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;v&&this.afterBufferFlushed(v,y,lt.MAIN)}p=this.getNextFragmentLoopLoading(p,u,a,lt.MAIN,f)}p&&(p.initSegment&&!p.initSegment.data&&!this.bitrateTest&&(p=p.initSegment),this.loadFragment(p,i,h))}loadFragment(e,n,r){const o=this.fragmentTracker.getState(e);o===fr.NOT_LOADED||o===fr.PARTIAL?Jn(e)?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,n)):super.loadFragment(e,n,r):this._loadInitSegment(e,n):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,lt.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:n}=this;if(n!=null&&n.readyState){let r;const o=this.getAppendedFrag(n.currentTime);o&&o.start>1&&this.flushMainBuffer(0,o.start-1);const s=this.getLevelDetails();if(s!=null&&s.live){const a=this.getMainFwdBufferInfo();if(!a||a.len<s.targetduration*2)return}if(!n.paused&&e){const a=this.hls.nextLoadLevel,c=e[a],u=this.fragLastKbps;u&&this.fragCurrent?r=this.fragCurrent.duration*c.maxBitrate/(1e3*u)+1:r=0}else r=0;const i=this.getBufferedFrag(n.currentTime+r);if(i){const a=this.followingBufferedFrag(i);if(a){this.abortCurrentFrag();const c=a.maxStartPTS?a.maxStartPTS:a.start,u=a.duration,d=Math.max(i.end,c+Math.min(Math.max(u-this.config.maxFragLookUpTolerance,u*(this.couldBacktrack?.5:.125)),u*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(d,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 Le.KEY_LOADING:case Le.FRAG_LOADING:case Le.FRAG_LOADING_WAITING_RETRY:case Le.PARSING:case Le.PARSED:this.state=Le.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,n){super.flushMainBuffer(e,n,this.altAudio===2?"video":null)}onMediaAttached(e,n){super.onMediaAttached(e,n);const r=n.media;qr(r,"playing",this.onMediaPlaying),qr(r,"seeked",this.onMediaSeeked)}onMediaDetaching(e,n){const{media:r}=this;r&&(to(r,"playing",this.onMediaPlaying),to(r,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(e,n),!n.transferMedia&&(this._hasEnoughToStart=!1)}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(W.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}onManifestParsed(e,n){let r=!1,o=!1;for(let s=0;s<n.levels.length;s++){const i=n.levels[s].audioCodec;i&&(r=r||i.indexOf("mp4a.40.2")!==-1,o=o||i.indexOf("mp4a.40.5")!==-1)}this.audioCodecSwitch=r&&o&&!kX(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=n.levels,this.startFragRequested=!1}onLevelLoading(e,n){const{levels:r}=this;if(!r||this.state!==Le.IDLE)return;const o=n.levelInfo;(!o.details||o.details.live&&(this.levelLastLoaded!==o||o.details.expired)||this.waitForCdnTuneIn(o.details))&&(this.state=Le.WAITING_LEVEL)}onLevelLoaded(e,n){var r;const{levels:o,startFragRequested:s}=this,i=n.level,a=n.details,c=a.totalduration;if(!o){this.warn(`Levels were reset while loading level ${i}`);return}this.log(`Level ${i} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${c}`);const u=n.levelInfo,d=this.fragCurrent;d&&(this.state===Le.FRAG_LOADING||this.state===Le.FRAG_LOADING_WAITING_RETRY)&&d.level!==n.level&&d.loader&&this.abortCurrentFrag();let f=0;if(a.live||(r=u.details)!=null&&r.live){var h;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;f=this.alignPlaylists(a,u.details,(h=this.levelLastLoaded)==null?void 0:h.details)}if(u.details=a,this.levelLastLoaded=u,s||this.setStartPosition(a,f),this.hls.trigger(W.LEVEL_UPDATED,{details:a,level:i}),this.state===Le.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=Le.IDLE}s&&a.live&&this.synchronizeToLiveEdge(a),this.tick()}synchronizeToLiveEdge(e){const{config:n,media:r}=this;if(!r)return;const o=this.hls.liveSyncPosition,s=this.getLoadPosition(),i=e.fragmentStart,a=e.edge,c=s>=i-n.maxFragLookUpTolerance&&s<=a;if(o!==null&&r.duration>o&&(s<o||!c)){const d=n.liveMaxLatencyDuration!==void 0?n.liveMaxLatencyDuration:n.liveMaxLatencyDurationCount*e.targetduration;if((!c&&r.readyState<4||s<a-d)&&(this._hasEnoughToStart||(this.nextLoadPosition=o),r.readyState))if(this.warn(`Playback: ${s.toFixed(3)} is located too far from the end of live sliding playlist: ${a}, reset currentTime to : ${o.toFixed(3)}`),this.config.liveSyncMode==="buffered"){var u;const f=Dt.bufferInfo(r,o,0);if(!((u=f.buffered)!=null&&u.length)){r.currentTime=o;return}if(f.start<=s){r.currentTime=o;return}const{nextStart:p}=Dt.bufferedInfo(f.buffered,s,0);p&&(r.currentTime=p)}else r.currentTime=o}}_handleFragmentLoadProgress(e){var n;const r=e.frag,{part:o,payload:s}=e,{levels:i}=this;if(!i){this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}const a=i[r.level];if(!a){this.warn(`Level ${r.level} not found on progress`);return}const c=a.details;if(!c){this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),this.fragmentTracker.removeFragment(r);return}const u=a.videoCodec,d=c.PTSKnown||!c.live,f=(n=r.initSegment)==null?void 0:n.data,h=this._getAudioCodec(a),p=this.transmuxer=this.transmuxer||new AM(this.hls,lt.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=o?o.index:-1,g=m!==-1,y=new Cv(r.level,r.sn,r.stats.chunkCount,s.byteLength,m,g),v=this.initPTS[r.cc];p.push(s,f,h,u,r,o,c.totalduration,d,y,v)}onAudioTrackSwitching(e,n){const r=this.hls,o=this.altAudio!==0;if(Cp(n.url,r))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const i=this.fragCurrent;i&&(this.log("Switching to main audio track, cancel main fragment load"),i.abortRequests(),this.fragmentTracker.removeFragment(i)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(o){this.altAudio=0,this.fragmentTracker.removeAllFragments(),r.once(W.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(W.AUDIO_TRACK_SWITCHED,n)}),r.trigger(W.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}r.trigger(W.AUDIO_TRACK_SWITCHED,n)}}onAudioTrackSwitched(e,n){const r=Cp(n.url,this.hls);if(r){const o=this.videoBuffer;o&&this.mediaBuffer!==o&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=o)}this.altAudio=r?2:0,this.tick()}onBufferCreated(e,n){const r=n.tracks;let o,s,i=!1;for(const a in r){const c=r[a];if(c.id==="main"){if(s=a,o=c,a==="video"){const u=r[a];u&&(this.videoBuffer=u.buffer)}}else i=!0}i&&o?(this.log(`Alternate track found, use ${s}.buffered to schedule main fragment loading`),this.mediaBuffer=o.buffer):this.mediaBuffer=this.media}onFragBuffered(e,n){const{frag:r,part:o}=n,s=r.type===lt.MAIN;if(s){if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${o?" p: "+o.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),this.state===Le.PARSED&&(this.state=Le.IDLE);return}const a=o?o.stats:r.stats;this.fragLastKbps=Math.round(8*a.total/(a.buffering.end-a.loading.first)),Jn(r)&&(this.fragPrevious=r),this.fragBufferedComplete(r,o)}const i=this.media;i&&(!this._hasEnoughToStart&&Dt.getBuffered(i).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),s&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,n){var r;if(n.fatal){this.state=Le.ERROR;return}switch(n.details){case ve.FRAG_GAP:case ve.FRAG_PARSING_ERROR:case ve.FRAG_DECRYPT_ERROR:case ve.FRAG_LOAD_ERROR:case ve.FRAG_LOAD_TIMEOUT:case ve.KEY_LOAD_ERROR:case ve.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(lt.MAIN,n);break;case ve.LEVEL_LOAD_ERROR:case ve.LEVEL_LOAD_TIMEOUT:case ve.LEVEL_PARSING_ERROR:!n.levelRetry&&this.state===Le.WAITING_LEVEL&&((r=n.context)==null?void 0:r.type)===Ht.LEVEL&&(this.state=Le.IDLE);break;case ve.BUFFER_ADD_CODEC_ERROR:case ve.BUFFER_APPEND_ERROR:if(n.parent!=="main")return;this.reduceLengthAndFlushBuffer(n)&&this.resetLoadingState();break;case ve.BUFFER_FULL_ERROR:if(n.parent!=="main")return;this.reduceLengthAndFlushBuffer(n)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY));break;case ve.INTERNAL_EXCEPTION:this.recoverWorkerError(n);break}}onFragLoadEmergencyAborted(){this.state=Le.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:n}){if(n!==xn.AUDIO||!this.altAudio){const r=(n===xn.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;r&&(this.afterBufferFlushed(r,n,lt.MAIN),this.tick())}}onLevelsUpdated(e,n){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,this.level===-1&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=n.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const n=e.currentTime;let r=this.startPosition;if(r>=0&&n<r){if(e.seeking){this.log(`could not seek to ${r}, already seeking at ${n}`);return}const o=this.timelineOffset;o&&r&&(r+=o);const s=this.getLevelDetails(),i=Dt.getBuffered(e),a=i.length?i.start(0):0,c=a-r,u=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||c>0&&(c<u||this.loadingParts&&c<2*((s==null?void 0:s.partTarget)||0)))&&(this.log(`adjusting start position by ${c} to match buffer start`),r+=c,this.startPosition=r),n<r&&(this.log(`seek to target start position ${r} from current time ${n} buffer start ${a}`),e.currentTime=r)}}_getAudioCodec(e){let n=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&n&&(this.log("Swapping audio codec"),n.indexOf("mp4a.40.5")!==-1?n="mp4a.40.2":n="mp4a.40.5"),n}_loadBitrateTestFrag(e,n){e.bitrateTest=!0,this._doFragLoad(e,n).then(r=>{const{hls:o}=this,s=r==null?void 0:r.frag;if(!s||this.fragContextChanged(s))return;n.fragmentError=0,this.state=Le.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const i=s.stats;i.parsing.start=i.parsing.end=i.buffering.start=i.buffering.end=self.performance.now(),o.trigger(W.FRAG_LOADED,r),s.bitrateTest=!1}).catch(r=>{this.state===Le.STOPPED||this.state===Le.ERROR||(this.warn(r),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){const n=this.playlistType,{hls:r}=this,{remuxResult:o,chunkMeta:s}=e,i=this.getCurrentContext(s);if(!i){this.resetWhenMissingContext(s);return}const{frag:a,part:c,level:u}=i,{video:d,text:f,id3:h,initSegment:p}=o,{details:m}=u,g=this.altAudio?void 0:o.audio;if(this.fragContextChanged(a)){this.fragmentTracker.removeFragment(a);return}if(this.state=Le.PARSING,p){const y=p.tracks;if(y){const w=a.initSegment||a;if(this.unhandledEncryptionError(p,a))return;this._bufferInitSegment(u,y,w,s),r.trigger(W.FRAG_PARSING_INIT_SEGMENT,{frag:w,id:n,tracks:y})}const v=p.initPTS,C=p.timescale,S=this.initPTS[a.cc];if(rt(v)&&(!S||S.baseTime!==v||S.timescale!==C)){const w=p.trackId;this.initPTS[a.cc]={baseTime:v,timescale:C,trackId:w},r.trigger(W.INIT_PTS_FOUND,{frag:a,id:n,initPTS:v,timescale:C,trackId:w})}}if(d&&m){g&&d.type==="audiovideo"&&this.logMuxedErr(a);const y=m.fragments[a.sn-1-m.startSN],v=a.sn===m.startSN,C=!y||a.cc>y.cc;if(o.independent!==!1){const{startPTS:S,endPTS:w,startDTS:T,endDTS:I}=d;if(c)c.elementaryStreams[d.type]={startPTS:S,endPTS:w,startDTS:T,endDTS:I};else if(d.firstKeyFrame&&d.independent&&s.id===1&&!C&&(this.couldBacktrack=!0),d.dropped&&d.independent){const P=this.getMainFwdBufferInfo(),M=(P?P.end:this.getLoadPosition())+this.config.maxBufferHole,D=d.firstKeyFramePTS?d.firstKeyFramePTS:S;if(!v&&M<D-this.config.maxBufferHole&&!C){this.backtrack(a);return}else C&&(a.gap=!0);a.setElementaryStreamInfo(d.type,a.start,w,a.start,I,!0)}else v&&S-(m.appliedTimelineOffset||0)>Kh&&(a.gap=!0);a.setElementaryStreamInfo(d.type,S,w,T,I),this.backtrackFragment&&(this.backtrackFragment=a),this.bufferFragmentData(d,a,c,s,v||C)}else if(v||C)a.gap=!0;else{this.backtrack(a);return}}if(g){const{startPTS:y,endPTS:v,startDTS:C,endDTS:S}=g;c&&(c.elementaryStreams[xn.AUDIO]={startPTS:y,endPTS:v,startDTS:C,endDTS:S}),a.setElementaryStreamInfo(xn.AUDIO,y,v,C,S),this.bufferFragmentData(g,a,c,s)}if(m&&h!=null&&h.samples.length){const y={id:n,frag:a,details:m,samples:h.samples};r.trigger(W.FRAG_PARSING_METADATA,y)}if(m&&f){const y={id:n,frag:a,details:m,samples:f.samples};r.trigger(W.FRAG_PARSING_USERDATA,y)}}logMuxedErr(e){this.warn(`${Jn(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,n,r,o){if(this.state!==Le.PARSING)return;this.audioOnly=!!n.audio&&!n.video,this.altAudio&&!this.audioOnly&&(delete n.audio,n.audiovideo&&this.logMuxedErr(r));const{audio:s,video:i,audiovideo:a}=n;if(s){const u=e.audioCodec;let d=Vh(s.codec,u);d==="mp4a"&&(d="mp4a.40.5");const f=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){d&&(d.indexOf("mp4a.40.5")!==-1?d="mp4a.40.2":d="mp4a.40.5");const h=s.metadata;h&&"channelCount"in h&&(h.channelCount||1)!==1&&f.indexOf("firefox")===-1&&(d="mp4a.40.5")}d&&d.indexOf("mp4a.40.5")!==-1&&f.indexOf("android")!==-1&&s.container!=="audio/mpeg"&&(d="mp4a.40.2",this.log(`Android: force audio codec to ${d}`)),u&&u!==d&&this.log(`Swapping manifest audio codec "${u}" for "${d}"`),s.levelCodec=d,s.id=lt.MAIN,this.log(`Init audio buffer, container:${s.container}, codecs[selected/level/parsed]=[${d||""}/${u||""}/${s.codec}]`),delete n.audiovideo}if(i){i.levelCodec=e.videoCodec,i.id=lt.MAIN;const u=i.codec;if((u==null?void 0:u.length)===4)switch(u){case"hvc1":case"hev1":i.codec="hvc1.1.6.L120.90";break;case"av01":i.codec="av01.0.04M.08";break;case"avc1":i.codec="avc1.42e01e";break}this.log(`Init video buffer, container:${i.container}, codecs[level/parsed]=[${e.videoCodec||""}/${u}]${i.codec!==u?" parsed-corrected="+i.codec:""}${i.supplemental?" supplemental="+i.supplemental:""}`),delete n.audiovideo}a&&(this.log(`Init audiovideo buffer, container:${a.container}, codecs[level/parsed]=[${e.codecs}/${a.codec}]`),delete n.video,delete n.audio);const c=Object.keys(n);if(c.length){if(this.hls.trigger(W.BUFFER_CODECS,n),!this.hls)return;c.forEach(u=>{const f=n[u].initSegment;f!=null&&f.byteLength&&this.hls.trigger(W.BUFFER_APPENDING,{type:u,data:f,frag:r,part:null,chunkMeta:o,parent:r.type})})}this.tickImmediate()}getMainFwdBufferInfo(){const e=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,lt.MAIN)}get maxBufferLength(){const{levels:e,level:n}=this,r=e==null?void 0:e[n];return r?this.getMaxBufferLength(r.maxBitrate):this.config.maxBufferLength}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=Le.IDLE}checkFragmentChanged(){const e=this.media;let n=null;if(e&&e.readyState>1&&e.seeking===!1){const r=e.currentTime;if(Dt.isBuffered(e,r)?n=this.getAppendedFrag(r):Dt.isBuffered(e,r+.1)&&(n=this.getAppendedFrag(r+.1)),n){this.backtrackFragment=null;const o=this.fragPlaying,s=n.level;(!o||n.sn!==o.sn||o.level!==s)&&(this.fragPlaying=n,this.hls.trigger(W.FRAG_CHANGED,{frag:n}),(!o||o.level!==s)&&this.hls.trigger(W.LEVEL_SWITCHED,{level:s}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){var e;if(this.fragPlaying)return this.fragPlaying;const n=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;return rt(n)?this.getAppendedFrag(n):null}get currentProgramDateTime(){var e;const n=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;if(rt(n)){const r=this.getLevelDetails(),o=this.currentFrag||(r?vl(null,r.fragments,n):null);if(o){const s=o.programDateTime;if(s!==null){const i=s+(n-o.start)*1e3;return new Date(i)}}}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 MX extends Jo{constructor(e,n){super("key-loader",n),this.config=void 0,this.keyIdToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const r in this.keyIdToKeyInfo){const o=this.keyIdToKeyInfo[r].loader;if(o){var n;if(e&&e!==((n=o.context)==null?void 0:n.frag.type))return;o.abort()}}}detach(){for(const e in this.keyIdToKeyInfo){const n=this.keyIdToKeyInfo[e];(n.mediaKeySessionContext||n.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyIdToKeyInfo){const n=this.keyIdToKeyInfo[e].loader;n&&n.destroy()}this.keyIdToKeyInfo={}}createKeyLoadError(e,n=ve.KEY_LOAD_ERROR,r,o,s){return new wi({type:pt.NETWORK_ERROR,details:n,fatal:!1,frag:e,response:s,error:r,networkDetails:o})}loadClear(e,n,r){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(n.length)for(let o=0,s=n.length;o<s;o++){const i=n[o];if(e.cc<=i.cc&&(!Jn(e)||!Jn(i)||e.sn<i.sn)||!r&&o==s-1)return this.emeController.selectKeySystemFormat(i).then(a=>{if(!this.emeController)return;i.setKeyFormat(a);const c=Uh(a);if(c)return this.emeController.getKeySystemAccess([c])})}if(this.config.requireKeySystemAccessOnStart){const o=Ju(this.config);if(o.length)return this.emeController.getKeySystemAccess(o)}}return null}load(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(n=>this.loadInternal(e,n)):this.loadInternal(e)}loadInternal(e,n){var r,o;n&&e.setKeyFormat(n);const s=e.decryptdata;if(!s){const u=new Error(n?`Expected frag.decryptdata to be defined after setting format ${n}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(this.createKeyLoadError(e,ve.KEY_LOAD_ERROR,u))}const i=s.uri;if(!i)return Promise.reject(this.createKeyLoadError(e,ve.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${i}"`)));const a=R0(s);let c=this.keyIdToKeyInfo[a];if((r=c)!=null&&r.decryptdata.key)return s.key=c.decryptdata.key,Promise.resolve({frag:e,keyInfo:c});if(this.emeController&&(o=c)!=null&&o.keyLoadPromise)switch(this.emeController.getKeyStatus(c.decryptdata)){case"usable":case"usable-in-future":return c.keyLoadPromise.then(d=>{const{keyInfo:f}=d;return s.key=f.decryptdata.key,{frag:e,keyInfo:f}})}switch(this.log(`${this.keyIdToKeyInfo[a]?"Rel":"L"}oading${s.keyId?" keyId: "+Er(s.keyId):""} URI: ${s.uri} from ${e.type} ${e.level}`),c=this.keyIdToKeyInfo[a]={decryptdata:s,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},s.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return s.keyFormat==="identity"?this.loadKeyHTTP(c,e):this.loadKeyEME(c,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(c,e);default:return Promise.reject(this.createKeyLoadError(e,ve.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${s.method}"`)))}}loadKeyEME(e,n){const r={frag:n,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var o;if(!e.decryptdata.keyId&&(o=n.initSegment)!=null&&o.data){const i=Yz(n.initSegment.data);if(i.length){let a=i[0];a.some(c=>c!==0)?(this.log(`Using keyId found in init segment ${Er(a)}`),fa.setKeyIdForUri(e.decryptdata.uri,a)):(a=fa.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${Er(a)}`)),e.decryptdata.keyId=a}}if(!e.decryptdata.keyId&&!Jn(n))return Promise.resolve(r);const s=this.emeController.loadKey(r);return(e.keyLoadPromise=s.then(i=>(e.mediaKeySessionContext=i,r))).catch(i=>{throw e.keyLoadPromise=null,"data"in i&&(i.data.frag=n),i})}return Promise.resolve(r)}loadKeyHTTP(e,n){const r=this.config,o=r.loader,s=new o(r);return n.keyLoader=e.loader=s,e.keyLoadPromise=new Promise((i,a)=>{const c={keyInfo:e,frag:n,responseType:"arraybuffer",url:e.decryptdata.uri},u=r.keyLoadPolicy.default,d={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},f={onSuccess:(h,p,m,g)=>{const{frag:y,keyInfo:v}=m,C=R0(v.decryptdata);if(!y.decryptdata||v!==this.keyIdToKeyInfo[C])return a(this.createKeyLoadError(y,ve.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,i({frag:y,keyInfo:v})},onError:(h,p,m,g)=>{this.resetLoader(p),a(this.createKeyLoadError(n,ve.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),m,un({url:c.url,data:void 0},h)))},onTimeout:(h,p,m)=>{this.resetLoader(p),a(this.createKeyLoadError(n,ve.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m))},onAbort:(h,p,m)=>{this.resetLoader(p),a(this.createKeyLoadError(n,ve.INTERNAL_ABORTED,new Error("key loading aborted"),m))}};s.load(c,d,f)})}resetLoader(e){const{frag:n,keyInfo:r,url:o}=e,s=r.loader;n.keyLoader===s&&(n.keyLoader=null,r.loader=null);const i=R0(r.decryptdata)||o;delete this.keyIdToKeyInfo[i],s&&s.destroy()}}function R0(t){if(t.keyFormat!==kr.FAIRPLAY){const e=t.keyId;if(e)return Er(e)}return t.uri}function KE(t){const{type:e}=t;switch(e){case Ht.AUDIO_TRACK:return lt.AUDIO;case Ht.SUBTITLE_TRACK:return lt.SUBTITLE;default:return lt.MAIN}}function L0(t,e){let n=t.url;return(n===void 0||n.indexOf("data:")===0)&&(n=e.url),n}class AX{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(W.MANIFEST_LOADING,this.onManifestLoading,this),e.on(W.LEVEL_LOADING,this.onLevelLoading,this),e.on(W.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(W.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(W.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off(W.MANIFEST_LOADING,this.onManifestLoading,this),e.off(W.LEVEL_LOADING,this.onLevelLoading,this),e.off(W.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(W.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(W.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){const n=this.hls.config,r=n.pLoader,o=n.loader,s=r||o,i=new s(n);return this.loaders[e.type]=i,i}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const n=this.loaders[e];n&&n.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,n){const{url:r}=n;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Ht.MANIFEST,url:r,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,n){const{id:r,level:o,pathwayId:s,url:i,deliveryDirectives:a,levelInfo:c}=n;this.load({id:r,level:o,pathwayId:s,responseType:"text",type:Ht.LEVEL,url:i,deliveryDirectives:a,levelOrTrack:c})}onAudioTrackLoading(e,n){const{id:r,groupId:o,url:s,deliveryDirectives:i,track:a}=n;this.load({id:r,groupId:o,level:null,responseType:"text",type:Ht.AUDIO_TRACK,url:s,deliveryDirectives:i,levelOrTrack:a})}onSubtitleTrackLoading(e,n){const{id:r,groupId:o,url:s,deliveryDirectives:i,track:a}=n;this.load({id:r,groupId:o,level:null,responseType:"text",type:Ht.SUBTITLE_TRACK,url:s,deliveryDirectives:i,levelOrTrack:a})}onLevelsUpdated(e,n){const r=this.loaders[Ht.LEVEL];if(r){const o=r.context;o&&!n.levels.some(s=>s===o.levelOrTrack)&&(r.abort(),delete this.loaders[Ht.LEVEL])}}load(e){var n;const r=this.hls.config;let o=this.getInternalLoader(e);if(o){const u=this.hls.logger,d=o.context;if(d&&d.levelOrTrack===e.levelOrTrack&&(d.url===e.url||d.deliveryDirectives&&!e.deliveryDirectives)){d.url===e.url?u.log(`[playlist-loader]: ignore ${e.url} ongoing request`):u.log(`[playlist-loader]: ignore ${e.url} in favor of ${d.url}`);return}u.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),o.abort()}let s;if(e.type===Ht.MANIFEST?s=r.manifestLoadPolicy.default:s=yn({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),o=this.createInternalLoader(e),rt((n=e.deliveryDirectives)==null?void 0:n.part)){let u;if(e.type===Ht.LEVEL&&e.level!==null?u=this.hls.levels[e.level].details:e.type===Ht.AUDIO_TRACK&&e.id!==null?u=this.hls.audioTracks[e.id].details:e.type===Ht.SUBTITLE_TRACK&&e.id!==null&&(u=this.hls.subtitleTracks[e.id].details),u){const d=u.partTarget,f=u.targetduration;if(d&&f){const h=Math.max(d*3,f*.8)*1e3;s=yn({},s,{maxTimeToFirstByteMs:Math.min(h,s.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,s.maxTimeToFirstByteMs)})}}}const i=s.errorRetry||s.timeoutRetry||{},a={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:i.maxNumRetry||0,retryDelay:i.retryDelayMs||0,maxRetryDelay:i.maxRetryDelayMs||0},c={onSuccess:(u,d,f,h)=>{const p=this.getInternalLoader(f);this.resetInternalLoader(f.type);const m=u.data;d.parsing.start=performance.now(),qs.isMediaPlaylist(m)||f.type!==Ht.MANIFEST?this.handleTrackOrLevelPlaylist(u,d,f,h||null,p):this.handleMasterPlaylist(u,d,f,h)},onError:(u,d,f,h)=>{this.handleNetworkError(d,f,!1,u,h)},onTimeout:(u,d,f)=>{this.handleNetworkError(d,f,!0,void 0,u)}};o.load(e,a,c)}checkAutostartLoad(){if(!this.hls)return;const{config:{autoStartLoad:e,startPosition:n},forceStartLoad:r}=this.hls;(e||r)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${n}`),this.hls.startLoad(n))}handleMasterPlaylist(e,n,r,o){const s=this.hls,i=e.data,a=L0(e,r),c=qs.parseMasterPlaylist(i,a);if(c.playlistParsingError){n.parsing.end=performance.now(),this.handleManifestParsingError(e,r,c.playlistParsingError,o,n);return}const{contentSteering:u,levels:d,sessionData:f,sessionKeys:h,startTimeOffset:p,variableList:m}=c;this.variableList=m,d.forEach(C=>{const{unknownCodecs:S}=C;if(S){const{preferManagedMediaSource:w}=this.hls.config;let{audioCodec:T,videoCodec:I}=C;for(let P=S.length;P--;){const M=S[P];Od(M,"audio",w)?(C.audioCodec=T=T?`${T},${M}`:M,qc.audio[T.substring(0,4)]=2,S.splice(P,1)):Od(M,"video",w)&&(C.videoCodec=I=I?`${I},${M}`:M,qc.video[I.substring(0,4)]=2,S.splice(P,1))}}});const{AUDIO:g=[],SUBTITLES:y,"CLOSED-CAPTIONS":v}=qs.parseMasterPlaylistMedia(i,a,c);g.length&&!g.some(S=>!S.url)&&d[0].audioCodec&&!d[0].attrs.AUDIO&&(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Vn({}),bitrate:0,url:""})),s.trigger(W.MANIFEST_LOADED,{levels:d,audioTracks:g,subtitles:y,captions:v,contentSteering:u,url:a,stats:n,networkDetails:o,sessionData:f,sessionKeys:h,startTimeOffset:p,variableList:m})}handleTrackOrLevelPlaylist(e,n,r,o,s){const i=this.hls,{id:a,level:c,type:u}=r,d=L0(e,r),f=rt(c)?c:rt(a)?a:0,h=KE(r),p=qs.parseLevelPlaylist(e.data,d,f,h,0,this.variableList);if(u===Ht.MANIFEST){const m={attrs:new Vn({}),bitrate:0,details:p,name:"",url:d};p.requestScheduled=n.loading.start+iM(p,0),i.trigger(W.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:d,stats:n,networkDetails:o,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}n.parsing.end=performance.now(),r.levelDetails=p,this.handlePlaylistLoaded(p,e,n,r,o,s)}handleManifestParsingError(e,n,r,o,s){this.hls.trigger(W.ERROR,{type:pt.NETWORK_ERROR,details:ve.MANIFEST_PARSING_ERROR,fatal:n.type===Ht.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:n,networkDetails:o,stats:s})}handleNetworkError(e,n,r=!1,o,s){let i=`A network ${r?"timeout":"error"+(o?" (status "+o.code+")":"")} occurred while loading ${e.type}`;e.type===Ht.LEVEL?i+=`: ${e.level} id: ${e.id}`:(e.type===Ht.AUDIO_TRACK||e.type===Ht.SUBTITLE_TRACK)&&(i+=` id: ${e.id} group-id: "${e.groupId}"`);const a=new Error(i);this.hls.logger.warn(`[playlist-loader]: ${i}`);let c=ve.UNKNOWN,u=!1;const d=this.getInternalLoader(e);switch(e.type){case Ht.MANIFEST:c=r?ve.MANIFEST_LOAD_TIMEOUT:ve.MANIFEST_LOAD_ERROR,u=!0;break;case Ht.LEVEL:c=r?ve.LEVEL_LOAD_TIMEOUT:ve.LEVEL_LOAD_ERROR,u=!1;break;case Ht.AUDIO_TRACK:c=r?ve.AUDIO_TRACK_LOAD_TIMEOUT:ve.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case Ht.SUBTITLE_TRACK:c=r?ve.SUBTITLE_TRACK_LOAD_TIMEOUT:ve.SUBTITLE_LOAD_ERROR,u=!1;break}d&&this.resetInternalLoader(e.type);const f={type:pt.NETWORK_ERROR,details:c,fatal:u,url:e.url,loader:d,context:e,error:a,networkDetails:n,stats:s};if(o){const h=(n==null?void 0:n.url)||e.url;f.response=un({url:h,data:void 0},o)}this.hls.trigger(W.ERROR,f)}handlePlaylistLoaded(e,n,r,o,s,i){const a=this.hls,{type:c,level:u,levelOrTrack:d,id:f,groupId:h,deliveryDirectives:p}=o,m=L0(n,o),g=KE(o);let y=typeof o.level=="number"&&g===lt.MAIN?u:void 0;const v=e.playlistParsingError;if(v){if(this.hls.logger.warn(`${v} ${e.url}`),!a.config.ignorePlaylistParsingErrors){a.trigger(W.ERROR,{type:pt.NETWORK_ERROR,details:ve.LEVEL_PARSING_ERROR,fatal:!1,url:m,error:v,reason:v.message,response:n,context:o,level:y,parent:g,networkDetails:s,stats:r});return}e.playlistParsingError=null}if(!e.fragments.length){const C=e.playlistParsingError=new Error("No Segments found in Playlist");a.trigger(W.ERROR,{type:pt.NETWORK_ERROR,details:ve.LEVEL_EMPTY_ERROR,fatal:!1,url:m,error:C,reason:C.message,response:n,context:o,level:y,parent:g,networkDetails:s,stats:r});return}switch(e.live&&i&&(i.getCacheAge&&(e.ageHeader=i.getCacheAge()||0),(!i.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),c){case Ht.MANIFEST:case Ht.LEVEL:if(y){if(!d)y=0;else if(d!==a.levels[y]){const C=a.levels.indexOf(d);C>-1&&(y=C)}}a.trigger(W.LEVEL_LOADED,{details:e,levelInfo:d||a.levels[0],level:y||0,id:f||0,stats:r,networkDetails:s,deliveryDirectives:p,withoutMultiVariant:c===Ht.MANIFEST});break;case Ht.AUDIO_TRACK:a.trigger(W.AUDIO_TRACK_LOADED,{details:e,track:d,id:f||0,groupId:h||"",stats:r,networkDetails:s,deliveryDirectives:p});break;case Ht.SUBTITLE_TRACK:a.trigger(W.SUBTITLE_TRACK_LOADED,{details:e,track:d,id:f||0,groupId:h||"",stats:r,networkDetails:s,deliveryDirectives:p});break}}}class Hs{static get version(){return Bd}static isMSESupported(){return sA()}static isSupported(){return IX()}static getMediaSource(){return ba()}static get Events(){return W}static get MetadataSchema(){return yo}static get ErrorTypes(){return pt}static get ErrorDetails(){return ve}static get DefaultConfig(){return Hs.defaultConfig?Hs.defaultConfig:pX}static set DefaultConfig(e){Hs.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Ev,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.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;const n=this.logger=Nz(e.debug||!1,"Hls instance",e.assetPlayerId),r=this.config=gX(Hs.DefaultConfig,e,n);this.userConfig=e,r.progressive&&yX(r,n);const{abrController:o,bufferController:s,capLevelController:i,errorController:a,fpsController:c}=r,u=new a(this),d=this.abrController=new o(this),f=new RW(this),h=r.interstitialsController,p=h?this.interstitialsController=new h(this,Hs):null,m=this.bufferController=new s(this,f),g=this.capLevelController=new i(this),y=new c(this),v=new AX(this),C=r.contentSteeringController,S=C?new C(this):null,w=this.levelController=new EX(this,S),T=new wX(this),I=new MX(this.config,this.logger),P=this.streamController=new DX(this,f,I),M=this.gapController=new CX(this,f);g.setStreamController(P),y.setStreamController(P);const D=[v,w,P];p&&D.splice(1,0,p),S&&D.splice(1,0,S),this.networkControllers=D;const k=[d,m,M,g,y,T,f];this.audioTrackController=this.createController(r.audioTrackController,D);const A=r.audioStreamController;A&&D.push(this.audioStreamController=new A(this,f,I)),this.subtitleTrackController=this.createController(r.subtitleTrackController,D);const E=r.subtitleStreamController;E&&D.push(this.subtititleStreamController=new E(this,f,I)),this.createController(r.timelineController,k),I.emeController=this.emeController=this.createController(r.emeController,k),this.cmcdController=this.createController(r.cmcdController,k),this.latencyController=this.createController(TX,k),this.coreComponents=k,D.push(u);const L=u.onErrorOut;typeof L=="function"&&this.on(W.ERROR,L,u),this.on(W.MANIFEST_LOADED,v.onManifestLoaded,v)}createController(e,n){if(e){const r=new e(this);return n&&n.push(r),r}return null}on(e,n,r=this){this._emitter.on(e,n,r)}once(e,n,r=this){this._emitter.once(e,n,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,n,r=this,o){this._emitter.off(e,n,r,o)}listeners(e){return this._emitter.listeners(e)}emit(e,n,r){return this._emitter.emit(e,n,r)}trigger(e,n){if(this.config.debug)return this.emit(e,e,n);try{return this.emit(e,e,n)}catch(r){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+r.message+'". Here is a stacktrace:',r),!this.triggeringException){this.triggeringException=!0;const o=e===W.ERROR;this.trigger(W.ERROR,{type:pt.OTHER_ERROR,details:ve.INTERNAL_EXCEPTION,fatal:o,event:e,error:r}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){this.logger.log("destroy"),this.trigger(W.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(n=>n.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(n=>n.destroy()),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){if(!e||"media"in e&&!e.media){const s=new Error(`attachMedia failed: invalid argument (${e})`);this.trigger(W.ERROR,{type:pt.OTHER_ERROR,details:ve.ATTACH_MEDIA_ERROR,fatal:!0,error:s});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());const n="media"in e,r=n?e.media:e,o=n?e:{media:r};this._media=r,this.trigger(W.MEDIA_ATTACHING,o)}detachMedia(){this.logger.log("detachMedia"),this.trigger(W.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const e=this.bufferController.transferMedia();return this.trigger(W.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();const n=this.media,r=this._url,o=this._url=pv.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${o}`),n&&r&&(r!==o||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(n)),this.trigger(W.MANIFEST_LOADING,{url:e})}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(e=-1,n){this.logger.log(`startLoad(${e+(n?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(let r=0;r<this.networkControllers.length&&(this.networkControllers[r].startLoad(e,n),!(!this.started||!this.networkControllers));r++);}stopLoad(){this.logger.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!(this.started||!this.networkControllers));e++);}get loadingEnabled(){return this.started}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()}))}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()}))}get inFlightFragments(){const e={[lt.MAIN]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[lt.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[lt.SUBTITLE]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){this.logger.log("recoverMediaError");const e=this._media,n=e==null?void 0:e.currentTime;this.detachMedia(),e&&(this.attachMedia(e),n&&this.startLoad(n))}removeLevel(e){this.levelController.removeLevel(e)}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=CY()),e}get levels(){const e=this.levelController.levels;return e||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){this.logger.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){this.logger.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){this.logger.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 n=!!e;n!==this.config.capLevelToPlayerSize&&(n?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=n)}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 abrEwmaDefaultEstimate(){const{bwEstimator:e}=this.abrController;return e?e.defaultEstimate:NaN}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){gW(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:n}}=this;if(!e)return 0;const r=e.length;for(let o=0;o<r;o++)if(e[o].maxBitrate>=n)return o;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:n,maxHdcpLevel:r}=this;let o;if(n===-1&&e!=null&&e.length?o=e.length-1:o=n,r)for(let s=o;s--;){const i=e[s].attrs["HDCP-LEVEL"];if(i&&i<=r)return s}return o}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()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var n;return((n=this.audioTrackController)==null?void 0:n.setAudioOption(e))||null}setSubtitleOption(e){var n;return((n=this.subtitleTrackController)==null?void 0:n.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 n=this.audioTrackController;n&&(n.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 n=this.subtitleTrackController;n&&(n.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){const n=this.subtitleTrackController;n&&(n.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}set targetLatency(e){this.latencyController.targetLatency=e}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(e){this.levelController.pathwayPriority=e}get bufferedToEnd(){var e;return!!((e=this.bufferController)!=null&&e.bufferedToEnd)}get interstitialsManager(){var e;return((e=this.interstitialsController)==null?void 0:e.interstitialsManager)||null}getMediaDecodingInfo(e,n=this.allAudioTracks){const r=zD(n);return UD(e,r,navigator.mediaCapabilities)}}Hs.defaultConfig=void 0;const ul=(t,e,n,r,o)=>{if(n<=1)return{panX:0,panY:0};const s=r*(1-1/n)/2,i=o*(1-1/n)/2;return{panX:Math.max(-s,Math.min(s,t)),panY:Math.max(-i,Math.min(i,e))}},iA=(t,e)=>{if(t.length===0)return-1;let n=0,r=Math.abs(t[0]-e);for(let o=1;o<t.length;o++){const s=Math.abs(t[o]-e);s<r&&(n=o,r=s)}return n},aA=t=>{const{direction:e,pointerX:n,pointerY:r,zoom:o,panX:s,panY:i,zoomLevels:a,width:c,height:u}=t;if(a.length===0)return null;const d=iA(a,o),f=Math.max(0,Math.min(a.length-1,d+e)),h=a[f];if(h===o)return null;if(h<=1)return{zoom:h,panX:0,panY:0};const p=n-c/2,m=r-u/2,g=1/h-1/o,y=s+p*g,v=i+m*g,C=ul(y,v,h,c,u);return{zoom:h,panX:C.panX,panY:C.panY}},Rm=t=>t.seekable&&t.seekable.length>0?t.seekable.end(t.seekable.length-1):Number.isFinite(t.duration)&&t.duration>0?t.duration:t.currentTime,YE=t=>{if(!Number.isFinite(t)||t<0)return"0:00";const e=Math.floor(t),n=Math.floor(e/3600),r=Math.floor(e%3600/60),o=e%60;return n>0?`${n}:${r.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}`:`${r}:${o.toString().padStart(2,"0")}`},RX=(t,e,n)=>({...t&&{"--player-width":typeof t=="number"?`${t}px`:t},...e&&{"--player-height":typeof e=="number"?`${e}px`:e},...n&&{"--player-aspect-ratio":n}}),Di={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};function lA(t){return"init"in t}function Ey(t){return!!t.write}function XE(t){return"v"in t||"e"in t}function Dp(t){if("e"in t)throw t.e;if((Di?"production":void 0)!=="production"&&!("v"in t))throw new Error("[Bug] atom state is not initialized");return t.v}const Mp=new WeakMap;function cA(t){var e;return Ap(t)&&!!((e=Mp.get(t))!=null&&e[0])}function LX(t){const e=Mp.get(t);e!=null&&e[0]&&(e[0]=!1,e[1].forEach(n=>n()))}function Iy(t,e){let n=Mp.get(t);if(!n){n=[!0,new Set],Mp.set(t,n);const r=()=>{n[0]=!1};t.then(r,r)}n[1].add(e)}function Ap(t){return typeof(t==null?void 0:t.then)=="function"}function uA(t,e,n){if(!n.p.has(t)){n.p.add(t);const r=()=>n.p.delete(t);e.then(r,r)}}function dA(t,e,n){var r;const o=new Set;for(const s of((r=n.get(t))==null?void 0:r.t)||[])o.add(s);for(const s of e.p)o.add(s);return o}const _X=(t,e,...n)=>e.read(...n),OX=(t,e,...n)=>e.write(...n),FX=(t,e)=>{if(e.INTERNAL_onInit)return e.INTERNAL_onInit(t);if(e.unstable_onInit)return console.warn("[DEPRECATED] atom.unstable_onInit is renamed to atom.INTERNAL_onInit."),e.unstable_onInit(t)},NX=(t,e,n)=>{var r;return(r=e.onMount)==null?void 0:r.call(e,n)},BX=(t,e)=>{var n;const r=Or(t),o=r[0],s=r[6],i=r[9];if((Di?"production":void 0)!=="production"&&!e)throw new Error("Atom is undefined or null");let a=o.get(e);return a||(a={d:new Map,p:new Set,n:0},o.set(e,a),(n=s.i)==null||n.call(s,e),i==null||i(t,e)),a},$X=t=>{const e=Or(t),n=e[1],r=e[3],o=e[4],s=e[5],i=e[6],a=e[13],c=[],u=d=>{try{d()}catch(f){c.push(f)}};do{i.f&&u(i.f);const d=new Set,f=d.add.bind(d);r.forEach(h=>{var p;return(p=n.get(h))==null?void 0:p.l.forEach(f)}),r.clear(),s.forEach(f),s.clear(),o.forEach(f),o.clear(),d.forEach(u),r.size&&a(t)}while(r.size||s.size||o.size);if(c.length)throw new AggregateError(c)},jX=t=>{const e=Or(t),n=e[1],r=e[2],o=e[3],s=e[11],i=e[14],a=e[17],c=[],u=new WeakSet,d=new WeakSet,f=Array.from(o);for(;f.length;){const h=f[f.length-1],p=s(t,h);if(d.has(h)){f.pop();continue}if(u.has(h)){if(r.get(h)===p.n)c.push([h,p]);else if((Di?"production":void 0)!=="production"&&r.has(h))throw new Error("[Bug] invalidated atom exists");d.add(h),f.pop();continue}u.add(h);for(const m of dA(h,p,n))u.has(m)||f.push(m)}for(let h=c.length-1;h>=0;--h){const[p,m]=c[h];let g=!1;for(const y of m.d.keys())if(y!==p&&o.has(y)){g=!0;break}g&&(i(t,p),a(t,p)),r.delete(p)}},ky=new WeakSet,VX=(t,e)=>{var n,r;const o=Or(t),s=o[1],i=o[2],a=o[3],c=o[6],u=o[7],d=o[11],f=o[12],h=o[13],p=o[14],m=o[16],g=o[17],y=o[20],v=d(t,e);if(XE(v)){if(s.has(e)&&i.get(e)!==v.n)return v;let D=!1;for(const[k,A]of v.d)if(p(t,k).n!==A){D=!0;break}if(!D)return v}v.d.clear();let C=!0;function S(){s.has(e)&&(g(t,e),h(t),f(t))}function w(D){var k;if(D===e){const E=d(t,D);if(!XE(E))if(lA(D))y(t,D,D.init);else throw new Error("no atom init");return Dp(E)}const A=p(t,D);try{return Dp(A)}finally{v.d.set(D,A.n),cA(v.v)&&uA(e,v.v,A),s.has(e)&&((k=s.get(D))==null||k.t.add(e)),C||S()}}let T,I;const P={get signal(){return T||(T=new AbortController),T.signal},get setSelf(){return(Di?"production":void 0)!=="production"&&!Ey(e)&&console.warn("setSelf function cannot be used with read-only atom"),!I&&Ey(e)&&(I=(...D)=>{if((Di?"production":void 0)!=="production"&&C&&console.warn("setSelf function cannot be called in sync"),!C)try{return m(t,e,...D)}finally{h(t),f(t)}}),I}},M=v.n;try{(Di?"production":void 0)!=="production"&&ky.delete(t);const D=u(t,e,w,P);return(Di?"production":void 0)!=="production"&&ky.has(t)&&console.warn("Detected store mutation during atom read. This is not supported."),y(t,e,D),Ap(D)&&(Iy(D,()=>T==null?void 0:T.abort()),D.then(S,S)),(n=c.r)==null||n.call(c,e),v}catch(D){return delete v.v,v.e=D,++v.n,v}finally{C=!1,M!==v.n&&i.get(e)===M&&(i.set(e,v.n),a.add(e),(r=c.c)==null||r.call(c,e))}},HX=(t,e)=>{const n=Or(t),r=n[1],o=n[2],s=n[11],i=[e];for(;i.length;){const a=i.pop(),c=s(t,a);for(const u of dA(a,c,r)){const d=s(t,u);o.set(u,d.n),i.push(u)}}},UX=(t,e,...n)=>{const r=Or(t),o=r[3],s=r[6],i=r[8],a=r[11],c=r[12],u=r[13],d=r[14],f=r[15],h=r[16],p=r[17],m=r[20];let g=!0;const y=C=>Dp(d(t,C)),v=(C,...S)=>{var w;const T=a(t,C);try{if(C===e){if(!lA(C))throw new Error("atom not writable");(Di?"production":void 0)!=="production"&&ky.add(t);const I=T.n,P=S[0];m(t,C,P),p(t,C),I!==T.n&&(o.add(C),f(t,C),(w=s.c)==null||w.call(s,C));return}else return h(t,C,...S)}finally{g||(u(t),c(t))}};try{return i(t,e,y,v,...n)}finally{g=!1}},GX=(t,e)=>{var n;const r=Or(t),o=r[1],s=r[3],i=r[6],a=r[11],c=r[15],u=r[18],d=r[19],f=a(t,e),h=o.get(e);if(h&&!cA(f.v)){for(const[p,m]of f.d)if(!h.d.has(p)){const g=a(t,p);u(t,p).t.add(e),h.d.add(p),m!==g.n&&(s.add(p),c(t,p),(n=i.c)==null||n.call(i,p))}for(const p of h.d)if(!f.d.has(p)){h.d.delete(p);const m=d(t,p);m==null||m.t.delete(e)}}},zX=(t,e)=>{var n;const r=Or(t),o=r[1],s=r[4],i=r[6],a=r[10],c=r[11],u=r[12],d=r[13],f=r[14],h=r[16],p=r[18],m=c(t,e);let g=o.get(e);if(!g){f(t,e);for(const y of m.d.keys())p(t,y).t.add(e);if(g={l:new Set,d:new Set(m.d.keys()),t:new Set},o.set(e,g),Ey(e)){const y=()=>{let v=!0;const C=(...S)=>{try{return h(t,e,...S)}finally{v||(d(t),u(t))}};try{const S=a(t,e,C);S&&(g.u=()=>{v=!0;try{S()}finally{v=!1}})}finally{v=!1}};s.add(y)}(n=i.m)==null||n.call(i,e)}return g},WX=(t,e)=>{var n,r;const o=Or(t),s=o[1],i=o[5],a=o[6],c=o[11],u=o[19],d=c(t,e);let f=s.get(e);if(!f||f.l.size)return f;let h=!1;for(const p of f.t)if((n=s.get(p))!=null&&n.d.has(e)){h=!0;break}if(!h){f.u&&i.add(f.u),f=void 0,s.delete(e);for(const p of d.d.keys()){const m=u(t,p);m==null||m.t.delete(e)}(r=a.u)==null||r.call(a,e);return}return f},qX=(t,e,n)=>{const r=Or(t)[11],o=r(t,e),s="v"in o,i=o.v;if(Ap(n))for(const a of o.d.keys())uA(e,n,r(t,a));o.v=n,delete o.e,(!s||!Object.is(i,o.v))&&(++o.n,Ap(i)&&LX(i))},KX=(t,e)=>{const n=Or(t)[14];return Dp(n(t,e))},YX=(t,e,...n)=>{const r=Or(t),o=r[12],s=r[13],i=r[16];try{return i(t,e,...n)}finally{s(t),o(t)}},XX=(t,e,n)=>{const r=Or(t),o=r[12],s=r[18],i=r[19],c=s(t,e).l;return c.add(n),o(t),()=>{c.delete(n),i(t,e),o(t)}},fA=new WeakMap,Or=t=>{const e=fA.get(t);if((Di?"production":void 0)!=="production"&&!e)throw new Error("Store must be created by buildStore to read its building blocks");return e};function ZX(...t){const e={get(r){const o=Or(e)[21];return o(e,r)},set(r,...o){const s=Or(e)[22];return s(e,r,...o)},sub(r,o){const s=Or(e)[23];return s(e,r,o)}},n=[new WeakMap,new WeakMap,new WeakMap,new Set,new Set,new Set,{},_X,OX,FX,NX,BX,$X,jX,VX,HX,UX,GX,zX,WX,qX,KX,YX,XX,void 0].map((r,o)=>t[o]||r);return fA.set(e,Object.freeze(n)),e}const hA={};let QX=0;function Bv(t,e){const n=`atom${++QX}`,r={toString(){return(hA?"production":void 0)!=="production"&&this.debugLabel?n+":"+this.debugLabel:n}};return typeof t=="function"?r.read=t:(r.init=t,r.read=JX,r.write=eZ),r}function JX(t){return t(this)}function eZ(t,e,n){return e(this,typeof n=="function"?n(t(this)):n)}function tZ(){return ZX()}let Du;function nZ(){return Du||(Du=tZ(),(hA?"production":void 0)!=="production"&&(globalThis.__JOTAI_DEFAULT_STORE__||(globalThis.__JOTAI_DEFAULT_STORE__=Du),globalThis.__JOTAI_DEFAULT_STORE__!==Du&&console.warn("Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"))),Du}const rZ={},oZ=$.createContext(void 0);function pA(t){return $.useContext(oZ)||nZ()}const Py=t=>typeof(t==null?void 0:t.then)=="function",Dy=t=>{t.status||(t.status="pending",t.then(e=>{t.status="fulfilled",t.value=e},e=>{t.status="rejected",t.reason=e}))},sZ=$.use||(t=>{if(t.status==="pending")throw t;if(t.status==="fulfilled")return t.value;throw t.status==="rejected"?t.reason:(Dy(t),t)}),_0=new WeakMap,ZE=(t,e)=>{let n=_0.get(t);return n||(n=new Promise((r,o)=>{let s=t;const i=u=>d=>{s===u&&r(d)},a=u=>d=>{s===u&&o(d)},c=()=>{try{const u=e();Py(u)?(_0.set(u,n),s=u,u.then(i(u),a(u)),Iy(u,c)):r(u)}catch(u){o(u)}};t.then(i(t),a(t)),Iy(t,c)}),_0.set(t,n)),n};function mA(t,e){const{delay:n,unstable_promiseStatus:r=!$.use}={},o=pA(),[[s,i,a],c]=$.useReducer(d=>{const f=o.get(t);return Object.is(d[0],f)&&d[1]===o&&d[2]===t?d:[f,o,t]},void 0,()=>[o.get(t),o,t]);let u=s;if((i!==o||a!==t)&&(c(),u=o.get(t)),$.useEffect(()=>{const d=o.sub(t,()=>{if(r)try{const f=o.get(t);Py(f)&&Dy(ZE(f,()=>o.get(t)))}catch{}if(typeof n=="number"){setTimeout(c,n);return}c()});return c(),d},[o,t,n,r]),$.useDebugValue(u),Py(u)){const d=ZE(u,()=>o.get(t));return r&&Dy(d),sZ(d)}return u}function iZ(t,e){const n=pA();return $.useCallback((...o)=>{if((rZ?"production":void 0)!=="production"&&!("write"in t))throw new Error("not writable atom");return n.set(t,...o)},[n,t])}function Rp(t,e){return[mA(t),iZ(t)]}const gA=Bv(0),yA=Bv(!0),aZ=Bv(null),bA=$.createContext(null),vA=$.createContext(null),xA=({children:t})=>{const e=$.useRef(null),[n,r]=Rp(gA),[o,s]=Rp(yA),[i,a]=$.useState(!1),[c,u]=$.useState(0),[d,f]=$.useState(!1),h=$.useRef(i);h.current=i,$.useEffect(()=>{const I=e.current;if(!I)return;const P=()=>{if(I.seekable&&I.seekable.length>0){const k=I.seekable.end(I.seekable.length-1);u(k),f(k>0)}else I.duration&&isFinite(I.duration)&&(u(I.duration),f(!0))},M=()=>a(!0),D=()=>a(!1);return I.addEventListener("durationchange",P),I.addEventListener("loadedmetadata",P),I.addEventListener("play",M),I.addEventListener("pause",D),P(),()=>{I.removeEventListener("durationchange",P),I.removeEventListener("loadedmetadata",P),I.removeEventListener("play",M),I.removeEventListener("pause",D)}},[]);const p=$.useCallback(I=>{r(I)},[r]),m=$.useCallback(I=>{s(I)},[s]),g=$.useRef(d);g.current=d;const y=$.useCallback(I=>{const P=e.current;!P||!g.current||(P.currentTime=I,r(I),s(!1))},[r,s]),v=$.useCallback(async()=>{const I=e.current;if(I)try{await I.play(),a(!0)}catch(P){console.error("Failed to play video:",P)}},[]),C=$.useCallback(()=>{const I=e.current;I&&(I.pause(),a(!1))},[]),S=$.useCallback(()=>{h.current?C():v()},[v,C]),w=$.useMemo(()=>({videoRef:e,setCurrentTime:p,setIsLive:m,seekTo:y,play:v,pause:C,togglePlay:S}),[p,m,y,v,C,S]),T=$.useMemo(()=>({currentTime:n,isLive:o,isPlaying:i,duration:c,canSeek:d}),[n,o,i,c,d]);return b.jsx(bA.Provider,{value:w,children:b.jsx(vA.Provider,{value:T,children:t})})},Lm=()=>{const t=$.useContext(bA),e=$.useContext(vA);return $.useMemo(()=>!t||!e?null:{...t,...e},[t,e])},lZ=()=>{const t=Lm();if(!t)throw new Error("useVideoControlRequired must be used within a VideoControlProvider. Wrap your VideoPlayer and VideoTimeline with <VideoControlProvider>.");return t};function cZ(t){return/\.m3u8(\?|$)/i.test(t)}function uZ(t,e){if(t===e)return!0;if(!t||!e)return!1;const n=t.getTracks().map(o=>o.id).sort(),r=e.getTracks().map(o=>o.id).sort();return n.length===r.length&&n.every((o,s)=>o===r[s])}const dZ=({stream:t,availableQualities:e,initialQuality:n,autoPlay:r,liveThresholdSeconds:o,allowPlaybackRateForStream:s})=>{const i=$.useRef(null),a=Lm(),c=$.useRef(null),u=$.useCallback(oe=>{c.current=oe,a!=null&&a.videoRef&&(a.videoRef.current=oe)},[a]),d=$.useMemo(()=>{if(!e||!e.length)return null;if(n){const oe=e.find(ce=>ce.value===n);if(oe)return oe}return e[0]},[e,n]),[f,h]=$.useState(d),[p,m]=$.useState(!1),[g,y]=$.useState(!0),[v,C]=$.useState(!1),[S,w]=$.useState(0),[T,I]=$.useState(0),[P,M]=$.useState(1),[D,k]=$.useState(1),[A,E]=$.useState(0),[L,O]=$.useState(0),_=$.useRef(!1),R=$.useRef({x:0,y:0}),B=$.useRef({x:0,y:0}),j=$.useRef(!1),[U,V]=$.useState(!1),[F,H]=$.useState(!0),[z,q]=$.useState(!1),[K,Y]=$.useState(!1),J=$.useRef(null),X=(f==null?void 0:f.stream)??t??null,ee=(f==null?void 0:f.src)??null,te=!!!X||s,ne=$.useCallback(()=>{const oe=c.current;m(!!(oe&&!oe.paused&&!oe.ended))},[]);$.useEffect(()=>{h(d)},[d]);const se=$.useRef(!1),ae=$.useRef({seekableEnd:0,currentTime:0,canSeek:!1,isLive:!0}),pe=$.useCallback(()=>{const oe=c.current;if(!oe)return;if(!oe.seekable||oe.seekable.length===0){y(!0),C(!1),a&&a.setIsLive(!0);return}const ce=Rm(oe),ie=Math.max(0,ce-oe.currentTime);ae.current={seekableEnd:ce,currentTime:oe.currentTime,canSeek:ce>0,isLive:ie<=(o??2)},se.current||(se.current=!0,requestAnimationFrame(()=>{se.current=!1;const ge=ae.current;I(ge.seekableEnd),w(ge.currentTime),C(ge.canSeek),y(ge.isLive),a&&(a.setCurrentTime(ge.currentTime),a.setIsLive(ge.isLive))}))},[o,a]);return $.useEffect(()=>{const oe=c.current;if(!oe)return;const ce=()=>ne(),ie=()=>ne(),ge=()=>H(!0),he=()=>H(!0),Z=()=>H(!1),Q=()=>{H(!1),ne()},de=()=>q(!0),ue=()=>q(!1),fe=()=>ne(),me=()=>{Y(!0),H(!1),ne()};return oe.addEventListener("play",ce),oe.addEventListener("pause",ie),oe.addEventListener("ended",fe),oe.addEventListener("emptied",fe),oe.addEventListener("waiting",ge),oe.addEventListener("loadstart",he),oe.addEventListener("canplay",Z),oe.addEventListener("playing",Q),oe.addEventListener("seeking",de),oe.addEventListener("seeked",ue),oe.addEventListener("error",me),oe.addEventListener("timeupdate",pe),oe.addEventListener("durationchange",pe),oe.addEventListener("loadedmetadata",pe),oe.addEventListener("progress",pe),()=>{oe.removeEventListener("play",ce),oe.removeEventListener("pause",ie),oe.removeEventListener("ended",fe),oe.removeEventListener("emptied",fe),oe.removeEventListener("waiting",ge),oe.removeEventListener("loadstart",he),oe.removeEventListener("canplay",Z),oe.removeEventListener("playing",Q),oe.removeEventListener("seeking",de),oe.removeEventListener("seeked",ue),oe.removeEventListener("error",me),oe.removeEventListener("timeupdate",pe),oe.removeEventListener("durationchange",pe),oe.removeEventListener("loadedmetadata",pe),oe.removeEventListener("progress",pe)}},[ne,pe]),$.useEffect(()=>{const oe=c.current;if(oe){if(J.current&&(J.current.destroy(),J.current=null),H(!0),Y(!1),m(!1),X)uZ(oe.srcObject,X)||(oe.srcObject=X),oe.getAttribute("src")&&oe.removeAttribute("src");else if(ee)if(oe.srcObject&&(oe.srcObject=null),cZ(ee)&&Hs.isSupported()){const ce=new Hs({manifestLoadingRetryDelay:2e3,manifestLoadingMaxRetry:10,levelLoadingRetryDelay:2e3,levelLoadingMaxRetry:10,fragLoadingRetryDelay:2e3,fragLoadingMaxRetry:10});J.current=ce,ce.on(Hs.Events.ERROR,(ie,ge)=>{ge.fatal&&(Y(!0),H(!1),ce.destroy(),J.current=null)}),ce.loadSource(ee),ce.attachMedia(oe)}else oe.src!==ee&&(oe.src=ee,oe.load());else oe.srcObject&&(oe.srcObject=null),oe.getAttribute("src")&&oe.removeAttribute("src");return r&&oe.play().then(()=>ne()).catch(()=>ne()),()=>{J.current&&(J.current.destroy(),J.current=null)}}},[X,ee,r,ne]),$.useEffect(()=>{const oe=c.current;oe&&(te?oe.playbackRate=P:(oe.playbackRate=1,M(1)))},[P,te]),$.useEffect(()=>{D<=1&&(E(0),O(0))},[D]),$.useEffect(()=>{const oe=()=>{V(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",oe),()=>{document.removeEventListener("fullscreenchange",oe)}},[]),$.useEffect(()=>{if(D<=1)return;const oe=i.current;if(!oe)return;const ce=requestAnimationFrame(()=>{const ie=oe.getBoundingClientRect(),ge=ul(A,L,D,ie.width,ie.height);E(ge.panX),O(ge.panY)});return()=>cancelAnimationFrame(ce)},[U]),{containerRef:i,videoRef:c,setVideoRef:u,selectedQuality:f,setSelectedQuality:h,isPlaying:p,isLive:g,canSeek:v,currentTime:S,setCurrentTime:w,seekableEnd:T,playbackRate:P,setPlaybackRate:M,zoom:D,setZoom:k,panX:A,setPanX:E,panY:L,setPanY:O,isDraggingRef:_,dragStartRef:R,panStartRef:B,didDragRef:j,isFullscreen:U,isLoading:F,isSeeking:z,hasError:K,canAdjustPlaybackRate:te,updateLiveStatus:pe,syncPlaybackState:ne}},fZ=60;function CA({targetRef:t,zoomLevels:e,zoom:n,panX:r,panY:o,onChange:s,enabled:i=!0}){const a=$.useRef(n),c=$.useRef(r),u=$.useRef(o),d=$.useRef(e),f=$.useRef(s),h=$.useRef(0);a.current=n,c.current=r,u.current=o,d.current=e,f.current=s,$.useEffect(()=>{const p=t.current;if(!p||!i)return;const m=g=>{const y=p.getBoundingClientRect(),v=aA({direction:g.deltaY<0?1:-1,pointerX:g.clientX-y.left,pointerY:g.clientY-y.top,zoom:a.current,panX:c.current,panY:u.current,zoomLevels:d.current,width:y.width,height:y.height});if(!v)return;g.preventDefault();const C=performance.now();C-h.current<fZ||(h.current=C,f.current(v))};return p.addEventListener("wheel",m,{passive:!1}),()=>p.removeEventListener("wheel",m)},[t,i])}const hZ=6,pZ=(t,e,n,r=hZ)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return{zoom:1,panX:0,panY:0};const o=Math.min(e/t.width,n/t.height),s=Math.max(1,Math.min(r,o));if(s<=1)return{zoom:1,panX:0,panY:0};const i=t.x+t.width/2,a=t.y+t.height/2,c=i-e/2,u=a-n/2,d=ul(-c,-u,s,e,n);return{zoom:s,panX:d.panX,panY:d.panY}},QE=8,mZ=({enabled:t,containerRef:e,videoRef:n,isLive:r,zoomRef:o,applyZoom:s})=>{const[i,a]=$.useState(null),c=$.useRef(!1),u=$.useRef(!1),d=$.useRef({x:0,y:0}),f=$.useRef(!1),h=$.useCallback(S=>{const w=e.current;if(!w)return null;const T=w.getBoundingClientRect();return{x:S.clientX-T.left,y:S.clientY-T.top,width:T.width,height:T.height}},[e]),p=$.useCallback(()=>{if(r||!f.current)return;f.current=!1;const S=n.current;S&&S.play().catch(()=>{})},[r,n]),m=$.useCallback(S=>{if(!t||S.button!==0||(o.current??1)>1)return!1;const w=h(S);return w?(c.current=!0,u.current=!1,f.current=!1,d.current={x:w.x,y:w.y},a({x:w.x,y:w.y,width:0,height:0}),!0):!1},[t,h,o]),g=$.useCallback(S=>{if(!c.current)return!1;const w=h(S);if(!w)return!0;const T=d.current.x,I=d.current.y,P=w.x-T,M=w.y-I;if(!u.current&&(Math.abs(P)>QE||Math.abs(M)>QE)&&(u.current=!0,!r)){const D=n.current;D&&(f.current=!D.paused,D.pause())}return a({x:Math.min(T,w.x),y:Math.min(I,w.y),width:Math.abs(P),height:Math.abs(M)}),!0},[h,r,n]),y=$.useCallback(S=>{if(!c.current)return!1;c.current=!1;const w=u.current;u.current=!1;const T=h(S);if(a(null),!w)return!1;if(T){const I=d.current.x,P=d.current.y,M={x:Math.min(I,T.x),y:Math.min(P,T.y),width:Math.abs(T.x-I),height:Math.abs(T.y-P)};s(pZ(M,T.width,T.height))}return p(),!0},[s,h,p]),v=$.useCallback(()=>c.current?(c.current=!1,u.current=!1,a(null),p(),!0):!1,[p]),C=$.useCallback(()=>{t&&s({zoom:1,panX:0,panY:0})},[s,t]);return{selectionRect:i,handleMouseDown:m,handleMouseMove:g,handleMouseUp:y,handleMouseLeave:v,handleDoubleClick:C}},gZ="_container_1x6ev_1",yZ="_loader_1x6ev_78",bZ="_loaderInitial_1x6ev_89",vZ="_spinner_1x6ev_93",xZ="_video_1x6ev_116",CZ="_videoZoomed_1x6ev_124",SZ="_videoAreaZooming_1x6ev_128",wZ="_areaSelection_1x6ev_132",TZ="_timestampOverlay_1x6ev_142",EZ="_timestampText_1x6ev_155",IZ="_badgeFloating_1x6ev_167",kZ="_controlsOverlay_1x6ev_174",PZ="_controlsVisible_1x6ev_198",DZ="_timeline_1x6ev_203",MZ="_controlsRow_1x6ev_210",AZ="_controlGroup_1x6ev_228",RZ="_iconButton_1x6ev_245",LZ="_menuButton_1x6ev_296",_Z="_liveBadge_1x6ev_306",OZ="_liveBadgeInactive_1x6ev_324",FZ="_liveBadgeActive_1x6ev_334",NZ="_recordingDot_1x6ev_363",BZ="_goLiveButton_1x6ev_379",$Z="_emptyState_1x6ev_397",jZ="_emptyStateText_1x6ev_414",VZ="_controlMenuWrapper_1x6ev_420",HZ="_zoomControl_1x6ev_438",UZ="_zoomValue_1x6ev_445",GZ="_playbackTime_1x6ev_452",zZ="_watermarkOverlay_1x6ev_470",WZ="_watermarkImage_1x6ev_479",At={container:gZ,loader:yZ,loaderInitial:bZ,spinner:vZ,video:xZ,videoZoomed:CZ,videoAreaZooming:SZ,areaSelection:wZ,timestampOverlay:TZ,timestampText:EZ,badgeFloating:IZ,controlsOverlay:kZ,controlsVisible:PZ,timeline:DZ,controlsRow:MZ,controlGroup:AZ,iconButton:RZ,menuButton:LZ,liveBadge:_Z,liveBadgeInactive:OZ,liveBadgeActive:FZ,recordingDot:NZ,goLiveButton:BZ,emptyState:$Z,emptyStateText:jZ,controlMenuWrapper:VZ,zoomControl:HZ,zoomValue:UZ,playbackTime:GZ,watermarkOverlay:zZ,watermarkImage:WZ},qZ=({icon:t,label:e,valueLabel:n,selectedValue:r,options:o,onChange:s,disabled:i,ariaLabel:a})=>{const[c,u]=$.useState(null),d=!!c;return b.jsxs(b.Fragment,{children:[b.jsxs(G.ButtonBase,{disabled:i,className:`${At.menuButton} ${At.controlMenuWrapper}`,"aria-label":a,onClick:f=>u(f.currentTarget),children:[t,e?`${e}: ${n}`:n]}),b.jsx(G.Menu,{anchorEl:c,open:d,onClose:()=>u(null),children:o.map(f=>b.jsx(G.MenuItem,{selected:f.value===r,disabled:f.disabled,onClick:()=>{s(f.value),u(null)},children:f.label},`${e}-${String(f.value)}`))})]})},KZ=$.memo(qZ),YZ=["Dom","Seg","Ter","Qua","Qui","Sex","Sab"];function XZ(){const t=new Date,e=String(t.getDate()).padStart(2,"0"),n=String(t.getMonth()+1).padStart(2,"0"),r=t.getFullYear(),o=YZ[t.getDay()],s=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0"),a=String(t.getSeconds()).padStart(2,"0");return`${e}-${n}-${r}, ${o} ${s}:${i}:${a}`}const SA=$.memo(({show:t})=>{const[e,n]=$.useState("");return $.useEffect(()=>{if(!t)return;const r=()=>n(XZ());r();const o=setInterval(r,1e3);return()=>clearInterval(o)},[t]),!t||!e?null:b.jsx("div",{className:At.timestampOverlay,children:b.jsx("span",{className:At.timestampText,children:e})})});SA.displayName="Timestamp";const ZZ=(t,e)=>()=>{const n=t.current;n&&(n.paused?(n.play().then(()=>e==null?void 0:e()).catch(()=>e==null?void 0:e()),e==null||e()):(n.pause(),e==null||e()))},QZ=(t,e,n)=>r=>{const o=t.current;if(!o||!e)return;const s=Rm(o),i=Math.min(Math.max(o.currentTime+r,0),s);o.currentTime=i,n()},JZ=(t,e,n)=>()=>{const r=t.current;if(!r||!e)return;const o=Rm(r);r.currentTime=Math.max(o-.1,0),n()},eQ=t=>()=>{t.current&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):t.current.requestFullscreen().catch(()=>{}))},tQ=(t,e,n)=>r=>{const o=t.find(s=>s.value===r)??null;e(o),n==null||n(o)},nQ=t=>{const{width:e=20,height:n=20,...r}=t;return b.jsx("svg",{width:e,height:n,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r,children:b.jsx("path",{d:"M10.4167 2.5C14.2917 2.5 17.5667 5.025 18.725 8.51667L16.75 9.16667C15.875 6.50833 13.3667 4.58333 10.4167 4.58333C8.78333 4.58333 7.30833 5.18333 6.15 6.15L8.33333 8.33333H2.5V2.5L4.66667 4.66667C6.20833 3.33333 8.20833 2.5 10.4167 2.5ZM8.33333 10V18.3333H6.66667V11.6667H5V10H8.33333ZM10 10H15V11.6667H11.6667V13.3333H13.3333C14.2583 13.3333 15 14.0833 15 15V16.6667C15 17.5917 14.2583 18.3333 13.3333 18.3333H10V16.6667H13.3333V15H10V10Z",fill:"currentColor"})})},rQ=t=>{const{width:e=20,height:n=20,...r}=t;return b.jsx("svg",{width:e,height:n,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r,children:b.jsx("path",{d:"M9.58336 2.5C11.7917 2.5 13.7917 3.33333 15.3334 4.66667L17.5 2.5V8.33333H11.6667L13.85 6.15C12.6917 5.18333 11.2167 4.58333 9.58336 4.58333C6.63336 4.58333 4.12502 6.50833 3.25002 9.16667L1.27502 8.51667C2.43336 5.025 5.70836 2.5 9.58336 2.5ZM8.33336 10V18.3333H6.66669V11.6667H5.00002V10H8.33336ZM10 10H15V11.6667H11.6667V13.3333H13.3334C14.2584 13.3333 15 14.0833 15 15V16.6667C15 17.5917 14.2584 18.3333 13.3334 18.3333H10V16.6667H13.3334V15H10V10Z",fill:"currentColor"})})},oQ={color:"#C8E642","& .MuiSlider-thumb":{width:12,height:12,backgroundColor:"#fff"},"& .MuiSlider-track":{border:"none",backgroundColor:"#C8E642"},"& .MuiSlider-rail":{backgroundColor:"#424242",opacity:1}},$v=({stream:t=null,availableQualities:e=[],initialQuality:n,onQualityChange:r,autoPlay:o=!0,playsInline:s=!0,muted:i=!0,poster:a,className:c,sx:u,liveThresholdSeconds:d=2,allowPlaybackRateForStream:f=!1,playbackRates:h=[.5,1,1.5,2],zoomLevels:p=[1,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3],width:m,height:g,aspectRatio:y="16 / 9",showTimestamp:v=!1,showTimeline:C=!0,isRecording:S=!1,recordingLabel:w="Gravação",onGoLive:T,borderRadius:I,loading:P,unavailable:M=!1,unavailableIcon:D,unavailableMessage:k="O vídeo não está disponível.",showSeekButtons:A=!1,showPlaybackRate:E=!1,noControl:L=!1,noBorderRadius:O=!1,showLiveButton:_=!0,showWatermark:R=!0,startTimeSeconds:B,preload:j="auto",enableWheelZoom:U=!1,enableAreaZoom:V=!1})=>{const H=ye.useTheme().palette.mode==="dark",[z,q]=$.useState(!0),K=$.useRef(!0),Y=$.useRef(null);K.current=z;const{containerRef:J,videoRef:X,setVideoRef:ee,selectedQuality:re,setSelectedQuality:te,isPlaying:ne,isLive:se,canSeek:ae,currentTime:pe,setCurrentTime:oe,seekableEnd:ce,playbackRate:ie,setPlaybackRate:ge,zoom:he,setZoom:Z,panX:Q,setPanX:de,panY:ue,setPanY:fe,isDraggingRef:me,dragStartRef:Ce,panStartRef:Oe,didDragRef:Ie,isFullscreen:Se,isLoading:xe,isSeeking:Ne,canAdjustPlaybackRate:st,updateLiveStatus:Je,syncPlaybackState:He}=dZ({stream:t,availableQualities:e,initialQuality:n,autoPlay:o,liveThresholdSeconds:d,allowPlaybackRateForStream:f}),at=$.useRef({width:0,height:0});$.useEffect(()=>{const ze=J.current;if(!ze)return;const St=new ResizeObserver(([Qt])=>{at.current={width:Qt.contentRect.width,height:Qt.contentRect.height}});return St.observe(ze),()=>St.disconnect()},[J]),$.useEffect(()=>{const ze=J.current;if(!ze)return;const St=()=>{Y.current&&(clearTimeout(Y.current),Y.current=null),q(!0)},Qt=()=>{Y.current=setTimeout(()=>{},1e4)},tr=()=>{K.current||q(!0),Y.current&&clearTimeout(Y.current),Y.current=setTimeout(()=>{},1e4)};return ze.addEventListener("mouseenter",St),ze.addEventListener("mouseleave",Qt),ze.addEventListener("mousemove",tr),()=>{ze.removeEventListener("mouseenter",St),ze.removeEventListener("mouseleave",Qt),ze.removeEventListener("mousemove",tr),Y.current&&clearTimeout(Y.current)}},[]);const[We,mt]=$.useState(!1),wt=$.useRef(!1),Xe=(re==null?void 0:re.src)??(re==null?void 0:re.value)??null;$.useEffect(()=>{mt(!1),wt.current=!1},[Xe]),$.useEffect(()=>{const ze=X.current;if(!ze)return;const St=()=>mt(!0);return ze.addEventListener("play",St),()=>{ze.removeEventListener("play",St)}},[X]);const ft=$.useMemo(()=>ZZ(X,He),[He,X]),Ee=$.useCallback(()=>{const ze=X.current;if(ze&&ze.paused&&(We||mt(!0),B&&B>0&&!wt.current)){const St=Number.isFinite(ze.duration)?ze.duration:0,Qt=St>0?Math.min(B,Math.max(St-.1,0)):B;ze.currentTime<Qt&&(ze.currentTime=Qt),wt.current=!0}ft()},[ft,We,B,X]),Ge=$.useMemo(()=>QZ(X,ae,Je),[X,ae,Je]),Qe=$.useMemo(()=>JZ(X,ae,Je),[X,ae,Je]),tt=$.useMemo(()=>eQ(J),[J]);$.useMemo(()=>tQ(e,te,r),[e,te,r]);const Yt=$.useRef({wasPlaying:!1,active:!1}),[Ke,Mt]=$.useState(!1);$.useEffect(()=>{const ze=X.current;if(!ze||!Ke)return;const St=()=>Mt(!1);ze.addEventListener("playing",St),ze.addEventListener("canplay",St);const Qt=window.setTimeout(St,4e3);return()=>{ze.removeEventListener("playing",St),ze.removeEventListener("canplay",St),window.clearTimeout(Qt)}},[Ke,X]);const Ue=$.useCallback((ze,St)=>{if(!ae)return;const Qt=Array.isArray(St)?St[0]:St,tr=X.current;!Yt.current.active&&tr&&(Yt.current.active=!0,Yt.current.wasPlaying=!tr.paused,tr.paused||tr.pause(),Mt(!0)),oe(Qt),tr&&(tr.currentTime=Qt)},[ae,oe,X]),it=$.useCallback((ze,St)=>{const Qt=X.current;if(!Qt||!ae){Yt.current.active=!1;return}const tr=Array.isArray(St)?St[0]:St,Da=Rm(Qt);Qt.currentTime=Math.min(Math.max(tr,0),Da);const jl=Yt.current.wasPlaying;Yt.current.active=!1,Yt.current.wasPlaying=!1,jl&&Qt.play().catch(()=>{}),Je()},[ae,Je,X]),Ct=$.useRef(Q),Lt=$.useRef(ue);Ct.current=Q,Lt.current=ue;const _t=$.useRef(he);_t.current=he;const mr=$.useCallback(ze=>{if(Z(ze),ze<=1)de(0),fe(0);else{const{width:St,height:Qt}=at.current;if(St&&Qt){const tr=ul(Ct.current,Lt.current,ze,St,Qt);de(tr.panX),fe(tr.panY)}}},[Z,de,fe]),Zr=$.useCallback(ze=>{const St=p.indexOf(he),Qt=Math.max(0,Math.min(p.length-1,St+ze));mr(p[Qt])},[he,p,mr]),[ao,ui]=$.useState(!1),Mr=$.useRef(null);CA({targetRef:J,zoomLevels:p,zoom:he,panX:Q,panY:ue,enabled:U&&!V,onChange:({zoom:ze,panX:St,panY:Qt})=>{Z(ze),de(St),fe(Qt)}});const Qn=$.useCallback(ze=>{ui(!0),Z(ze.zoom),de(ze.panX),fe(ze.panY),Mr.current&&clearTimeout(Mr.current),Mr.current=setTimeout(()=>{ui(!1),Mr.current=null},360)},[Z,de,fe]),Zt=mZ({enabled:V,containerRef:J,videoRef:X,isLive:se,zoomRef:_t,applyZoom:Qn});$.useEffect(()=>()=>{Mr.current&&clearTimeout(Mr.current)},[]);const ts=$.useCallback(ze=>{Ie.current=!1,!(_t.current<=1)&&(ze.preventDefault(),me.current=!0,Ce.current={x:ze.clientX,y:ze.clientY},Oe.current={x:Ct.current,y:Lt.current})},[me,Ie,Ce,Oe]),$l=$.useCallback(()=>{const ze=Ie.current;me.current=!1,Ie.current=!1,!ze&&!L&&Ee()},[me,Ie,Ee,L]),$i=$.useCallback(ze=>{if(!me.current||_t.current<=1)return;ze.preventDefault();const St=ze.clientX-Ce.current.x,Qt=ze.clientY-Ce.current.y;(Math.abs(St)>3||Math.abs(Qt)>3)&&(Ie.current=!0);const{width:tr,height:Da}=at.current;if(!tr||!Da)return;const jl=Oe.current.x+St/_t.current,_g=Oe.current.y+Qt/_t.current,Uf=ul(jl,_g,_t.current,tr,Da);de(Uf.panX),fe(Uf.panY)},[me,Ce,Oe,Ie,de,fe]),Pa=$.useCallback(()=>{me.current=!1},[me]),Re=$.useCallback(ze=>{Zt.handleMouseDown(ze)||ts(ze)},[Zt,ts]),De=$.useCallback(ze=>{Zt.handleMouseMove(ze)||$i(ze)},[Zt,$i]),Ze=$.useCallback(ze=>{Zt.handleMouseUp(ze)||$l()},[Zt,$l]),vt=$.useCallback(()=>{Zt.handleMouseLeave()||Pa()},[Zt,Pa]),Tt=$.useCallback(ze=>{if(_t.current<=1||ze.touches.length!==1)return;const St=ze.touches[0];me.current=!0,Ie.current=!1,Ce.current={x:St.clientX,y:St.clientY},Oe.current={x:Ct.current,y:Lt.current}},[me,Ie,Ce,Oe]),Tn=$.useCallback(ze=>{if(!me.current||_t.current<=1||ze.touches.length!==1)return;const St=ze.touches[0],Qt=St.clientX-Ce.current.x,tr=St.clientY-Ce.current.y;(Math.abs(Qt)>3||Math.abs(tr)>3)&&(Ie.current=!0);const{width:Da,height:jl}=at.current;if(!Da||!jl)return;const _g=Oe.current.x+Qt/_t.current,Uf=Oe.current.y+tr/_t.current,CS=ul(_g,Uf,_t.current,Da,jl);de(CS.panX),fe(CS.panY)},[me,Ce,Oe,Ie,de,fe]),jn=$.useCallback(()=>{me.current=!1},[me]);$.useEffect(()=>{const ze=X.current;if(!ze)return;const St=Qt=>{_t.current>1&&me.current&&Qt.preventDefault()};return ze.addEventListener("touchmove",St,{passive:!1}),()=>{ze.removeEventListener("touchmove",St)}},[X,me]);const Ar=$.useMemo(()=>h.map(ze=>({value:ze,label:`${ze}x`})),[h]);$.useMemo(()=>e.map(ze=>({value:ze.value,label:ze.label})),[e]),re==null||re.label;const ji=`${Math.round(he*100)}%`,Hf=`${ie}x`,di=ae&&ce>0,Vi=RX(m,g,y),Xt=O?{...Vi,"--vp-radius":"0px"}:I!=null?{...Vi,"--vp-radius":typeof I=="number"?`${I}px`:I}:Vi,Ps=$.useMemo(()=>{const ze=he>1||ao;return{transform:ze?`scale(${he}) translate3d(${Q}px, ${ue}px, 0)`:void 0,willChange:ze?"transform":void 0}},[he,Q,ue,ao]);return b.jsx(G.Box,{ref:J,className:`${At.container} ${c||""}`.trim(),"data-theme":H?"dark":"light",style:Xt,sx:u,children:M?b.jsxs("div",{className:At.emptyState,children:[D??b.jsx(PD,{}),typeof k=="string"?b.jsx(G.Typography,{className:At.emptyStateText,children:k}):k]}):b.jsxs(b.Fragment,{children:[(P||xe&&We&&!Ne&&!Ke)&&b.jsx("div",{className:`${At.loader} ${a?"":At.loaderInitial}`.trim(),children:b.jsx("span",{className:At.spinner})}),b.jsx("video",{ref:ee,className:`${At.video} ${he>1?At.videoZoomed:""} ${ao?At.videoAreaZooming:""}`.trim(),autoPlay:o,playsInline:s,muted:i,poster:a,preload:j,style:Ps,onMouseDown:Re,onMouseMove:De,onMouseUp:Ze,onMouseLeave:vt,onDoubleClick:Zt.handleDoubleClick,onTouchStart:Tt,onTouchMove:Tn,onTouchEnd:jn}),Zt.selectionRect&&b.jsx("div",{className:At.areaSelection,style:{left:`${Zt.selectionRect.x}px`,top:`${Zt.selectionRect.y}px`,width:`${Zt.selectionRect.width}px`,height:`${Zt.selectionRect.height}px`}}),b.jsx(SA,{show:v}),R&&b.jsx("div",{className:At.watermarkOverlay,children:b.jsxs("svg",{className:At.watermarkImage,viewBox:"0 0 98 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M9.97803 15.3143C9.97803 15.9818 9.9994 16.6048 10.0648 17.1789H15.4093C16.3864 17.1789 17.1786 16.3867 17.1786 15.4096V10.0119C16.7309 9.94473 16.2429 9.91052 15.711 9.91052C10.9705 9.91052 9.97803 11.7427 9.97803 15.3143Z",fill:"white"}),b.jsx("path",{d:"M15.7111 7.24518C16.2192 7.24518 16.7078 7.27572 17.1787 7.33435V2.32267C17.1787 1.04014 16.1386 6.10352e-05 14.8561 6.10352e-05H2.32262C1.03947 6.10352e-05 0 1.04014 0 2.32267V15.4094C0 16.3866 0.79212 17.1787 1.76929 17.1787H7.2097C7.13763 16.67 7.09793 16.1362 7.09793 15.575C7.09793 10.1944 10.5431 7.24518 15.7111 7.24518Z",fill:"white"}),b.jsx("path",{d:"M17.1785 7.33435V10.0118C20.1381 10.4546 21.3046 12.3521 21.3046 15.5988C21.3046 19.2778 20.808 21.3378 15.7109 21.3378C11.5402 21.3378 10.3572 19.764 10.0646 17.1794H7.20947C7.83364 21.5724 11.0748 24 15.6638 24C20.8319 24 24.1286 21.0502 24.1286 15.6702C24.1286 10.7813 21.4524 7.86569 17.1791 7.33496L17.1785 7.33435Z",fill:"white"}),b.jsx("path",{d:"M48.2628 1.92908L40.6787 22.0741H37.713L30.1289 1.92908L32.4894 1.92725L39.1958 19.7112L45.9017 1.92725L48.2622 1.92908H48.2628Z",fill:"white"}),b.jsx("path",{d:"M49.8848 22.0692V1.92236H52.1121V22.0692H49.8848Z",fill:"white"}),b.jsx("path",{d:"M70.1892 16.5256C70.1892 19.1493 68.1713 22.4784 62.2711 22.4784C57.0188 22.4784 54.3413 19.0284 54.3413 16.0828H56.5564C56.5564 18.2106 58.7557 20.4434 62.4964 20.4434C66.5028 20.4434 67.9875 18.4018 67.9875 16.2905C67.9875 10.6094 54.902 15.0568 54.902 6.83571C54.902 3.87427 57.5086 1.52173 62.1581 1.52173C66.5163 1.52173 69.2163 3.99581 69.2157 7.45805H66.9981C66.9981 5.23804 65.183 3.57074 62.1581 3.57074C59.1331 3.57074 57.1226 4.71891 57.1226 6.91694C57.1226 12.8869 70.1898 8.39796 70.1898 16.525L70.1892 16.5256Z",fill:"white"}),b.jsx("path",{d:"M72.4399 22.0692V1.92236H74.6673V22.0692H72.4399Z",fill:"white"}),b.jsx("path",{d:"M97.5617 11.9995C97.5617 19.7246 92.2452 22.4772 87.2696 22.4772C81.0175 22.4772 76.9775 18.3645 76.9775 11.9995C76.9775 8.75463 78.0311 6.0497 80.0245 4.1772C81.8475 2.46531 84.4199 1.52173 87.2696 1.52173C93.5223 1.52173 97.5623 5.53485 97.5617 11.9995ZM95.3441 11.9995C95.3441 5.72479 91.232 3.56463 87.2696 3.56463C83.3072 3.56463 79.1951 5.95565 79.1951 11.9995C79.1951 18.0433 83.3072 20.4343 87.2696 20.4343C92.3246 20.4343 95.3441 17.3941 95.3441 11.9995Z",fill:"white"})]})}),!L&&se&&!S&&!z&&b.jsx("div",{className:At.badgeFloating,children:b.jsx("span",{className:`${At.liveBadge} ${At.liveBadgeActive}`,children:"ao vivo"})}),!L&&b.jsxs("div",{className:`${At.controlsOverlay} ${z?At.controlsVisible:""}`,children:[C&&b.jsx("div",{className:At.timeline,children:b.jsx(G.Slider,{size:"small",min:0,max:di?ce:1,step:.05,value:di?pe:0,disabled:!di,onChange:Ue,onChangeCommitted:it,"aria-label":"Linha do tempo do video",sx:oQ})}),b.jsxs("div",{className:At.controlsRow,children:[b.jsxs("div",{className:At.controlGroup,children:[_&&(S?b.jsx(b.Fragment,{children:b.jsx("button",{type:"button",className:`${At.liveBadge} ${At.liveBadgeInactive} ${At.goLiveButton}`,onClick:()=>{console.log("LIB"),T==null||T()},"aria-label":"Ir ao vivo",children:w})}):se?b.jsxs("div",{className:`${At.liveBadge} ${At.liveBadgeActive}`,children:[se&&b.jsx("span",{className:At.recordingDot}),"ao vivo"]}):b.jsx("button",{type:"button",className:`${At.liveBadge} ${At.liveBadgeInactive} ${At.goLiveButton}`,onClick:Qe,"aria-label":"Ir ao vivo",children:"ao vivo"})),A&&b.jsx(G.IconButton,{className:At.iconButton,onClick:()=>Ge(-15),disabled:!ae,"aria-label":"Voltar 15 segundos",children:b.jsx(nQ,{})}),b.jsx(G.IconButton,{className:At.iconButton,onClick:Ee,"aria-label":"Play/Pause",children:ne?b.jsx(on.Pause,{fontSize:"small"}):b.jsx(on.PlayArrow,{fontSize:"small"})}),A&&b.jsx(G.IconButton,{className:At.iconButton,onClick:()=>Ge(15),disabled:!ae,"aria-label":"Avançar 15 segundos",children:b.jsx(rQ,{})}),di&&!se&&b.jsxs("span",{className:At.playbackTime,"aria-label":"Tempo do vídeo",children:[YE(pe)," / ",YE(ce)]})]}),b.jsxs("div",{className:At.controlGroup,children:[E&&b.jsx(KZ,{icon:b.jsx(on.Speed,{fontSize:"small"}),label:"",valueLabel:Hf,selectedValue:ie,options:Ar,ariaLabel:"Selecionar velocidade de reprodução",onChange:ge,disabled:!st}),b.jsxs("div",{className:At.zoomControl,children:[b.jsx(G.IconButton,{className:At.iconButton,onClick:()=>mr(1),disabled:he<=1,"aria-label":"Resetar zoom",children:b.jsx(on.Undo,{fontSize:"small"})}),b.jsx(G.IconButton,{className:At.iconButton,onClick:()=>Zr(-1),disabled:he<=p[0],"aria-label":"Diminuir zoom",children:b.jsx(on.ZoomOut,{fontSize:"small"})}),b.jsx("span",{className:At.zoomValue,children:ji}),b.jsx(G.IconButton,{className:At.iconButton,onClick:()=>Zr(1),disabled:he>=p[p.length-1],"aria-label":"Aumentar zoom",children:b.jsx(on.ZoomIn,{fontSize:"small"})})]}),b.jsx(G.IconButton,{className:At.iconButton,onClick:tt,"aria-label":"Fullscreen",children:Se?b.jsx(on.CloseFullscreen,{fontSize:"small"}):b.jsx(on.OpenInFull,{fontSize:"small"})})]})]})]})]})})};$v.displayName="VideoPlayer";const sQ=Bt(b.jsx("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z"}),"Add"),iQ=Bt(b.jsx("path",{d:"M19 13H5v-2h14z"}),"Remove"),aQ=Bt(b.jsx("path",{d:"M18 15v3H6v-3H4v3c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-3zm-1-4-1.41-1.41L13 12.17V4h-2v8.17L8.41 9.59 7 11l5 5z"}),"FileDownloadOutlined"),lQ=Bt(b.jsx("path",{d:"M20 3h-1V1h-2v2H7V1H5v2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m0 18H4V10h16zm0-13H4V5h16z"}),"CalendarTodayOutlined");function N(){return N=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},N.apply(null,arguments)}function we(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function cQ(t){const{theme:e,name:n,props:r}=t;return!e||!e.components||!e.components[n]||!e.components[n].defaultProps?r:yl(e.components[n].defaultProps,r)}function uQ(t,e,n,r,o){const[s,i]=x.useState(()=>o&&n?n(t).matches:r?r(t).matches:e);return Ot(()=>{if(!n)return;const a=n(t),c=()=>{i(a.matches)};return c(),a.addEventListener("change",c),()=>{a.removeEventListener("change",c)}},[t,n]),s}const dQ={...x},wA=dQ.useSyncExternalStore;function fQ(t,e,n,r,o){const s=x.useCallback(()=>e,[e]),i=x.useMemo(()=>{if(o&&n)return()=>n(t).matches;if(r!==null){const{matches:d}=r(t);return()=>d}return s},[s,t,r,o,n]),[a,c]=x.useMemo(()=>{if(n===null)return[s,()=>()=>{}];const d=n(t);return[()=>d.matches,f=>(d.addEventListener("change",f),()=>{d.removeEventListener("change",f)})]},[s,n,t]);return wA(c,a,i)}function TA(t={}){const{themeId:e}=t;return function(r,o={}){let s=z4();s&&e&&(s=s[e]||s);const i=typeof window<"u"&&typeof window.matchMedia<"u",{defaultMatches:a=!1,matchMedia:c=i?window.matchMedia:null,ssrMatchMedia:u=null,noSsr:d=!1}=cQ({name:"MuiUseMediaQuery",props:o,theme:s});process.env.NODE_ENV!=="production"&&typeof r=="function"&&s===null&&console.error(["MUI: The `query` argument provided is invalid.","You are providing a function without a theme in the context.","One of the parent elements needs to use a ThemeProvider."].join(`
|
|
148
|
+
`:(s=r.childNodes)!=null&&s.length?tA(r,e):e?n+r.textContent.trim().replace(/\s+/g," "):n+r.textContent},"")}function QY(t,e,n){const r="http://www.w3.org/ns/ttml#styling";let o=null;const s=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],i=t!=null&&t.hasAttribute("style")?t.getAttribute("style"):null;return i&&n.hasOwnProperty(i)&&(o=n[i]),s.reduce((a,c)=>{const u=D0(e,r,c)||D0(t,r,c)||D0(o,r,c);return u&&(a[c]=u),a},{})}function D0(t,e,n){return t&&t.hasAttributeNS(e,n)?t.getAttributeNS(e,n):null}function VE(t){return new Error(`Could not parse ttml timestamp ${t}`)}function M0(t,e){if(!t)return null;let n=XM(t);return n===null&&(JM.test(t)?n=JY(t,e):eA.test(t)&&(n=eX(t,e))),n}function JY(t,e){const n=JM.exec(t),r=(n[4]|0)+(n[5]|0)/e.subFrameRate;return(n[1]|0)*3600+(n[2]|0)*60+(n[3]|0)+r/e.frameRate}function eX(t,e){const n=eA.exec(t),r=Number(n[1]);switch(n[2]){case"h":return r*3600;case"m":return r*60;case"ms":return r*1e3;case"f":return r/e.frameRate;case"t":return r/e.tickRate}return r}class ph{constructor(e,n){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=n}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,n,r){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=n,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}class tX{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=UE(),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(W.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(W.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(W.MANIFEST_LOADING,this.onManifestLoading,this),e.on(W.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(W.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(W.FRAG_LOADING,this.onFragLoading,this),e.on(W.FRAG_LOADED,this.onFragLoaded,this),e.on(W.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(W.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(W.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(W.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(W.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(W.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(W.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(W.MANIFEST_LOADING,this.onManifestLoading,this),e.off(W.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(W.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(W.FRAG_LOADING,this.onFragLoading,this),e.off(W.FRAG_LOADED,this.onFragLoaded,this),e.off(W.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(W.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(W.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(W.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(W.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new ph(this,"textTrack1"),n=new ph(this,"textTrack2"),r=new ph(this,"textTrack3"),o=new ph(this,"textTrack4");this.cea608Parser1=new BE(1,e,n),this.cea608Parser2=new BE(3,r,o)}addCues(e,n,r,o,s){let i=!1;for(let a=s.length;a--;){const c=s[a],u=nX(c[0],c[1],n,r);if(u>=0&&(c[0]=Math.min(c[0],n),c[1]=Math.max(c[1],r),i=!0,u/(r-n)>.5))return}if(i||s.push([n,r]),this.config.renderTextTracksNatively){const a=this.captionsTracks[e];this.Cues.newCue(a,n,r,o)}else{const a=this.Cues.newCue(null,n,r,o);this.hls.trigger(W.CUES_PARSED,{type:"captions",cues:a,track:e})}}onInitPtsFound(e,{frag:n,id:r,initPTS:o,timescale:s,trackId:i}){const{unparsedVttFrags:a}=this;r===lt.MAIN&&(this.initPTS[n.cc]={baseTime:o,timescale:s,trackId:i}),a.length&&(this.unparsedVttFrags=[],a.forEach(c=>{this.initPTS[c.frag.cc]?this.onFragLoaded(W.FRAG_LOADED,c):this.hls.trigger(W.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:c.frag,error:new Error("Subtitle discontinuity domain does not match main")})}))}getExistingTrack(e,n){const{media:r}=this;if(r)for(let o=0;o<r.textTracks.length;o++){const s=r.textTracks[o];if(HE(s,{name:e,lang:n,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return s}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:n,captionsTracks:r,media:o}=this,{label:s,languageCode:i}=n[e],a=this.getExistingTrack(s,i);if(a)r[e]=a,wc(r[e]),zM(r[e],o);else{const c=this.createTextTrack("captions",s,i);c&&(c[e]=!0,r[e]=c)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const n=this.captionsProperties[e];if(!n)return;const r=n.label,o={_id:e,label:r,kind:"captions",default:n.media?!!n.media.default:!1,closedCaptions:n.media};this.nonNativeCaptionsTracks[e]=o,this.hls.trigger(W.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[o]})}createTextTrack(e,n,r){const o=this.media;if(o)return o.addTextTrack(e,n,r)}onMediaAttaching(e,n){this.media=n.media,n.mediaSource||this._cleanTracks()}onMediaDetaching(e,n){const r=!!n.transferMedia;if(this.media=null,r)return;const{captionsTracks:o}=this;Object.keys(o).forEach(s=>{wc(o[s]),delete o[s]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=UE(),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 n=e.textTracks;if(n)for(let r=0;r<n.length;r++)wc(n[r])}onSubtitleTracksUpdated(e,n){const r=n.subtitleTracks||[],o=r.some(s=>s.textCodec===k0);if(this.config.enableWebVTT||o&&this.config.enableIMSC1){if(RM(this.tracks,r)){this.tracks=r;return}if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){const i=this.media,a=i?qh(i.textTracks):null;if(this.tracks.forEach((c,u)=>{let d;if(a){let f=null;for(let h=0;h<a.length;h++)if(a[h]&&HE(a[h],c)){f=a[h],a[h]=null;break}f&&(d=f)}if(d)wc(d);else{const f=nA(c);d=this.createTextTrack(f,c.name,c.lang),d&&(d.mode="disabled")}d&&this.textTracks.push(d)}),a!=null&&a.length){const c=a.filter(u=>u!==null).map(u=>u.label);c.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${c.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const i=this.tracks.map(a=>({label:a.name,kind:a.type.toLowerCase(),default:a.default,subtitleTrack:a}));this.hls.trigger(W.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:i})}}}onManifestLoaded(e,n){this.config.enableCEA708Captions&&n.captions&&n.captions.forEach(r=>{const o=/(?:CC|SERVICE)([1-4])/.exec(r.instreamId);if(!o)return;const s=`textTrack${o[1]}`,i=this.captionsProperties[s];i&&(i.label=r.name,r.lang&&(i.languageCode=r.lang),i.media=r)})}closedCaptionsForLevel(e){const n=this.hls.levels[e.level];return n==null?void 0:n.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,n){if(this.enabled&&n.frag.type===lt.MAIN){var r,o;const{cea608Parser1:s,cea608Parser2:i,lastSn:a}=this,{cc:c,sn:u}=n.frag,d=(r=(o=n.part)==null?void 0:o.index)!=null?r:-1;s&&i&&(u!==a+1||u===a&&d!==this.lastPartIndex+1||c!==this.lastCc)&&(s.reset(),i.reset()),this.lastCc=c,this.lastSn=u,this.lastPartIndex=d}}onFragLoaded(e,n){const{frag:r,payload:o}=n;if(r.type===lt.SUBTITLE)if(o.byteLength){const s=r.decryptdata,i="stats"in n;if(s==null||!s.encrypted||i){const a=this.tracks[r.level],c=this.vttCCs;c[r.cc]||(c[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),a&&a.textCodec===k0?this._parseIMSC1(r,o):this._parseVTTs(n)}}else this.hls.trigger(W.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,n){const r=this.hls;$E(n,this.initPTS[e.cc],o=>{this._appendCues(o,e.level),r.trigger(W.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},o=>{r.logger.log(`Failed to parse IMSC1: ${o}`),r.trigger(W.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:o})})}_parseVTTs(e){var n;const{frag:r,payload:o}=e,{initPTS:s,unparsedVttFrags:i}=this,a=s.length-1;if(!s[r.cc]&&a===-1){i.push(e);return}const c=this.hls,u=(n=r.initSegment)!=null&&n.data?Ko(r.initSegment.data,new Uint8Array(o)).buffer:o;YY(u,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,d=>{this._appendCues(d,r.level),c.trigger(W.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},d=>{const f=d.message==="Missing initPTS for VTT MPEGTS";f?i.push(e):this._fallbackToIMSC1(r,o),c.logger.log(`Failed to parse VTT cue: ${d}`),!(f&&a>r.cc)&&c.trigger(W.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:d})})}_fallbackToIMSC1(e,n){const r=this.tracks[e.level];r.textCodec||$E(n,this.initPTS[e.cc],()=>{r.textCodec=k0,this._parseIMSC1(e,n)},()=>{r.textCodec="wvtt"})}_appendCues(e,n){const r=this.hls;if(this.config.renderTextTracksNatively){const o=this.textTracks[n];if(!o||o.mode==="disabled")return;e.forEach(s=>WM(o,s))}else{const o=this.tracks[n];if(!o)return;const s=o.default?"default":"subtitles"+n;r.trigger(W.CUES_PARSED,{type:"subtitles",cues:e,track:s})}}onFragDecrypted(e,n){const{frag:r}=n;r.type===lt.SUBTITLE&&this.onFragLoaded(W.FRAG_LOADED,n)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,n){if(!this.enabled||!this.config.enableCEA708Captions)return;const{frag:r,samples:o}=n;if(!(r.type===lt.MAIN&&this.closedCaptionsForLevel(r)==="NONE"))for(let s=0;s<o.length;s++){const i=o[s].bytes;if(i){this.cea608Parser1||this.initCea608Parsers();const a=this.extractCea608Data(i);this.cea608Parser1.addData(o[s].pts,a[0]),this.cea608Parser2.addData(o[s].pts,a[1])}}}onBufferFlushing(e,{startOffset:n,endOffset:r,endOffsetSubtitles:o,type:s}){const{media:i}=this;if(!(!i||i.currentTime<r)){if(!s||s==="video"){const{captionsTracks:a}=this;Object.keys(a).forEach(c=>Cy(a[c],n,r))}if(this.config.renderTextTracksNatively&&n===0&&o!==void 0){const{textTracks:a}=this;Object.keys(a).forEach(c=>Cy(a[c],n,o))}}}extractCea608Data(e){const n=[[],[]],r=e[0]&31;let o=2;for(let s=0;s<r;s++){const i=e[o++],a=127&e[o++],c=127&e[o++];if(a===0&&c===0)continue;if((4&i)!==0){const d=3&i;(d===0||d===1)&&(n[d].push(a),n[d].push(c))}}return n}}function nA(t){return t.characteristics&&/transcribes-spoken-dialog/gi.test(t.characteristics)&&/describes-music-and-sound/gi.test(t.characteristics)?"captions":"subtitles"}function HE(t,e){return!!t&&t.kind===nA(e)&&yy(e,t)}function nX(t,e,n,r){return Math.min(e,r)-Math.max(t,n)}function UE(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}const rX=/\s/,oX={newCue(t,e,n,r){const o=[];let s,i,a,c,u;const d=self.VTTCue||self.TextTrackCue;for(let h=0;h<r.rows.length;h++)if(s=r.rows[h],a=!0,c=0,u="",!s.isEmpty()){var f;for(let g=0;g<s.chars.length;g++)rX.test(s.chars[g].uchar)&&a?c++:(u+=s.chars[g].uchar,a=!1);s.cueStartTime=e,e===n&&(n+=1e-4),c>=16?c--:c++;const p=QM(u.trim()),m=Nv(e,n,p);t!=null&&(f=t.cues)!=null&&f.getCueById(m)||(i=new d(e,n,p),i.id=m,i.line=h+1,i.align="left",i.position=10+Math.min(80,Math.floor(c*8/32)*10),o.push(i))}return t&&o.length&&(o.sort((h,p)=>h.line==="auto"||p.line==="auto"?0:h.line>8&&p.line>8?p.line-h.line:h.line-p.line),o.forEach(h=>WM(t,h))),o}};function sX(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const iX=/(\d+)-(\d+)\/(\d+)/;class GE{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||uX,this.controller=new self.AbortController,this.stats=new mv}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,n,r){const o=this.stats;if(o.loading.start)throw new Error("Loader can only be used once.");o.loading.start=self.performance.now();const s=aX(e,this.controller.signal),i=e.responseType==="arraybuffer",a=i?"byteLength":"length",{maxTimeToFirstByteMs:c,maxLoadTimeMs:u}=n.loadPolicy;this.context=e,this.config=n,this.callbacks=r,this.request=this.fetchSetup(e,s),self.clearTimeout(this.requestTimeout),n.timeout=c&&rt(c)?c:u,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(o,e,this.response))},n.timeout),(jd(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(f=>{var h;this.response=this.loader=f;const p=Math.max(self.performance.now(),o.loading.start);if(self.clearTimeout(this.requestTimeout),n.timeout=u,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(o,e,this.response))},u-(p-o.loading.start)),!f.ok){const{status:g,statusText:y}=f;throw new dX(y||"fetch, bad network response",g,f)}o.loading.first=p,o.total=cX(f.headers)||o.total;const m=(h=this.callbacks)==null?void 0:h.onProgress;return m&&rt(n.highWaterMark)?this.loadProgressively(f,o,e,n.highWaterMark,m):i?f.arrayBuffer():e.responseType==="json"?f.json():f.text()}).then(f=>{var h,p;const m=this.response;if(!m)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),o.loading.end=Math.max(self.performance.now(),o.loading.first);const g=f[a];g&&(o.loaded=o.total=g);const y={url:m.url,data:f,code:m.status},v=(h=this.callbacks)==null?void 0:h.onProgress;v&&!rt(n.highWaterMark)&&v(o,e,f,m),(p=this.callbacks)==null||p.onSuccess(y,o,e,m)}).catch(f=>{var h;if(self.clearTimeout(this.requestTimeout),o.aborted)return;const p=f&&f.code||0,m=f?f.message:null;(h=this.callbacks)==null||h.onError({code:p,text:m},e,f?f.details:null,o)})}getCacheAge(){let e=null;if(this.response){const n=this.response.headers.get("age");e=n?parseFloat(n):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,n,r,o=0,s){const i=new fM,a=e.body.getReader(),c=()=>a.read().then(u=>{if(u.done)return i.dataLength&&s(n,r,i.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));const d=u.value,f=d.length;return n.loaded+=f,f<o||i.dataLength?(i.push(d),i.dataLength>=o&&s(n,r,i.flush().buffer,e)):s(n,r,d.buffer,e),c()}).catch(()=>Promise.reject());return c()}}function aX(t,e){const n={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(yn({},t.headers))};return t.rangeEnd&&n.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1)),n}function lX(t){const e=iX.exec(t);if(e)return parseInt(e[2])-parseInt(e[1])+1}function cX(t){const e=t.get("Content-Range");if(e){const r=lX(e);if(rt(r))return r}const n=t.get("Content-Length");if(n)return parseInt(n)}function uX(t,e){return new self.Request(t.url,e)}class dX extends Error{constructor(e,n,r){super(e),this.code=void 0,this.details=void 0,this.code=n,this.details=r}}const fX=/^age:\s*[\d.]+\s*$/im;class rA{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 mv,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=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,n,r){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=n,this.callbacks=r,this.loadInternal()}loadInternal(){const{config:e,context:n}=this;if(!e||!n)return;const r=this.loader=new self.XMLHttpRequest,o=this.stats;o.loading.first=0,o.loaded=0,o.aborted=!1;const s=this.xhrSetup;s?Promise.resolve().then(()=>{if(!(this.loader!==r||this.stats.aborted))return s(r,n.url)}).catch(i=>{if(!(this.loader!==r||this.stats.aborted))return r.open("GET",n.url,!0),s(r,n.url)}).then(()=>{this.loader!==r||this.stats.aborted||this.openAndSendXhr(r,n,e)}).catch(i=>{var a;(a=this.callbacks)==null||a.onError({code:r.status,text:i.message},n,r,o)}):this.openAndSendXhr(r,n,e)}openAndSendXhr(e,n,r){e.readyState||e.open("GET",n.url,!0);const o=n.headers,{maxTimeToFirstByteMs:s,maxLoadTimeMs:i}=r.loadPolicy;if(o)for(const a in o)e.setRequestHeader(a,o[a]);n.rangeEnd&&e.setRequestHeader("Range","bytes="+n.rangeStart+"-"+(n.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=n.responseType,self.clearTimeout(this.requestTimeout),r.timeout=s&&rt(s)?s:i,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()}readystatechange(){const{context:e,loader:n,stats:r}=this;if(!e||!n)return;const o=n.readyState,s=this.config;if(!r.aborted&&o>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),s.timeout!==s.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),s.timeout=s.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),o===4)){self.clearTimeout(this.requestTimeout),n.onreadystatechange=null,n.onprogress=null;const u=n.status,d=n.responseType==="text"?n.responseText:null;if(u>=200&&u<300){const m=d??n.response;if(m!=null){var i,a;r.loading.end=Math.max(self.performance.now(),r.loading.first);const g=n.responseType==="arraybuffer"?m.byteLength:m.length;r.loaded=r.total=g,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first);const y=(i=this.callbacks)==null?void 0:i.onProgress;y&&y(r,e,m,n);const v={url:n.responseURL,data:m,code:u};(a=this.callbacks)==null||a.onSuccess(v,r,e,n);return}}const f=s.loadPolicy.errorRetry,h=r.retry,p={url:e.url,data:void 0,code:u};if(wp(f,h,!1,p))this.retry(f);else{var c;dn.error(`${u} while loading ${e.url}`),(c=this.callbacks)==null||c.onError({code:u,text:n.statusText},e,n,r)}}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry,n=this.stats.retry;if(wp(e,n,!0))this.retry(e);else{var r;dn.warn(`timeout while loading ${(r=this.context)==null?void 0:r.url}`);const o=this.callbacks;o&&(this.abortInternal(),o.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:n,stats:r}=this;this.retryDelay=vv(e,r.retry),r.retry++,dn.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${n==null?void 0:n.url}, retrying ${r.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 n=this.stats;n.loaded=e.loaded,e.lengthComputable&&(n.total=e.total)}getCacheAge(){let e=null;if(this.loader&&fX.test(this.loader.getAllResponseHeaders())){const n=this.loader.getResponseHeader("age");e=n?parseFloat(n):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}const hX={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},pX=un(un({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:!1,maxBufferSize:60*1e3*1e3,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,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,ignorePlaylistParsingErrors:!1,loader:rA,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:IW,bufferController:gK,capLevelController:Lv,errorController:AW,fpsController:yY,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:tM,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,preserveManualLevelOnError:!1,certLoadPolicy:{default:hX},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}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,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},mX()),{},{subtitleStreamController:DY,subtitleTrackController:xY,timelineController:tX,audioStreamController:fK,audioTrackController:hK,emeController:_c,cmcdController:hY,contentSteeringController:mY,interstitialsController:PY});function mX(){return{cueHandler:oX,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 gX(t,e,n){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 r=wy(t),o=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return o.forEach(i=>{const a=`${i==="level"?"playlist":i}LoadPolicy`,c=e[a]===void 0,u=[];s.forEach(d=>{const f=`${i}Loading${d}`,h=e[f];if(h!==void 0&&c){u.push(f);const p=r[a].default;switch(e[a]={default:p},d){case"TimeOut":p.maxLoadTimeMs=h,p.maxTimeToFirstByteMs=h;break;case"MaxRetry":p.errorRetry.maxNumRetry=h,p.timeoutRetry.maxNumRetry=h;break;case"RetryDelay":p.errorRetry.retryDelayMs=h,p.timeoutRetry.retryDelayMs=h;break;case"MaxRetryTimeout":p.errorRetry.maxRetryDelayMs=h,p.timeoutRetry.maxRetryDelayMs=h;break}}}),u.length&&n.warn(`hls.js config: "${u.join('", "')}" setting(s) are deprecated, use "${a}": ${Cn(e[a])}`)}),un(un({},r),e)}function wy(t){return t&&typeof t=="object"?Array.isArray(t)?t.map(wy):Object.keys(t).reduce((e,n)=>(e[n]=wy(t[n]),e),{}):t}function yX(t,e){const n=t.loader;n!==GE&&n!==rA?(e.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):sX()&&(t.loader=GE,t.progressive=!0,t.enableSoftwareAES=!0,e.log("[config]: Progressive streaming enabled, using FetchLoader"))}const Kh=2,bX=.1,vX=.05,xX=100;class CX extends XD{constructor(e,n){super("gap-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0},this.onMediaWaiting=()=>{var r;(r=this.media)!=null&&r.seeking||(this.waiting=self.performance.now(),this.tick())},this.onMediaEnded=()=>{if(this.hls){var r;this.ended=((r=this.media)==null?void 0:r.currentTime)||1,this.hls.trigger(W.MEDIA_ENDED,{stalled:!1})}},this.hls=e,this.fragmentTracker=n,this.registerListeners()}registerListeners(){const{hls:e}=this;e&&(e.on(W.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(W.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(W.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(W.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(W.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(W.BUFFER_APPENDED,this.onBufferAppended,this))}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}onMediaAttached(e,n){this.setInterval(xX),this.mediaSource=n.mediaSource;const r=this.media=n.media;qr(r,"playing",this.onMediaPlaying),qr(r,"waiting",this.onMediaWaiting),qr(r,"ended",this.onMediaEnded)}onMediaDetaching(e,n){this.clearInterval();const{media:r}=this;r&&(to(r,"playing",this.onMediaPlaying),to(r,"waiting",this.onMediaWaiting),to(r,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}onBufferAppended(e,n){this.buffered=n.timeRanges}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var e;if(!((e=this.media)!=null&&e.readyState)||!this.hasBuffered)return;const n=this.media.currentTime;this.poll(n,this.lastCurrentTime),this.lastCurrentTime=n}poll(e,n){var r,o;const s=(r=this.hls)==null?void 0:r.config;if(!s)return;const i=this.media;if(!i)return;const{seeking:a}=i,c=this.seeking&&!a,u=!this.seeking&&a,d=i.paused&&!a||i.ended||i.playbackRate===0;if(this.seeking=a,e!==n){n&&(this.ended=0),this.moved=!0,a||(this.nudgeRetry=0,s.nudgeOnVideoHole&&!d&&e>n&&this.nudgeOnVideoHole(e,n)),this.waiting===0&&this.stallResolved(e);return}if(u||c){c&&this.stallResolved(e);return}if(d){this.nudgeRetry=0,this.stallResolved(e),!this.ended&&i.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(W.MEDIA_ENDED,{stalled:!1}));return}if(!Dt.getBuffered(i).length){this.nudgeRetry=0;return}const f=Dt.bufferInfo(i,e,0),h=f.nextStart||0,p=this.fragmentTracker;if(a&&p&&this.hls){const I=zE(this.hls.inFlightFragments,e),P=f.len>Kh,M=!h||I||h-e>Kh&&!p.getPartialFragment(e);if(P||M)return;this.moved=!1}const m=(o=this.hls)==null?void 0:o.latestLevelDetails;if(!this.moved&&this.stalled!==null&&p){if(!(f.len>0)&&!h)return;const P=Math.max(h,f.start||0)-e,D=!!(m!=null&&m.live)?m.targetduration*2:Kh,k=mh(e,p);if(P>0&&(P<=D||k)){i.paused||this._trySkipBufferHole(k);return}}const g=s.detectStallWithCurrentTimeMs,y=self.performance.now(),v=this.waiting;let C=this.stalled;if(C===null)if(v>0&&y-v<g)C=this.stalled=v;else{this.stalled=y;return}const S=y-C;if(!a&&(S>=g||v)&&this.hls){var w;if(((w=this.mediaSource)==null?void 0:w.readyState)==="ended"&&!(m!=null&&m.live)&&Math.abs(e-((m==null?void 0:m.edge)||0))<1){if(this.ended)return;this.ended=e||1,this.hls.trigger(W.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(f),!this.media||!this.hls)return}const T=Dt.bufferInfo(i,e,s.maxBufferHole);this._tryFixBufferStall(T,S,e)}stallResolved(e){const n=this.stalled;if(n&&this.hls&&(this.stalled=null,this.stallReported)){const r=self.performance.now()-n;this.log(`playback not stuck anymore @${e}, after ${Math.round(r)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(W.STALL_RESOLVED,{})}}nudgeOnVideoHole(e,n){var r;const o=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(r=this.buffered.audio)!=null&&r.length&&o&&o.length>1&&e>o.end(0)){const s=Dt.bufferedInfo(Dt.timeRangesToArray(this.buffered.audio),e,0);if(s.len>1&&n>=s.start){const i=Dt.timeRangesToArray(o),a=Dt.bufferedInfo(i,n,0).bufferedIndex;if(a>-1&&a<i.length-1){const c=Dt.bufferedInfo(i,e,0).bufferedIndex,u=i[a].end,d=i[a+1].start;if((c===-1||c>a)&&d-u<1&&e-u<2){const f=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${u} -> ${d} buffered index: ${c}`);this.warn(f.message),this.media.currentTime+=1e-6;let h=mh(e,this.fragmentTracker);h&&"fragment"in h?h=h.fragment:h||(h=void 0);const p=Dt.bufferInfo(this.media,e,0);this.hls.trigger(W.ERROR,{type:pt.MEDIA_ERROR,details:ve.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:f,reason:f.message,frag:h,buffer:p.len,bufferInfo:p})}}}}}_tryFixBufferStall(e,n,r){var o,s;const{fragmentTracker:i,media:a}=this,c=(o=this.hls)==null?void 0:o.config;if(!a||!i||!c)return;const u=(s=this.hls)==null?void 0:s.latestLevelDetails,d=mh(r,i);if((d||u!=null&&u.live&&r<u.fragmentStart)&&(this._trySkipBufferHole(d)||!this.media))return;const f=e.buffered,h=this.adjacentTraversal(e,r);(f&&f.length>1&&e.len>c.maxBufferHole||e.nextStart&&(e.nextStart-r<c.maxBufferHole||h))&&(n>c.highBufferWatchdogPeriod*1e3||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}adjacentTraversal(e,n){const r=this.fragmentTracker,o=e.nextStart;if(r&&o){const s=r.getFragAtPos(n,lt.MAIN),i=r.getFragAtPos(o,lt.MAIN);if(s&&i)return i.sn-s.sn<2}return!1}_reportStall(e){const{hls:n,media:r,stallReported:o,stalled:s}=this;if(!o&&s!==null&&r&&n){this.stallReported=!0;const i=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${Cn(e)})`);this.warn(i.message),n.trigger(W.ERROR,{type:pt.MEDIA_ERROR,details:ve.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len,bufferInfo:e,stalled:{start:s}})}}_trySkipBufferHole(e){var n;const{fragmentTracker:r,media:o}=this,s=(n=this.hls)==null?void 0:n.config;if(!o||!r||!s)return 0;const i=o.currentTime,a=Dt.bufferInfo(o,i,0),c=i<a.start?a.start:a.nextStart;if(c&&this.hls){const d=a.len<=s.maxBufferHole,f=a.len>0&&a.len<1&&o.readyState<3,h=c-i;if(h>0&&(d||f)){if(h>s.maxBufferHole){let m=!1;if(i===0){const g=r.getAppendedFrag(0,lt.MAIN);g&&c<g.end&&(m=!0)}if(!m&&e){var u;if(!((u=this.hls.loadLevelObj)!=null&&u.details)||zE(this.hls.inFlightFragments,c))return 0;let y=!1,v=e.end;for(;v<c;){const C=mh(v,r);if(C)v+=C.duration;else{y=!0;break}}if(y)return 0}}const p=Math.max(c+vX,i+bX);if(this.warn(`skipping hole, adjusting currentTime from ${i} to ${p}`),this.moved=!0,o.currentTime=p,!(e!=null&&e.gap)){const m=new Error(`fragment loaded with buffer holes, seeking from ${i} to ${p}`),g={type:pt.MEDIA_ERROR,details:ve.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:m,reason:m.message,buffer:a.len,bufferInfo:a};e&&("fragment"in e?g.part=e:g.frag=e),this.hls.trigger(W.ERROR,g)}return p}}return 0}_tryNudgeBuffer(e){const{hls:n,media:r,nudgeRetry:o}=this,s=n==null?void 0:n.config;if(!r||!s)return 0;const i=r.currentTime;if(this.nudgeRetry++,o<s.nudgeMaxRetry){const a=i+(o+1)*s.nudgeOffset,c=new Error(`Nudging 'currentTime' from ${i} to ${a}`);this.warn(c.message),r.currentTime=a,n.trigger(W.ERROR,{type:pt.MEDIA_ERROR,details:ve.BUFFER_NUDGE_ON_STALL,error:c,fatal:!1,buffer:e.len,bufferInfo:e})}else{const a=new Error(`Playhead still not moving while enough data buffered @${i} after ${s.nudgeMaxRetry} nudges`);this.error(a.message),n.trigger(W.ERROR,{type:pt.MEDIA_ERROR,details:ve.BUFFER_STALLED_ERROR,error:a,fatal:!0,buffer:e.len,bufferInfo:e})}}}function zE(t,e){const n=WE(t.main);if(n&&n.start<=e)return n;const r=WE(t.audio);return r&&r.start<=e?r:null}function WE(t){if(!t)return null;switch(t.state){case Le.IDLE:case Le.STOPPED:case Le.ENDED:case Le.ERROR:return null}return t.frag}function mh(t,e){return e.getAppendedFrag(t,lt.MAIN)||e.getPartialFragment(t)}const SX=.25;function Ty(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function A0(t,e,n,r,o){let s=new t(e,n,"");try{s.value=r,o&&(s.type=o)}catch{s=new t(e,n,Cn(o?un({type:o},r):r))}return s}const gh=(()=>{const t=Ty();try{t&&new t(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class wX{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(W.EVENT_CUE_ENTER,{})},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}_registerListeners(){const{hls:e}=this;e&&(e.on(W.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(W.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(W.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(W.MANIFEST_LOADING,this.onManifestLoading,this),e.on(W.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(W.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(W.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(W.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(W.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(W.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(W.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(W.MANIFEST_LOADING,this.onManifestLoading,this),e.off(W.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(W.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(W.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(W.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}onMediaAttaching(e,n){var r;this.media=n.media,((r=n.overrides)==null?void 0:r.cueRemoval)===!1&&(this.removeCues=!1)}onMediaAttached(){var e;const n=(e=this.hls)==null?void 0:e.latestLevelDetails;n&&this.updateDateRangeCues(n)}onMediaDetaching(e,n){this.media=null,!n.transferMedia&&(this.id3Track&&(this.removeCues&&wc(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const n=this.getID3Track(e.textTracks);return n.mode="hidden",n}getID3Track(e){if(this.media){for(let n=0;n<e.length;n++){const r=e[n];if(r.kind==="metadata"&&r.label==="id3")return zM(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,n){if(!this.media||!this.hls)return;const{enableEmsgMetadataCues:r,enableID3MetadataCues:o}=this.hls.config;if(!r&&!o)return;const{samples:s}=n;this.id3Track||(this.id3Track=this.createTrack(this.media));const i=Ty();if(i)for(let a=0;a<s.length;a++){const c=s[a].type;if(c===yo.emsg&&!r||!o)continue;const u=vM(s[a].data),d=s[a].pts;let f=d+s[a].duration;f>gh&&(f=gh),f-d<=0&&(f=d+SX);for(let p=0;p<u.length;p++){const m=u[p];if(!xM(m)){this.updateId3CueEnds(d,c);const g=A0(i,d,f,m,c);g&&this.id3Track.addCue(g)}}}}updateId3CueEnds(e,n){var r;const o=(r=this.id3Track)==null?void 0:r.cues;if(o)for(let s=o.length;s--;){const i=o[s];i.type===n&&i.startTime<e&&i.endTime===gh&&(i.endTime=e)}}onBufferFlushing(e,{startOffset:n,endOffset:r,type:o}){const{id3Track:s,hls:i}=this;if(!i)return;const{config:{enableEmsgMetadataCues:a,enableID3MetadataCues:c}}=i;if(s&&(a||c)){let u;o==="audio"?u=d=>d.type===yo.audioId3&&c:o==="video"?u=d=>d.type===yo.emsg&&a:u=d=>d.type===yo.audioId3&&c||d.type===yo.emsg&&a,Cy(s,n,r,u)}}onLevelUpdated(e,{details:n}){this.updateDateRangeCues(n,!0)}onLevelPtsUpdated(e,n){Math.abs(n.drift)>.01&&this.updateDateRangeCues(n.details)}updateDateRangeCues(e,n){if(!this.hls||!this.media)return;const{assetPlayerId:r,timelineOffset:o,enableDateRangeMetadataCues:s,interstitialsController:i}=this.hls.config;if(!s)return;const a=Ty();if(r&&o&&!i){const{fragmentStart:g,fragmentEnd:y}=e;let v=this.assetCue;v?(v.startTime=g,v.endTime=y):a&&(v=this.assetCue=A0(a,g,y,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),v&&(v.id=r,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(v),v.addEventListener("enter",this.onEventCueEnter)))}if(!e.hasProgramDateTime)return;const{id3Track:c}=this,{dateRanges:u}=e,d=Object.keys(u);let f=this.dateRangeCuesAppended;if(c&&n){var h;if((h=c.cues)!=null&&h.length){const g=Object.keys(f).filter(y=>!d.includes(y));for(let y=g.length;y--;){var p;const v=g[y],C=(p=f[v])==null?void 0:p.cues;delete f[v],C&&Object.keys(C).forEach(S=>{const w=C[S];if(w){w.removeEventListener("enter",this.onEventCueEnter);try{c.removeCue(w)}catch{}}})}}else f=this.dateRangeCuesAppended={}}const m=e.fragments[e.fragments.length-1];if(!(d.length===0||!rt(m==null?void 0:m.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let g=0;g<d.length;g++){const y=d[g],v=u[y],C=v.startTime,S=f[y],w=(S==null?void 0:S.cues)||{};let T=(S==null?void 0:S.durationKnown)||!1,I=gh;const{duration:P,endDate:M}=v;if(M&&P!==null)I=C+P,T=!0;else if(v.endOnNext&&!T){const k=d.reduce((A,E)=>{if(E!==v.id){const L=u[E];if(L.class===v.class&&L.startDate>v.startDate&&(!A||v.startDate<A.startDate))return L}return A},null);k&&(I=k.startTime,T=!0)}const D=Object.keys(v.attr);for(let k=0;k<D.length;k++){const A=D[k];if(!GW(A))continue;const E=w[A];if(E)T&&!(S!=null&&S.durationKnown)?E.endTime=I:Math.abs(E.startTime-C)>.01&&(E.startTime=C,E.endTime=I);else if(a){let L=v.attr[A];zW(A)&&(L=MD(L));const _=A0(a,C,I,{key:A,data:L},yo.dateRange);_&&(_.id=y,this.id3Track.addCue(_),w[A]=_,i&&(A==="X-ASSET-LIST"||A==="X-ASSET-URL")&&_.addEventListener("enter",this.onEventCueEnter))}}f[y]={cues:w,dateRange:v,durationKnown:T}}}}}class TX{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{const{media:n}=this,r=this.levelDetails;if(!n||!r)return;this.currentTime=n.currentTime;const o=this.computeLatency();if(o===null)return;this._latency=o;const{lowLatencyMode:s,maxLiveSyncPlaybackRate:i}=this.config;if(!s||i===1||!r.live)return;const a=this.targetLatency;if(a===null)return;const c=o-a,u=Math.min(this.maxLatency,a+r.targetduration);if(c<u&&c>.05&&this.forwardBufferLength>1){const f=Math.min(2,Math.max(1,i)),h=Math.round(2/(1+Math.exp(-.75*c-this.edgeStalled))*20)/20,p=Math.min(f,Math.max(1,h));this.changeMediaPlaybackRate(n,p)}else n.playbackRate!==1&&n.playbackRate!==0&&this.changeMediaPlaybackRate(n,1)},this.hls=e,this.config=e.config,this.registerListeners()}get levelDetails(){var e;return((e=this.hls)==null?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){const{config:e}=this;if(e.liveMaxLatencyDuration!==void 0)return e.liveMaxLatencyDuration;const n=this.levelDetails;return n?e.liveMaxLatencyDurationCount*n.targetduration:0}get targetLatency(){const e=this.levelDetails;if(e===null||this.hls===null)return null;const{holdBack:n,partHoldBack:r,targetduration:o}=e,{liveSyncDuration:s,liveSyncDurationCount:i,lowLatencyMode:a}=this.config,c=this.hls.userConfig;let u=a&&r||n;(this._targetLatencyUpdated||c.liveSyncDuration||c.liveSyncDurationCount||u===0)&&(u=s!==void 0?s:i*o);const d=o;return u+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,d)}set targetLatency(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}get liveSyncPosition(){const e=this.estimateLiveEdge(),n=this.targetLatency;if(e===null||n===null)return null;const r=this.levelDetails;if(r===null)return null;const o=r.edge,s=e-n-this.edgeStalled,i=o-r.totalduration,a=o-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(i,s),a)}get drift(){const e=this.levelDetails;return e===null?1:e.drift}get edgeStalled(){const e=this.levelDetails;if(e===null)return 0;const n=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-n,0)}get forwardBufferLength(){const{media:e}=this,n=this.levelDetails;if(!e||!n)return 0;const r=e.buffered.length;return(r?e.buffered.end(r-1):n.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}registerListeners(){const{hls:e}=this;e&&(e.on(W.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(W.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(W.MANIFEST_LOADING,this.onManifestLoading,this),e.on(W.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(W.ERROR,this.onError,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(W.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(W.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(W.MANIFEST_LOADING,this.onManifestLoading,this),e.off(W.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(W.ERROR,this.onError,this))}onMediaAttached(e,n){this.media=n.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}onManifestLoading(){this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:n}){n.advanced&&this.onTimeupdate(),!n.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}onError(e,n){var r;n.details===ve.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&(r=this.levelDetails)!=null&&r.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}changeMediaPlaybackRate(e,n){var r,o;e.playbackRate!==n&&((r=this.hls)==null||r.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${(o=this.targetLatency)==null?void 0:o.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${n}`),e.playbackRate=n)}estimateLiveEdge(){const e=this.levelDetails;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}class EX extends Rv{constructor(e,n){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=n,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(W.MANIFEST_LOADING,this.onManifestLoading,this),e.on(W.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(W.LEVEL_LOADED,this.onLevelLoaded,this),e.on(W.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(W.FRAG_BUFFERED,this.onFragBuffered,this),e.on(W.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(W.MANIFEST_LOADING,this.onManifestLoading,this),e.off(W.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(W.LEVEL_LOADED,this.onLevelLoaded,this),e.off(W.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(W.FRAG_BUFFERED,this.onFragBuffered,this),e.off(W.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(n=>{n.loadError=0,n.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,n){this.resetLevels()}onManifestLoaded(e,n){const r=this.hls.config.preferManagedMediaSource,o=[],s={},i={};let a=!1,c=!1,u=!1;n.levels.forEach(d=>{const f=d.attrs;let{audioCodec:h,videoCodec:p}=d;h&&(d.audioCodec=h=vp(h,r)||void 0),p&&(p=d.videoCodec=aW(p));const{width:m,height:g,unknownCodecs:y}=d,v=(y==null?void 0:y.length)||0;if(a||(a=!!(m&&g)),c||(c=!!p),u||(u=!!h),v||h&&!this.isAudioSupported(h)||p&&!this.isVideoSupported(p)){this.log(`Some or all CODECS not supported "${f.CODECS}"`);return}const{CODECS:C,"FRAME-RATE":S,"HDCP-LEVEL":w,"PATHWAY-ID":T,RESOLUTION:I,"VIDEO-RANGE":P}=f,D=`${`${T||"."}-`}${d.bitrate}-${I}-${S}-${C}-${P}-${w}`;if(s[D])if(s[D].uri!==d.url&&!d.attrs["PATHWAY-ID"]){const k=i[D]+=1;d.attrs["PATHWAY-ID"]=new Array(k+1).join(".");const A=this.createLevel(d);s[D]=A,o.push(A)}else s[D].addGroupId("audio",f.AUDIO),s[D].addGroupId("text",f.SUBTITLES);else{const k=this.createLevel(d);s[D]=k,i[D]=1,o.push(k)}}),this.filterAndSortMediaOptions(o,n,a,c,u)}createLevel(e){const n=new Nd(e),r=e.supplemental;if(r!=null&&r.videoCodec&&!this.isVideoSupported(r.videoCodec)){const o=new Error(`SUPPLEMENTAL-CODECS not supported "${r.videoCodec}"`);this.log(o.message),n.supportedResult=HD(o,[])}return n}isAudioSupported(e){return Od(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return Od(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,n,r,o,s){var i;let a=[],c=[],u=e;const d=((i=n.stats)==null?void 0:i.parsing)||{};if((r||o)&&s&&(u=u.filter(({videoCodec:C,videoRange:S,width:w,height:T})=>(!!C||!!(w&&T))&&yW(S))),u.length===0){Promise.resolve().then(()=>{if(this.hls){let C="no level with compatible codecs found in manifest",S=C;n.levels.length&&(S=`one or more CODECS in variant not supported: ${Cn(n.levels.map(T=>T.attrs.CODECS).filter((T,I,P)=>P.indexOf(T)===I))}`,this.warn(S),C+=` (${S})`);const w=new Error(C);this.hls.trigger(W.ERROR,{type:pt.MEDIA_ERROR,details:ve.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:n.url,error:w,reason:S})}}),d.end=performance.now();return}n.audioTracks&&(a=n.audioTracks.filter(C=>!C.audioCodec||this.isAudioSupported(C.audioCodec)),qE(a)),n.subtitles&&(c=n.subtitles,qE(c));const f=u.slice(0);u.sort((C,S)=>{if(C.attrs["HDCP-LEVEL"]!==S.attrs["HDCP-LEVEL"])return(C.attrs["HDCP-LEVEL"]||"")>(S.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&C.height!==S.height)return C.height-S.height;if(C.frameRate!==S.frameRate)return C.frameRate-S.frameRate;if(C.videoRange!==S.videoRange)return xp.indexOf(C.videoRange)-xp.indexOf(S.videoRange);if(C.videoCodec!==S.videoCodec){const w=BT(C.videoCodec),T=BT(S.videoCodec);if(w!==T)return T-w}if(C.uri===S.uri&&C.codecSet!==S.codecSet){const w=bp(C.codecSet),T=bp(S.codecSet);if(w!==T)return T-w}return C.averageBitrate!==S.averageBitrate?C.averageBitrate-S.averageBitrate:0});let h=f[0];if(this.steering&&(u=this.steering.filterParsedLevels(u),u.length!==f.length)){for(let C=0;C<f.length;C++)if(f[C].pathwayId===u[0].pathwayId){h=f[C];break}}this._levels=u;for(let C=0;C<u.length;C++)if(u[C]===h){var p;this._firstLevel=C;const S=h.bitrate,w=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${u.length} level(s) found, first bitrate: ${S}`),((p=this.hls.userConfig)==null?void 0:p.abrEwmaDefaultEstimate)===void 0){const T=Math.min(S,this.hls.config.abrEwmaDefaultEstimateMax);T>w&&w===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=T)}break}const m=s&&!o,g=this.hls.config,y=!!(g.audioStreamController&&g.audioTrackController),v={levels:u,audioTracks:a,subtitleTracks:c,sessionData:n.sessionData,sessionKeys:n.sessionKeys,firstLevel:this._firstLevel,stats:n.stats,audio:s,video:o,altAudio:y&&!m&&a.some(C=>!!C.url)};d.end=performance.now(),this.hls.trigger(W.MANIFEST_PARSED,v)}get levels(){return this._levels.length===0?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){const n=this._levels;if(n.length===0)return;if(e<0||e>=n.length){const d=new Error("invalid level idx"),f=e<0;if(this.hls.trigger(W.ERROR,{type:pt.OTHER_ERROR,details:ve.LEVEL_SWITCH_ERROR,level:e,fatal:f,error:d,reason:d.message}),f)return;e=Math.min(e,n.length-1)}const r=this.currentLevelIndex,o=this.currentLevel,s=o?o.attrs["PATHWAY-ID"]:void 0,i=n[e],a=i.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=i,r===e&&o&&s===a)return;this.log(`Switching to level ${e} (${i.height?i.height+"p ":""}${i.videoRange?i.videoRange+" ":""}${i.codecSet?i.codecSet+" ":""}@${i.bitrate})${a?" with Pathway "+a:""} from level ${r}${s?" with Pathway "+s:""}`);const c={level:e,attrs:i.attrs,details:i.details,bitrate:i.bitrate,averageBitrate:i.averageBitrate,maxBitrate:i.maxBitrate,realBitrate:i.realBitrate,width:i.width,height:i.height,codecSet:i.codecSet,audioCodec:i.audioCodec,videoCodec:i.videoCodec,audioGroups:i.audioGroups,subtitleGroups:i.subtitleGroups,loaded:i.loaded,loadError:i.loadError,fragmentError:i.fragmentError,name:i.name,id:i.id,uri:i.uri,url:i.url,urlId:0,audioGroupIds:i.audioGroupIds,textGroupIds:i.textGroupIds};this.hls.trigger(W.LEVEL_SWITCHING,c);const u=i.details;if(!u||u.live){const d=this.switchParams(i.uri,o==null?void 0:o.details,u);this.loadPlaylist(d)}}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}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){const n=this.steering.pathways(),r=e.filter(o=>n.indexOf(o)!==-1);if(e.length<1){this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${n}`);return}this.steering.pathwayPriority=r}}onError(e,n){n.fatal||!n.context||n.context.type===Ht.LEVEL&&n.context.level===this.level&&this.checkRetry(n)}onFragBuffered(e,{frag:n}){if(n!==void 0&&n.type===lt.MAIN){const r=n.elementaryStreams;if(!Object.keys(r).some(s=>!!r[s]))return;const o=this._levels[n.level];o!=null&&o.loadError&&(this.log(`Resetting level error count of ${o.loadError} on frag buffered`),o.loadError=0)}}onLevelLoaded(e,n){var r;const{level:o,details:s}=n,i=n.levelInfo;if(!i){var a;this.warn(`Invalid level index ${o}`),(a=n.deliveryDirectives)!=null&&a.skip&&(s.deltaUpdateFailed=!0);return}if(i===this.currentLevel||n.withoutMultiVariant){i.fragmentError===0&&(i.loadError=0);let c=i.details;c===n.details&&c.advanced&&(c=void 0),this.playlistLoaded(o,n,c)}else(r=n.deliveryDirectives)!=null&&r.skip&&(s.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}loadingPlaylist(e,n){super.loadingPlaylist(e,n);const r=this.getUrlWithDirectives(e.uri,n),o=this.currentLevelIndex,s=e.attrs["PATHWAY-ID"],i=e.details,a=i==null?void 0:i.age;this.log(`Loading level index ${o}${(n==null?void 0:n.msn)!==void 0?" at sn "+n.msn+" part "+n.part:""}${s?" Pathway "+s:""}${a&&i.live?" age "+a.toFixed(1)+(i.type&&" "+i.type||""):""} ${r}`),this.hls.trigger(W.LEVEL_LOADING,{url:r,level:o,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:n||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 n;if(this._levels.length===1)return;const r=this._levels.filter((s,i)=>i!==e?!0:(this.steering&&this.steering.removeLevel(s),s===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,s.details&&s.details.fragments.forEach(a=>a.level=-1)),!1));cM(r),this._levels=r,this.currentLevelIndex>-1&&(n=this.currentLevel)!=null&&n.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);const o=r.length-1;this._firstLevel=Math.min(this._firstLevel,o),this._startLevel&&(this._startLevel=Math.min(this._startLevel,o)),this.hls.trigger(W.LEVELS_UPDATED,{levels:r})}onLevelsUpdated(e,{levels:n}){this._levels=n}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:n,maxHdcpLevel:r}=this.hls;this._maxAutoLevel!==n&&(this._maxAutoLevel=n,this.hls.trigger(W.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:n,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))}}function qE(t){const e={};t.forEach(n=>{const r=n.groupId||"";n.id=e[r]=e[r]||0,e[r]++})}function oA(){return self.SourceBuffer||self.WebKitSourceBuffer}function sA(){if(!ba())return!1;const e=oA();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function IX(){if(!sA())return!1;const t=ba();return typeof(t==null?void 0:t.isTypeSupported)=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>t.isTypeSupported(Fd(e,"video")))||["mp4a.40.2","fLaC"].some(e=>t.isTypeSupported(Fd(e,"audio"))))}function kX(){var t;const e=oA();return typeof(e==null||(t=e.prototype)==null?void 0:t.changeType)=="function"}const PX=100;class DX extends Tv{constructor(e,n,r){super(e,n,r,"stream-controller",lt.MAIN),this.audioCodecSwap=!1,this.level=-1,this._forceStartLoad=!1,this._hasEnoughToStart=!1,this.altAudio=0,this.audioOnly=!1,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick()},this.onMediaSeeked=()=>{const o=this.media,s=o?o.currentTime:null;if(s===null||!rt(s)||(this.log(`Media seeked to ${s.toFixed(3)}`),!this.getBufferedFrag(s)))return;const i=this.getFwdBufferInfoAtPos(o,s,lt.MAIN,0);if(i===null||i.len===0){this.warn(`Main forward buffer length at ${s} on "seeked" event ${i?i.len:"empty"})`);return}this.tick()},this.registerListeners()}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(W.MANIFEST_PARSED,this.onManifestParsed,this),e.on(W.LEVEL_LOADING,this.onLevelLoading,this),e.on(W.LEVEL_LOADED,this.onLevelLoaded,this),e.on(W.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(W.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(W.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(W.BUFFER_CREATED,this.onBufferCreated,this),e.on(W.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(W.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(W.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(W.MANIFEST_PARSED,this.onManifestParsed,this),e.off(W.LEVEL_LOADED,this.onLevelLoaded,this),e.off(W.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(W.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(W.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(W.BUFFER_CREATED,this.onBufferCreated,this),e.off(W.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(W.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(W.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}startLoad(e,n){if(this.levels){const{lastCurrentTime:r,hls:o}=this;if(this.stopLoad(),this.setInterval(PX),this.level=-1,!this.startFragRequested){let s=o.startLevel;s===-1&&(o.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=o.firstAutoLevel),o.nextLoadLevel=s,this.level=o.loadLevel,this._hasEnoughToStart=!!n}r>0&&e===-1&&!n&&(this.log(`Override startPosition with lastCurrentTime @${r.toFixed(3)}`),e=r),this.state=Le.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=n?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=Le.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Le.WAITING_LEVEL:{const{levels:e,level:n}=this,r=e==null?void 0:e[n],o=r==null?void 0:r.details;if(o&&(!o.live||this.levelLastLoaded===r&&!this.waitForLive(r))){if(this.waitForCdnTuneIn(o))break;this.state=Le.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=Le.IDLE;break}break}case Le.FRAG_LOADING_WAITING_RETRY:this.checkRetryDate();break}this.state===Le.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){var e;super.onTickEnd(),(e=this.media)!=null&&e.readyState&&this.media.seeking===!1&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:n,levels:r,media:o}=this;if(n===null||!o&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;const s=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(r!=null&&r[s]))return;const i=r[s],a=this.getMainFwdBufferInfo();if(a===null)return;const c=this.getLevelDetails();if(c&&this._streamEnded(a,c)){const g={};this.altAudio===2&&(g.type="video"),this.hls.trigger(W.BUFFER_EOS,g),this.state=Le.ENDED;return}if(!this.buffering)return;e.loadLevel!==s&&e.manualLevel===-1&&this.log(`Adapting to level ${s} from level ${this.level}`),this.level=e.nextLoadLevel=s;const u=i.details;if(!u||this.state===Le.WAITING_LEVEL||this.waitForLive(i)){this.level=s,this.state=Le.WAITING_LEVEL,this.startFragRequested=!1;return}const d=a.len,f=this.getMaxBufferLength(i.maxBitrate);if(d>=f)return;this.backtrackFragment&&this.backtrackFragment.start>a.end&&(this.backtrackFragment=null);const h=this.backtrackFragment?this.backtrackFragment.start:a.end;let p=this.getNextFragment(h,u);if(this.couldBacktrack&&!this.fragPrevious&&p&&Jn(p)&&this.fragmentTracker.getState(p)!==fr.OK){var m;const y=((m=this.backtrackFragment)!=null?m:p).sn-u.startSN,v=u.fragments[y-1];v&&p.cc===v.cc&&(p=v,this.fragmentTracker.removeFragment(v))}else this.backtrackFragment&&a.len&&(this.backtrackFragment=null);if(p&&this.isLoopLoading(p,h)){if(!p.gap){const y=this.audioOnly&&!this.altAudio?xn.AUDIO:xn.VIDEO,v=(y===xn.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;v&&this.afterBufferFlushed(v,y,lt.MAIN)}p=this.getNextFragmentLoopLoading(p,u,a,lt.MAIN,f)}p&&(p.initSegment&&!p.initSegment.data&&!this.bitrateTest&&(p=p.initSegment),this.loadFragment(p,i,h))}loadFragment(e,n,r){const o=this.fragmentTracker.getState(e);o===fr.NOT_LOADED||o===fr.PARTIAL?Jn(e)?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,n)):super.loadFragment(e,n,r):this._loadInitSegment(e,n):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,lt.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:n}=this;if(n!=null&&n.readyState){let r;const o=this.getAppendedFrag(n.currentTime);o&&o.start>1&&this.flushMainBuffer(0,o.start-1);const s=this.getLevelDetails();if(s!=null&&s.live){const a=this.getMainFwdBufferInfo();if(!a||a.len<s.targetduration*2)return}if(!n.paused&&e){const a=this.hls.nextLoadLevel,c=e[a],u=this.fragLastKbps;u&&this.fragCurrent?r=this.fragCurrent.duration*c.maxBitrate/(1e3*u)+1:r=0}else r=0;const i=this.getBufferedFrag(n.currentTime+r);if(i){const a=this.followingBufferedFrag(i);if(a){this.abortCurrentFrag();const c=a.maxStartPTS?a.maxStartPTS:a.start,u=a.duration,d=Math.max(i.end,c+Math.min(Math.max(u-this.config.maxFragLookUpTolerance,u*(this.couldBacktrack?.5:.125)),u*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(d,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 Le.KEY_LOADING:case Le.FRAG_LOADING:case Le.FRAG_LOADING_WAITING_RETRY:case Le.PARSING:case Le.PARSED:this.state=Le.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,n){super.flushMainBuffer(e,n,this.altAudio===2?"video":null)}onMediaAttached(e,n){super.onMediaAttached(e,n);const r=n.media;qr(r,"playing",this.onMediaPlaying),qr(r,"seeked",this.onMediaSeeked)}onMediaDetaching(e,n){const{media:r}=this;r&&(to(r,"playing",this.onMediaPlaying),to(r,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(e,n),!n.transferMedia&&(this._hasEnoughToStart=!1)}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(W.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}onManifestParsed(e,n){let r=!1,o=!1;for(let s=0;s<n.levels.length;s++){const i=n.levels[s].audioCodec;i&&(r=r||i.indexOf("mp4a.40.2")!==-1,o=o||i.indexOf("mp4a.40.5")!==-1)}this.audioCodecSwitch=r&&o&&!kX(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=n.levels,this.startFragRequested=!1}onLevelLoading(e,n){const{levels:r}=this;if(!r||this.state!==Le.IDLE)return;const o=n.levelInfo;(!o.details||o.details.live&&(this.levelLastLoaded!==o||o.details.expired)||this.waitForCdnTuneIn(o.details))&&(this.state=Le.WAITING_LEVEL)}onLevelLoaded(e,n){var r;const{levels:o,startFragRequested:s}=this,i=n.level,a=n.details,c=a.totalduration;if(!o){this.warn(`Levels were reset while loading level ${i}`);return}this.log(`Level ${i} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${c}`);const u=n.levelInfo,d=this.fragCurrent;d&&(this.state===Le.FRAG_LOADING||this.state===Le.FRAG_LOADING_WAITING_RETRY)&&d.level!==n.level&&d.loader&&this.abortCurrentFrag();let f=0;if(a.live||(r=u.details)!=null&&r.live){var h;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;f=this.alignPlaylists(a,u.details,(h=this.levelLastLoaded)==null?void 0:h.details)}if(u.details=a,this.levelLastLoaded=u,s||this.setStartPosition(a,f),this.hls.trigger(W.LEVEL_UPDATED,{details:a,level:i}),this.state===Le.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=Le.IDLE}s&&a.live&&this.synchronizeToLiveEdge(a),this.tick()}synchronizeToLiveEdge(e){const{config:n,media:r}=this;if(!r)return;const o=this.hls.liveSyncPosition,s=this.getLoadPosition(),i=e.fragmentStart,a=e.edge,c=s>=i-n.maxFragLookUpTolerance&&s<=a;if(o!==null&&r.duration>o&&(s<o||!c)){const d=n.liveMaxLatencyDuration!==void 0?n.liveMaxLatencyDuration:n.liveMaxLatencyDurationCount*e.targetduration;if((!c&&r.readyState<4||s<a-d)&&(this._hasEnoughToStart||(this.nextLoadPosition=o),r.readyState))if(this.warn(`Playback: ${s.toFixed(3)} is located too far from the end of live sliding playlist: ${a}, reset currentTime to : ${o.toFixed(3)}`),this.config.liveSyncMode==="buffered"){var u;const f=Dt.bufferInfo(r,o,0);if(!((u=f.buffered)!=null&&u.length)){r.currentTime=o;return}if(f.start<=s){r.currentTime=o;return}const{nextStart:p}=Dt.bufferedInfo(f.buffered,s,0);p&&(r.currentTime=p)}else r.currentTime=o}}_handleFragmentLoadProgress(e){var n;const r=e.frag,{part:o,payload:s}=e,{levels:i}=this;if(!i){this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}const a=i[r.level];if(!a){this.warn(`Level ${r.level} not found on progress`);return}const c=a.details;if(!c){this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),this.fragmentTracker.removeFragment(r);return}const u=a.videoCodec,d=c.PTSKnown||!c.live,f=(n=r.initSegment)==null?void 0:n.data,h=this._getAudioCodec(a),p=this.transmuxer=this.transmuxer||new AM(this.hls,lt.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=o?o.index:-1,g=m!==-1,y=new Cv(r.level,r.sn,r.stats.chunkCount,s.byteLength,m,g),v=this.initPTS[r.cc];p.push(s,f,h,u,r,o,c.totalduration,d,y,v)}onAudioTrackSwitching(e,n){const r=this.hls,o=this.altAudio!==0;if(Cp(n.url,r))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const i=this.fragCurrent;i&&(this.log("Switching to main audio track, cancel main fragment load"),i.abortRequests(),this.fragmentTracker.removeFragment(i)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(o){this.altAudio=0,this.fragmentTracker.removeAllFragments(),r.once(W.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(W.AUDIO_TRACK_SWITCHED,n)}),r.trigger(W.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}r.trigger(W.AUDIO_TRACK_SWITCHED,n)}}onAudioTrackSwitched(e,n){const r=Cp(n.url,this.hls);if(r){const o=this.videoBuffer;o&&this.mediaBuffer!==o&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=o)}this.altAudio=r?2:0,this.tick()}onBufferCreated(e,n){const r=n.tracks;let o,s,i=!1;for(const a in r){const c=r[a];if(c.id==="main"){if(s=a,o=c,a==="video"){const u=r[a];u&&(this.videoBuffer=u.buffer)}}else i=!0}i&&o?(this.log(`Alternate track found, use ${s}.buffered to schedule main fragment loading`),this.mediaBuffer=o.buffer):this.mediaBuffer=this.media}onFragBuffered(e,n){const{frag:r,part:o}=n,s=r.type===lt.MAIN;if(s){if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${o?" p: "+o.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),this.state===Le.PARSED&&(this.state=Le.IDLE);return}const a=o?o.stats:r.stats;this.fragLastKbps=Math.round(8*a.total/(a.buffering.end-a.loading.first)),Jn(r)&&(this.fragPrevious=r),this.fragBufferedComplete(r,o)}const i=this.media;i&&(!this._hasEnoughToStart&&Dt.getBuffered(i).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),s&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,n){var r;if(n.fatal){this.state=Le.ERROR;return}switch(n.details){case ve.FRAG_GAP:case ve.FRAG_PARSING_ERROR:case ve.FRAG_DECRYPT_ERROR:case ve.FRAG_LOAD_ERROR:case ve.FRAG_LOAD_TIMEOUT:case ve.KEY_LOAD_ERROR:case ve.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(lt.MAIN,n);break;case ve.LEVEL_LOAD_ERROR:case ve.LEVEL_LOAD_TIMEOUT:case ve.LEVEL_PARSING_ERROR:!n.levelRetry&&this.state===Le.WAITING_LEVEL&&((r=n.context)==null?void 0:r.type)===Ht.LEVEL&&(this.state=Le.IDLE);break;case ve.BUFFER_ADD_CODEC_ERROR:case ve.BUFFER_APPEND_ERROR:if(n.parent!=="main")return;this.reduceLengthAndFlushBuffer(n)&&this.resetLoadingState();break;case ve.BUFFER_FULL_ERROR:if(n.parent!=="main")return;this.reduceLengthAndFlushBuffer(n)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY));break;case ve.INTERNAL_EXCEPTION:this.recoverWorkerError(n);break}}onFragLoadEmergencyAborted(){this.state=Le.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:n}){if(n!==xn.AUDIO||!this.altAudio){const r=(n===xn.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;r&&(this.afterBufferFlushed(r,n,lt.MAIN),this.tick())}}onLevelsUpdated(e,n){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,this.level===-1&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=n.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const n=e.currentTime;let r=this.startPosition;if(r>=0&&n<r){if(e.seeking){this.log(`could not seek to ${r}, already seeking at ${n}`);return}const o=this.timelineOffset;o&&r&&(r+=o);const s=this.getLevelDetails(),i=Dt.getBuffered(e),a=i.length?i.start(0):0,c=a-r,u=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||c>0&&(c<u||this.loadingParts&&c<2*((s==null?void 0:s.partTarget)||0)))&&(this.log(`adjusting start position by ${c} to match buffer start`),r+=c,this.startPosition=r),n<r&&(this.log(`seek to target start position ${r} from current time ${n} buffer start ${a}`),e.currentTime=r)}}_getAudioCodec(e){let n=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&n&&(this.log("Swapping audio codec"),n.indexOf("mp4a.40.5")!==-1?n="mp4a.40.2":n="mp4a.40.5"),n}_loadBitrateTestFrag(e,n){e.bitrateTest=!0,this._doFragLoad(e,n).then(r=>{const{hls:o}=this,s=r==null?void 0:r.frag;if(!s||this.fragContextChanged(s))return;n.fragmentError=0,this.state=Le.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const i=s.stats;i.parsing.start=i.parsing.end=i.buffering.start=i.buffering.end=self.performance.now(),o.trigger(W.FRAG_LOADED,r),s.bitrateTest=!1}).catch(r=>{this.state===Le.STOPPED||this.state===Le.ERROR||(this.warn(r),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){const n=this.playlistType,{hls:r}=this,{remuxResult:o,chunkMeta:s}=e,i=this.getCurrentContext(s);if(!i){this.resetWhenMissingContext(s);return}const{frag:a,part:c,level:u}=i,{video:d,text:f,id3:h,initSegment:p}=o,{details:m}=u,g=this.altAudio?void 0:o.audio;if(this.fragContextChanged(a)){this.fragmentTracker.removeFragment(a);return}if(this.state=Le.PARSING,p){const y=p.tracks;if(y){const w=a.initSegment||a;if(this.unhandledEncryptionError(p,a))return;this._bufferInitSegment(u,y,w,s),r.trigger(W.FRAG_PARSING_INIT_SEGMENT,{frag:w,id:n,tracks:y})}const v=p.initPTS,C=p.timescale,S=this.initPTS[a.cc];if(rt(v)&&(!S||S.baseTime!==v||S.timescale!==C)){const w=p.trackId;this.initPTS[a.cc]={baseTime:v,timescale:C,trackId:w},r.trigger(W.INIT_PTS_FOUND,{frag:a,id:n,initPTS:v,timescale:C,trackId:w})}}if(d&&m){g&&d.type==="audiovideo"&&this.logMuxedErr(a);const y=m.fragments[a.sn-1-m.startSN],v=a.sn===m.startSN,C=!y||a.cc>y.cc;if(o.independent!==!1){const{startPTS:S,endPTS:w,startDTS:T,endDTS:I}=d;if(c)c.elementaryStreams[d.type]={startPTS:S,endPTS:w,startDTS:T,endDTS:I};else if(d.firstKeyFrame&&d.independent&&s.id===1&&!C&&(this.couldBacktrack=!0),d.dropped&&d.independent){const P=this.getMainFwdBufferInfo(),M=(P?P.end:this.getLoadPosition())+this.config.maxBufferHole,D=d.firstKeyFramePTS?d.firstKeyFramePTS:S;if(!v&&M<D-this.config.maxBufferHole&&!C){this.backtrack(a);return}else C&&(a.gap=!0);a.setElementaryStreamInfo(d.type,a.start,w,a.start,I,!0)}else v&&S-(m.appliedTimelineOffset||0)>Kh&&(a.gap=!0);a.setElementaryStreamInfo(d.type,S,w,T,I),this.backtrackFragment&&(this.backtrackFragment=a),this.bufferFragmentData(d,a,c,s,v||C)}else if(v||C)a.gap=!0;else{this.backtrack(a);return}}if(g){const{startPTS:y,endPTS:v,startDTS:C,endDTS:S}=g;c&&(c.elementaryStreams[xn.AUDIO]={startPTS:y,endPTS:v,startDTS:C,endDTS:S}),a.setElementaryStreamInfo(xn.AUDIO,y,v,C,S),this.bufferFragmentData(g,a,c,s)}if(m&&h!=null&&h.samples.length){const y={id:n,frag:a,details:m,samples:h.samples};r.trigger(W.FRAG_PARSING_METADATA,y)}if(m&&f){const y={id:n,frag:a,details:m,samples:f.samples};r.trigger(W.FRAG_PARSING_USERDATA,y)}}logMuxedErr(e){this.warn(`${Jn(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,n,r,o){if(this.state!==Le.PARSING)return;this.audioOnly=!!n.audio&&!n.video,this.altAudio&&!this.audioOnly&&(delete n.audio,n.audiovideo&&this.logMuxedErr(r));const{audio:s,video:i,audiovideo:a}=n;if(s){const u=e.audioCodec;let d=Vh(s.codec,u);d==="mp4a"&&(d="mp4a.40.5");const f=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){d&&(d.indexOf("mp4a.40.5")!==-1?d="mp4a.40.2":d="mp4a.40.5");const h=s.metadata;h&&"channelCount"in h&&(h.channelCount||1)!==1&&f.indexOf("firefox")===-1&&(d="mp4a.40.5")}d&&d.indexOf("mp4a.40.5")!==-1&&f.indexOf("android")!==-1&&s.container!=="audio/mpeg"&&(d="mp4a.40.2",this.log(`Android: force audio codec to ${d}`)),u&&u!==d&&this.log(`Swapping manifest audio codec "${u}" for "${d}"`),s.levelCodec=d,s.id=lt.MAIN,this.log(`Init audio buffer, container:${s.container}, codecs[selected/level/parsed]=[${d||""}/${u||""}/${s.codec}]`),delete n.audiovideo}if(i){i.levelCodec=e.videoCodec,i.id=lt.MAIN;const u=i.codec;if((u==null?void 0:u.length)===4)switch(u){case"hvc1":case"hev1":i.codec="hvc1.1.6.L120.90";break;case"av01":i.codec="av01.0.04M.08";break;case"avc1":i.codec="avc1.42e01e";break}this.log(`Init video buffer, container:${i.container}, codecs[level/parsed]=[${e.videoCodec||""}/${u}]${i.codec!==u?" parsed-corrected="+i.codec:""}${i.supplemental?" supplemental="+i.supplemental:""}`),delete n.audiovideo}a&&(this.log(`Init audiovideo buffer, container:${a.container}, codecs[level/parsed]=[${e.codecs}/${a.codec}]`),delete n.video,delete n.audio);const c=Object.keys(n);if(c.length){if(this.hls.trigger(W.BUFFER_CODECS,n),!this.hls)return;c.forEach(u=>{const f=n[u].initSegment;f!=null&&f.byteLength&&this.hls.trigger(W.BUFFER_APPENDING,{type:u,data:f,frag:r,part:null,chunkMeta:o,parent:r.type})})}this.tickImmediate()}getMainFwdBufferInfo(){const e=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,lt.MAIN)}get maxBufferLength(){const{levels:e,level:n}=this,r=e==null?void 0:e[n];return r?this.getMaxBufferLength(r.maxBitrate):this.config.maxBufferLength}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=Le.IDLE}checkFragmentChanged(){const e=this.media;let n=null;if(e&&e.readyState>1&&e.seeking===!1){const r=e.currentTime;if(Dt.isBuffered(e,r)?n=this.getAppendedFrag(r):Dt.isBuffered(e,r+.1)&&(n=this.getAppendedFrag(r+.1)),n){this.backtrackFragment=null;const o=this.fragPlaying,s=n.level;(!o||n.sn!==o.sn||o.level!==s)&&(this.fragPlaying=n,this.hls.trigger(W.FRAG_CHANGED,{frag:n}),(!o||o.level!==s)&&this.hls.trigger(W.LEVEL_SWITCHED,{level:s}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){var e;if(this.fragPlaying)return this.fragPlaying;const n=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;return rt(n)?this.getAppendedFrag(n):null}get currentProgramDateTime(){var e;const n=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;if(rt(n)){const r=this.getLevelDetails(),o=this.currentFrag||(r?vl(null,r.fragments,n):null);if(o){const s=o.programDateTime;if(s!==null){const i=s+(n-o.start)*1e3;return new Date(i)}}}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 MX extends Jo{constructor(e,n){super("key-loader",n),this.config=void 0,this.keyIdToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const r in this.keyIdToKeyInfo){const o=this.keyIdToKeyInfo[r].loader;if(o){var n;if(e&&e!==((n=o.context)==null?void 0:n.frag.type))return;o.abort()}}}detach(){for(const e in this.keyIdToKeyInfo){const n=this.keyIdToKeyInfo[e];(n.mediaKeySessionContext||n.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyIdToKeyInfo){const n=this.keyIdToKeyInfo[e].loader;n&&n.destroy()}this.keyIdToKeyInfo={}}createKeyLoadError(e,n=ve.KEY_LOAD_ERROR,r,o,s){return new wi({type:pt.NETWORK_ERROR,details:n,fatal:!1,frag:e,response:s,error:r,networkDetails:o})}loadClear(e,n,r){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(n.length)for(let o=0,s=n.length;o<s;o++){const i=n[o];if(e.cc<=i.cc&&(!Jn(e)||!Jn(i)||e.sn<i.sn)||!r&&o==s-1)return this.emeController.selectKeySystemFormat(i).then(a=>{if(!this.emeController)return;i.setKeyFormat(a);const c=Uh(a);if(c)return this.emeController.getKeySystemAccess([c])})}if(this.config.requireKeySystemAccessOnStart){const o=Ju(this.config);if(o.length)return this.emeController.getKeySystemAccess(o)}}return null}load(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(n=>this.loadInternal(e,n)):this.loadInternal(e)}loadInternal(e,n){var r,o;n&&e.setKeyFormat(n);const s=e.decryptdata;if(!s){const u=new Error(n?`Expected frag.decryptdata to be defined after setting format ${n}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(this.createKeyLoadError(e,ve.KEY_LOAD_ERROR,u))}const i=s.uri;if(!i)return Promise.reject(this.createKeyLoadError(e,ve.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${i}"`)));const a=R0(s);let c=this.keyIdToKeyInfo[a];if((r=c)!=null&&r.decryptdata.key)return s.key=c.decryptdata.key,Promise.resolve({frag:e,keyInfo:c});if(this.emeController&&(o=c)!=null&&o.keyLoadPromise)switch(this.emeController.getKeyStatus(c.decryptdata)){case"usable":case"usable-in-future":return c.keyLoadPromise.then(d=>{const{keyInfo:f}=d;return s.key=f.decryptdata.key,{frag:e,keyInfo:f}})}switch(this.log(`${this.keyIdToKeyInfo[a]?"Rel":"L"}oading${s.keyId?" keyId: "+Er(s.keyId):""} URI: ${s.uri} from ${e.type} ${e.level}`),c=this.keyIdToKeyInfo[a]={decryptdata:s,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},s.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return s.keyFormat==="identity"?this.loadKeyHTTP(c,e):this.loadKeyEME(c,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(c,e);default:return Promise.reject(this.createKeyLoadError(e,ve.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${s.method}"`)))}}loadKeyEME(e,n){const r={frag:n,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var o;if(!e.decryptdata.keyId&&(o=n.initSegment)!=null&&o.data){const i=Yz(n.initSegment.data);if(i.length){let a=i[0];a.some(c=>c!==0)?(this.log(`Using keyId found in init segment ${Er(a)}`),fa.setKeyIdForUri(e.decryptdata.uri,a)):(a=fa.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${Er(a)}`)),e.decryptdata.keyId=a}}if(!e.decryptdata.keyId&&!Jn(n))return Promise.resolve(r);const s=this.emeController.loadKey(r);return(e.keyLoadPromise=s.then(i=>(e.mediaKeySessionContext=i,r))).catch(i=>{throw e.keyLoadPromise=null,"data"in i&&(i.data.frag=n),i})}return Promise.resolve(r)}loadKeyHTTP(e,n){const r=this.config,o=r.loader,s=new o(r);return n.keyLoader=e.loader=s,e.keyLoadPromise=new Promise((i,a)=>{const c={keyInfo:e,frag:n,responseType:"arraybuffer",url:e.decryptdata.uri},u=r.keyLoadPolicy.default,d={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},f={onSuccess:(h,p,m,g)=>{const{frag:y,keyInfo:v}=m,C=R0(v.decryptdata);if(!y.decryptdata||v!==this.keyIdToKeyInfo[C])return a(this.createKeyLoadError(y,ve.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,i({frag:y,keyInfo:v})},onError:(h,p,m,g)=>{this.resetLoader(p),a(this.createKeyLoadError(n,ve.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),m,un({url:c.url,data:void 0},h)))},onTimeout:(h,p,m)=>{this.resetLoader(p),a(this.createKeyLoadError(n,ve.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m))},onAbort:(h,p,m)=>{this.resetLoader(p),a(this.createKeyLoadError(n,ve.INTERNAL_ABORTED,new Error("key loading aborted"),m))}};s.load(c,d,f)})}resetLoader(e){const{frag:n,keyInfo:r,url:o}=e,s=r.loader;n.keyLoader===s&&(n.keyLoader=null,r.loader=null);const i=R0(r.decryptdata)||o;delete this.keyIdToKeyInfo[i],s&&s.destroy()}}function R0(t){if(t.keyFormat!==kr.FAIRPLAY){const e=t.keyId;if(e)return Er(e)}return t.uri}function KE(t){const{type:e}=t;switch(e){case Ht.AUDIO_TRACK:return lt.AUDIO;case Ht.SUBTITLE_TRACK:return lt.SUBTITLE;default:return lt.MAIN}}function L0(t,e){let n=t.url;return(n===void 0||n.indexOf("data:")===0)&&(n=e.url),n}class AX{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(W.MANIFEST_LOADING,this.onManifestLoading,this),e.on(W.LEVEL_LOADING,this.onLevelLoading,this),e.on(W.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(W.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(W.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off(W.MANIFEST_LOADING,this.onManifestLoading,this),e.off(W.LEVEL_LOADING,this.onLevelLoading,this),e.off(W.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(W.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(W.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){const n=this.hls.config,r=n.pLoader,o=n.loader,s=r||o,i=new s(n);return this.loaders[e.type]=i,i}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const n=this.loaders[e];n&&n.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,n){const{url:r}=n;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Ht.MANIFEST,url:r,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,n){const{id:r,level:o,pathwayId:s,url:i,deliveryDirectives:a,levelInfo:c}=n;this.load({id:r,level:o,pathwayId:s,responseType:"text",type:Ht.LEVEL,url:i,deliveryDirectives:a,levelOrTrack:c})}onAudioTrackLoading(e,n){const{id:r,groupId:o,url:s,deliveryDirectives:i,track:a}=n;this.load({id:r,groupId:o,level:null,responseType:"text",type:Ht.AUDIO_TRACK,url:s,deliveryDirectives:i,levelOrTrack:a})}onSubtitleTrackLoading(e,n){const{id:r,groupId:o,url:s,deliveryDirectives:i,track:a}=n;this.load({id:r,groupId:o,level:null,responseType:"text",type:Ht.SUBTITLE_TRACK,url:s,deliveryDirectives:i,levelOrTrack:a})}onLevelsUpdated(e,n){const r=this.loaders[Ht.LEVEL];if(r){const o=r.context;o&&!n.levels.some(s=>s===o.levelOrTrack)&&(r.abort(),delete this.loaders[Ht.LEVEL])}}load(e){var n;const r=this.hls.config;let o=this.getInternalLoader(e);if(o){const u=this.hls.logger,d=o.context;if(d&&d.levelOrTrack===e.levelOrTrack&&(d.url===e.url||d.deliveryDirectives&&!e.deliveryDirectives)){d.url===e.url?u.log(`[playlist-loader]: ignore ${e.url} ongoing request`):u.log(`[playlist-loader]: ignore ${e.url} in favor of ${d.url}`);return}u.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),o.abort()}let s;if(e.type===Ht.MANIFEST?s=r.manifestLoadPolicy.default:s=yn({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),o=this.createInternalLoader(e),rt((n=e.deliveryDirectives)==null?void 0:n.part)){let u;if(e.type===Ht.LEVEL&&e.level!==null?u=this.hls.levels[e.level].details:e.type===Ht.AUDIO_TRACK&&e.id!==null?u=this.hls.audioTracks[e.id].details:e.type===Ht.SUBTITLE_TRACK&&e.id!==null&&(u=this.hls.subtitleTracks[e.id].details),u){const d=u.partTarget,f=u.targetduration;if(d&&f){const h=Math.max(d*3,f*.8)*1e3;s=yn({},s,{maxTimeToFirstByteMs:Math.min(h,s.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,s.maxTimeToFirstByteMs)})}}}const i=s.errorRetry||s.timeoutRetry||{},a={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:i.maxNumRetry||0,retryDelay:i.retryDelayMs||0,maxRetryDelay:i.maxRetryDelayMs||0},c={onSuccess:(u,d,f,h)=>{const p=this.getInternalLoader(f);this.resetInternalLoader(f.type);const m=u.data;d.parsing.start=performance.now(),qs.isMediaPlaylist(m)||f.type!==Ht.MANIFEST?this.handleTrackOrLevelPlaylist(u,d,f,h||null,p):this.handleMasterPlaylist(u,d,f,h)},onError:(u,d,f,h)=>{this.handleNetworkError(d,f,!1,u,h)},onTimeout:(u,d,f)=>{this.handleNetworkError(d,f,!0,void 0,u)}};o.load(e,a,c)}checkAutostartLoad(){if(!this.hls)return;const{config:{autoStartLoad:e,startPosition:n},forceStartLoad:r}=this.hls;(e||r)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${n}`),this.hls.startLoad(n))}handleMasterPlaylist(e,n,r,o){const s=this.hls,i=e.data,a=L0(e,r),c=qs.parseMasterPlaylist(i,a);if(c.playlistParsingError){n.parsing.end=performance.now(),this.handleManifestParsingError(e,r,c.playlistParsingError,o,n);return}const{contentSteering:u,levels:d,sessionData:f,sessionKeys:h,startTimeOffset:p,variableList:m}=c;this.variableList=m,d.forEach(C=>{const{unknownCodecs:S}=C;if(S){const{preferManagedMediaSource:w}=this.hls.config;let{audioCodec:T,videoCodec:I}=C;for(let P=S.length;P--;){const M=S[P];Od(M,"audio",w)?(C.audioCodec=T=T?`${T},${M}`:M,qc.audio[T.substring(0,4)]=2,S.splice(P,1)):Od(M,"video",w)&&(C.videoCodec=I=I?`${I},${M}`:M,qc.video[I.substring(0,4)]=2,S.splice(P,1))}}});const{AUDIO:g=[],SUBTITLES:y,"CLOSED-CAPTIONS":v}=qs.parseMasterPlaylistMedia(i,a,c);g.length&&!g.some(S=>!S.url)&&d[0].audioCodec&&!d[0].attrs.AUDIO&&(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Vn({}),bitrate:0,url:""})),s.trigger(W.MANIFEST_LOADED,{levels:d,audioTracks:g,subtitles:y,captions:v,contentSteering:u,url:a,stats:n,networkDetails:o,sessionData:f,sessionKeys:h,startTimeOffset:p,variableList:m})}handleTrackOrLevelPlaylist(e,n,r,o,s){const i=this.hls,{id:a,level:c,type:u}=r,d=L0(e,r),f=rt(c)?c:rt(a)?a:0,h=KE(r),p=qs.parseLevelPlaylist(e.data,d,f,h,0,this.variableList);if(u===Ht.MANIFEST){const m={attrs:new Vn({}),bitrate:0,details:p,name:"",url:d};p.requestScheduled=n.loading.start+iM(p,0),i.trigger(W.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:d,stats:n,networkDetails:o,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}n.parsing.end=performance.now(),r.levelDetails=p,this.handlePlaylistLoaded(p,e,n,r,o,s)}handleManifestParsingError(e,n,r,o,s){this.hls.trigger(W.ERROR,{type:pt.NETWORK_ERROR,details:ve.MANIFEST_PARSING_ERROR,fatal:n.type===Ht.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:n,networkDetails:o,stats:s})}handleNetworkError(e,n,r=!1,o,s){let i=`A network ${r?"timeout":"error"+(o?" (status "+o.code+")":"")} occurred while loading ${e.type}`;e.type===Ht.LEVEL?i+=`: ${e.level} id: ${e.id}`:(e.type===Ht.AUDIO_TRACK||e.type===Ht.SUBTITLE_TRACK)&&(i+=` id: ${e.id} group-id: "${e.groupId}"`);const a=new Error(i);this.hls.logger.warn(`[playlist-loader]: ${i}`);let c=ve.UNKNOWN,u=!1;const d=this.getInternalLoader(e);switch(e.type){case Ht.MANIFEST:c=r?ve.MANIFEST_LOAD_TIMEOUT:ve.MANIFEST_LOAD_ERROR,u=!0;break;case Ht.LEVEL:c=r?ve.LEVEL_LOAD_TIMEOUT:ve.LEVEL_LOAD_ERROR,u=!1;break;case Ht.AUDIO_TRACK:c=r?ve.AUDIO_TRACK_LOAD_TIMEOUT:ve.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case Ht.SUBTITLE_TRACK:c=r?ve.SUBTITLE_TRACK_LOAD_TIMEOUT:ve.SUBTITLE_LOAD_ERROR,u=!1;break}d&&this.resetInternalLoader(e.type);const f={type:pt.NETWORK_ERROR,details:c,fatal:u,url:e.url,loader:d,context:e,error:a,networkDetails:n,stats:s};if(o){const h=(n==null?void 0:n.url)||e.url;f.response=un({url:h,data:void 0},o)}this.hls.trigger(W.ERROR,f)}handlePlaylistLoaded(e,n,r,o,s,i){const a=this.hls,{type:c,level:u,levelOrTrack:d,id:f,groupId:h,deliveryDirectives:p}=o,m=L0(n,o),g=KE(o);let y=typeof o.level=="number"&&g===lt.MAIN?u:void 0;const v=e.playlistParsingError;if(v){if(this.hls.logger.warn(`${v} ${e.url}`),!a.config.ignorePlaylistParsingErrors){a.trigger(W.ERROR,{type:pt.NETWORK_ERROR,details:ve.LEVEL_PARSING_ERROR,fatal:!1,url:m,error:v,reason:v.message,response:n,context:o,level:y,parent:g,networkDetails:s,stats:r});return}e.playlistParsingError=null}if(!e.fragments.length){const C=e.playlistParsingError=new Error("No Segments found in Playlist");a.trigger(W.ERROR,{type:pt.NETWORK_ERROR,details:ve.LEVEL_EMPTY_ERROR,fatal:!1,url:m,error:C,reason:C.message,response:n,context:o,level:y,parent:g,networkDetails:s,stats:r});return}switch(e.live&&i&&(i.getCacheAge&&(e.ageHeader=i.getCacheAge()||0),(!i.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),c){case Ht.MANIFEST:case Ht.LEVEL:if(y){if(!d)y=0;else if(d!==a.levels[y]){const C=a.levels.indexOf(d);C>-1&&(y=C)}}a.trigger(W.LEVEL_LOADED,{details:e,levelInfo:d||a.levels[0],level:y||0,id:f||0,stats:r,networkDetails:s,deliveryDirectives:p,withoutMultiVariant:c===Ht.MANIFEST});break;case Ht.AUDIO_TRACK:a.trigger(W.AUDIO_TRACK_LOADED,{details:e,track:d,id:f||0,groupId:h||"",stats:r,networkDetails:s,deliveryDirectives:p});break;case Ht.SUBTITLE_TRACK:a.trigger(W.SUBTITLE_TRACK_LOADED,{details:e,track:d,id:f||0,groupId:h||"",stats:r,networkDetails:s,deliveryDirectives:p});break}}}class Hs{static get version(){return Bd}static isMSESupported(){return sA()}static isSupported(){return IX()}static getMediaSource(){return ba()}static get Events(){return W}static get MetadataSchema(){return yo}static get ErrorTypes(){return pt}static get ErrorDetails(){return ve}static get DefaultConfig(){return Hs.defaultConfig?Hs.defaultConfig:pX}static set DefaultConfig(e){Hs.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Ev,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.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;const n=this.logger=Nz(e.debug||!1,"Hls instance",e.assetPlayerId),r=this.config=gX(Hs.DefaultConfig,e,n);this.userConfig=e,r.progressive&&yX(r,n);const{abrController:o,bufferController:s,capLevelController:i,errorController:a,fpsController:c}=r,u=new a(this),d=this.abrController=new o(this),f=new RW(this),h=r.interstitialsController,p=h?this.interstitialsController=new h(this,Hs):null,m=this.bufferController=new s(this,f),g=this.capLevelController=new i(this),y=new c(this),v=new AX(this),C=r.contentSteeringController,S=C?new C(this):null,w=this.levelController=new EX(this,S),T=new wX(this),I=new MX(this.config,this.logger),P=this.streamController=new DX(this,f,I),M=this.gapController=new CX(this,f);g.setStreamController(P),y.setStreamController(P);const D=[v,w,P];p&&D.splice(1,0,p),S&&D.splice(1,0,S),this.networkControllers=D;const k=[d,m,M,g,y,T,f];this.audioTrackController=this.createController(r.audioTrackController,D);const A=r.audioStreamController;A&&D.push(this.audioStreamController=new A(this,f,I)),this.subtitleTrackController=this.createController(r.subtitleTrackController,D);const E=r.subtitleStreamController;E&&D.push(this.subtititleStreamController=new E(this,f,I)),this.createController(r.timelineController,k),I.emeController=this.emeController=this.createController(r.emeController,k),this.cmcdController=this.createController(r.cmcdController,k),this.latencyController=this.createController(TX,k),this.coreComponents=k,D.push(u);const L=u.onErrorOut;typeof L=="function"&&this.on(W.ERROR,L,u),this.on(W.MANIFEST_LOADED,v.onManifestLoaded,v)}createController(e,n){if(e){const r=new e(this);return n&&n.push(r),r}return null}on(e,n,r=this){this._emitter.on(e,n,r)}once(e,n,r=this){this._emitter.once(e,n,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,n,r=this,o){this._emitter.off(e,n,r,o)}listeners(e){return this._emitter.listeners(e)}emit(e,n,r){return this._emitter.emit(e,n,r)}trigger(e,n){if(this.config.debug)return this.emit(e,e,n);try{return this.emit(e,e,n)}catch(r){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+r.message+'". Here is a stacktrace:',r),!this.triggeringException){this.triggeringException=!0;const o=e===W.ERROR;this.trigger(W.ERROR,{type:pt.OTHER_ERROR,details:ve.INTERNAL_EXCEPTION,fatal:o,event:e,error:r}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){this.logger.log("destroy"),this.trigger(W.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(n=>n.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(n=>n.destroy()),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){if(!e||"media"in e&&!e.media){const s=new Error(`attachMedia failed: invalid argument (${e})`);this.trigger(W.ERROR,{type:pt.OTHER_ERROR,details:ve.ATTACH_MEDIA_ERROR,fatal:!0,error:s});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());const n="media"in e,r=n?e.media:e,o=n?e:{media:r};this._media=r,this.trigger(W.MEDIA_ATTACHING,o)}detachMedia(){this.logger.log("detachMedia"),this.trigger(W.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const e=this.bufferController.transferMedia();return this.trigger(W.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();const n=this.media,r=this._url,o=this._url=pv.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${o}`),n&&r&&(r!==o||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(n)),this.trigger(W.MANIFEST_LOADING,{url:e})}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(e=-1,n){this.logger.log(`startLoad(${e+(n?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(let r=0;r<this.networkControllers.length&&(this.networkControllers[r].startLoad(e,n),!(!this.started||!this.networkControllers));r++);}stopLoad(){this.logger.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!(this.started||!this.networkControllers));e++);}get loadingEnabled(){return this.started}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()}))}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()}))}get inFlightFragments(){const e={[lt.MAIN]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[lt.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[lt.SUBTITLE]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){this.logger.log("recoverMediaError");const e=this._media,n=e==null?void 0:e.currentTime;this.detachMedia(),e&&(this.attachMedia(e),n&&this.startLoad(n))}removeLevel(e){this.levelController.removeLevel(e)}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=CY()),e}get levels(){const e=this.levelController.levels;return e||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){this.logger.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){this.logger.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){this.logger.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 n=!!e;n!==this.config.capLevelToPlayerSize&&(n?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=n)}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 abrEwmaDefaultEstimate(){const{bwEstimator:e}=this.abrController;return e?e.defaultEstimate:NaN}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){gW(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:n}}=this;if(!e)return 0;const r=e.length;for(let o=0;o<r;o++)if(e[o].maxBitrate>=n)return o;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:n,maxHdcpLevel:r}=this;let o;if(n===-1&&e!=null&&e.length?o=e.length-1:o=n,r)for(let s=o;s--;){const i=e[s].attrs["HDCP-LEVEL"];if(i&&i<=r)return s}return o}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()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var n;return((n=this.audioTrackController)==null?void 0:n.setAudioOption(e))||null}setSubtitleOption(e){var n;return((n=this.subtitleTrackController)==null?void 0:n.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 n=this.audioTrackController;n&&(n.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 n=this.subtitleTrackController;n&&(n.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){const n=this.subtitleTrackController;n&&(n.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}set targetLatency(e){this.latencyController.targetLatency=e}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(e){this.levelController.pathwayPriority=e}get bufferedToEnd(){var e;return!!((e=this.bufferController)!=null&&e.bufferedToEnd)}get interstitialsManager(){var e;return((e=this.interstitialsController)==null?void 0:e.interstitialsManager)||null}getMediaDecodingInfo(e,n=this.allAudioTracks){const r=zD(n);return UD(e,r,navigator.mediaCapabilities)}}Hs.defaultConfig=void 0;const ul=(t,e,n,r,o)=>{if(n<=1)return{panX:0,panY:0};const s=r*(1-1/n)/2,i=o*(1-1/n)/2;return{panX:Math.max(-s,Math.min(s,t)),panY:Math.max(-i,Math.min(i,e))}},iA=(t,e)=>{if(t.length===0)return-1;let n=0,r=Math.abs(t[0]-e);for(let o=1;o<t.length;o++){const s=Math.abs(t[o]-e);s<r&&(n=o,r=s)}return n},aA=t=>{const{direction:e,pointerX:n,pointerY:r,zoom:o,panX:s,panY:i,zoomLevels:a,width:c,height:u}=t;if(a.length===0)return null;const d=iA(a,o),f=Math.max(0,Math.min(a.length-1,d+e)),h=a[f];if(h===o)return null;if(h<=1)return{zoom:h,panX:0,panY:0};const p=n-c/2,m=r-u/2,g=1/h-1/o,y=s+p*g,v=i+m*g,C=ul(y,v,h,c,u);return{zoom:h,panX:C.panX,panY:C.panY}},Rm=t=>t.seekable&&t.seekable.length>0?t.seekable.end(t.seekable.length-1):Number.isFinite(t.duration)&&t.duration>0?t.duration:t.currentTime,YE=t=>{if(!Number.isFinite(t)||t<0)return"0:00";const e=Math.floor(t),n=Math.floor(e/3600),r=Math.floor(e%3600/60),o=e%60;return n>0?`${n}:${r.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}`:`${r}:${o.toString().padStart(2,"0")}`},RX=(t,e,n)=>({...t&&{"--player-width":typeof t=="number"?`${t}px`:t},...e&&{"--player-height":typeof e=="number"?`${e}px`:e},...n&&{"--player-aspect-ratio":n}}),Di={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};function lA(t){return"init"in t}function Ey(t){return!!t.write}function XE(t){return"v"in t||"e"in t}function Dp(t){if("e"in t)throw t.e;if((Di?"production":void 0)!=="production"&&!("v"in t))throw new Error("[Bug] atom state is not initialized");return t.v}const Mp=new WeakMap;function cA(t){var e;return Ap(t)&&!!((e=Mp.get(t))!=null&&e[0])}function LX(t){const e=Mp.get(t);e!=null&&e[0]&&(e[0]=!1,e[1].forEach(n=>n()))}function Iy(t,e){let n=Mp.get(t);if(!n){n=[!0,new Set],Mp.set(t,n);const r=()=>{n[0]=!1};t.then(r,r)}n[1].add(e)}function Ap(t){return typeof(t==null?void 0:t.then)=="function"}function uA(t,e,n){if(!n.p.has(t)){n.p.add(t);const r=()=>n.p.delete(t);e.then(r,r)}}function dA(t,e,n){var r;const o=new Set;for(const s of((r=n.get(t))==null?void 0:r.t)||[])o.add(s);for(const s of e.p)o.add(s);return o}const _X=(t,e,...n)=>e.read(...n),OX=(t,e,...n)=>e.write(...n),FX=(t,e)=>{if(e.INTERNAL_onInit)return e.INTERNAL_onInit(t);if(e.unstable_onInit)return console.warn("[DEPRECATED] atom.unstable_onInit is renamed to atom.INTERNAL_onInit."),e.unstable_onInit(t)},NX=(t,e,n)=>{var r;return(r=e.onMount)==null?void 0:r.call(e,n)},BX=(t,e)=>{var n;const r=Or(t),o=r[0],s=r[6],i=r[9];if((Di?"production":void 0)!=="production"&&!e)throw new Error("Atom is undefined or null");let a=o.get(e);return a||(a={d:new Map,p:new Set,n:0},o.set(e,a),(n=s.i)==null||n.call(s,e),i==null||i(t,e)),a},$X=t=>{const e=Or(t),n=e[1],r=e[3],o=e[4],s=e[5],i=e[6],a=e[13],c=[],u=d=>{try{d()}catch(f){c.push(f)}};do{i.f&&u(i.f);const d=new Set,f=d.add.bind(d);r.forEach(h=>{var p;return(p=n.get(h))==null?void 0:p.l.forEach(f)}),r.clear(),s.forEach(f),s.clear(),o.forEach(f),o.clear(),d.forEach(u),r.size&&a(t)}while(r.size||s.size||o.size);if(c.length)throw new AggregateError(c)},jX=t=>{const e=Or(t),n=e[1],r=e[2],o=e[3],s=e[11],i=e[14],a=e[17],c=[],u=new WeakSet,d=new WeakSet,f=Array.from(o);for(;f.length;){const h=f[f.length-1],p=s(t,h);if(d.has(h)){f.pop();continue}if(u.has(h)){if(r.get(h)===p.n)c.push([h,p]);else if((Di?"production":void 0)!=="production"&&r.has(h))throw new Error("[Bug] invalidated atom exists");d.add(h),f.pop();continue}u.add(h);for(const m of dA(h,p,n))u.has(m)||f.push(m)}for(let h=c.length-1;h>=0;--h){const[p,m]=c[h];let g=!1;for(const y of m.d.keys())if(y!==p&&o.has(y)){g=!0;break}g&&(i(t,p),a(t,p)),r.delete(p)}},ky=new WeakSet,VX=(t,e)=>{var n,r;const o=Or(t),s=o[1],i=o[2],a=o[3],c=o[6],u=o[7],d=o[11],f=o[12],h=o[13],p=o[14],m=o[16],g=o[17],y=o[20],v=d(t,e);if(XE(v)){if(s.has(e)&&i.get(e)!==v.n)return v;let D=!1;for(const[k,A]of v.d)if(p(t,k).n!==A){D=!0;break}if(!D)return v}v.d.clear();let C=!0;function S(){s.has(e)&&(g(t,e),h(t),f(t))}function w(D){var k;if(D===e){const E=d(t,D);if(!XE(E))if(lA(D))y(t,D,D.init);else throw new Error("no atom init");return Dp(E)}const A=p(t,D);try{return Dp(A)}finally{v.d.set(D,A.n),cA(v.v)&&uA(e,v.v,A),s.has(e)&&((k=s.get(D))==null||k.t.add(e)),C||S()}}let T,I;const P={get signal(){return T||(T=new AbortController),T.signal},get setSelf(){return(Di?"production":void 0)!=="production"&&!Ey(e)&&console.warn("setSelf function cannot be used with read-only atom"),!I&&Ey(e)&&(I=(...D)=>{if((Di?"production":void 0)!=="production"&&C&&console.warn("setSelf function cannot be called in sync"),!C)try{return m(t,e,...D)}finally{h(t),f(t)}}),I}},M=v.n;try{(Di?"production":void 0)!=="production"&&ky.delete(t);const D=u(t,e,w,P);return(Di?"production":void 0)!=="production"&&ky.has(t)&&console.warn("Detected store mutation during atom read. This is not supported."),y(t,e,D),Ap(D)&&(Iy(D,()=>T==null?void 0:T.abort()),D.then(S,S)),(n=c.r)==null||n.call(c,e),v}catch(D){return delete v.v,v.e=D,++v.n,v}finally{C=!1,M!==v.n&&i.get(e)===M&&(i.set(e,v.n),a.add(e),(r=c.c)==null||r.call(c,e))}},HX=(t,e)=>{const n=Or(t),r=n[1],o=n[2],s=n[11],i=[e];for(;i.length;){const a=i.pop(),c=s(t,a);for(const u of dA(a,c,r)){const d=s(t,u);o.set(u,d.n),i.push(u)}}},UX=(t,e,...n)=>{const r=Or(t),o=r[3],s=r[6],i=r[8],a=r[11],c=r[12],u=r[13],d=r[14],f=r[15],h=r[16],p=r[17],m=r[20];let g=!0;const y=C=>Dp(d(t,C)),v=(C,...S)=>{var w;const T=a(t,C);try{if(C===e){if(!lA(C))throw new Error("atom not writable");(Di?"production":void 0)!=="production"&&ky.add(t);const I=T.n,P=S[0];m(t,C,P),p(t,C),I!==T.n&&(o.add(C),f(t,C),(w=s.c)==null||w.call(s,C));return}else return h(t,C,...S)}finally{g||(u(t),c(t))}};try{return i(t,e,y,v,...n)}finally{g=!1}},GX=(t,e)=>{var n;const r=Or(t),o=r[1],s=r[3],i=r[6],a=r[11],c=r[15],u=r[18],d=r[19],f=a(t,e),h=o.get(e);if(h&&!cA(f.v)){for(const[p,m]of f.d)if(!h.d.has(p)){const g=a(t,p);u(t,p).t.add(e),h.d.add(p),m!==g.n&&(s.add(p),c(t,p),(n=i.c)==null||n.call(i,p))}for(const p of h.d)if(!f.d.has(p)){h.d.delete(p);const m=d(t,p);m==null||m.t.delete(e)}}},zX=(t,e)=>{var n;const r=Or(t),o=r[1],s=r[4],i=r[6],a=r[10],c=r[11],u=r[12],d=r[13],f=r[14],h=r[16],p=r[18],m=c(t,e);let g=o.get(e);if(!g){f(t,e);for(const y of m.d.keys())p(t,y).t.add(e);if(g={l:new Set,d:new Set(m.d.keys()),t:new Set},o.set(e,g),Ey(e)){const y=()=>{let v=!0;const C=(...S)=>{try{return h(t,e,...S)}finally{v||(d(t),u(t))}};try{const S=a(t,e,C);S&&(g.u=()=>{v=!0;try{S()}finally{v=!1}})}finally{v=!1}};s.add(y)}(n=i.m)==null||n.call(i,e)}return g},WX=(t,e)=>{var n,r;const o=Or(t),s=o[1],i=o[5],a=o[6],c=o[11],u=o[19],d=c(t,e);let f=s.get(e);if(!f||f.l.size)return f;let h=!1;for(const p of f.t)if((n=s.get(p))!=null&&n.d.has(e)){h=!0;break}if(!h){f.u&&i.add(f.u),f=void 0,s.delete(e);for(const p of d.d.keys()){const m=u(t,p);m==null||m.t.delete(e)}(r=a.u)==null||r.call(a,e);return}return f},qX=(t,e,n)=>{const r=Or(t)[11],o=r(t,e),s="v"in o,i=o.v;if(Ap(n))for(const a of o.d.keys())uA(e,n,r(t,a));o.v=n,delete o.e,(!s||!Object.is(i,o.v))&&(++o.n,Ap(i)&&LX(i))},KX=(t,e)=>{const n=Or(t)[14];return Dp(n(t,e))},YX=(t,e,...n)=>{const r=Or(t),o=r[12],s=r[13],i=r[16];try{return i(t,e,...n)}finally{s(t),o(t)}},XX=(t,e,n)=>{const r=Or(t),o=r[12],s=r[18],i=r[19],c=s(t,e).l;return c.add(n),o(t),()=>{c.delete(n),i(t,e),o(t)}},fA=new WeakMap,Or=t=>{const e=fA.get(t);if((Di?"production":void 0)!=="production"&&!e)throw new Error("Store must be created by buildStore to read its building blocks");return e};function ZX(...t){const e={get(r){const o=Or(e)[21];return o(e,r)},set(r,...o){const s=Or(e)[22];return s(e,r,...o)},sub(r,o){const s=Or(e)[23];return s(e,r,o)}},n=[new WeakMap,new WeakMap,new WeakMap,new Set,new Set,new Set,{},_X,OX,FX,NX,BX,$X,jX,VX,HX,UX,GX,zX,WX,qX,KX,YX,XX,void 0].map((r,o)=>t[o]||r);return fA.set(e,Object.freeze(n)),e}const hA={};let QX=0;function Bv(t,e){const n=`atom${++QX}`,r={toString(){return(hA?"production":void 0)!=="production"&&this.debugLabel?n+":"+this.debugLabel:n}};return typeof t=="function"?r.read=t:(r.init=t,r.read=JX,r.write=eZ),r}function JX(t){return t(this)}function eZ(t,e,n){return e(this,typeof n=="function"?n(t(this)):n)}function tZ(){return ZX()}let Du;function nZ(){return Du||(Du=tZ(),(hA?"production":void 0)!=="production"&&(globalThis.__JOTAI_DEFAULT_STORE__||(globalThis.__JOTAI_DEFAULT_STORE__=Du),globalThis.__JOTAI_DEFAULT_STORE__!==Du&&console.warn("Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"))),Du}const rZ={},oZ=$.createContext(void 0);function pA(t){return $.useContext(oZ)||nZ()}const Py=t=>typeof(t==null?void 0:t.then)=="function",Dy=t=>{t.status||(t.status="pending",t.then(e=>{t.status="fulfilled",t.value=e},e=>{t.status="rejected",t.reason=e}))},sZ=$.use||(t=>{if(t.status==="pending")throw t;if(t.status==="fulfilled")return t.value;throw t.status==="rejected"?t.reason:(Dy(t),t)}),_0=new WeakMap,ZE=(t,e)=>{let n=_0.get(t);return n||(n=new Promise((r,o)=>{let s=t;const i=u=>d=>{s===u&&r(d)},a=u=>d=>{s===u&&o(d)},c=()=>{try{const u=e();Py(u)?(_0.set(u,n),s=u,u.then(i(u),a(u)),Iy(u,c)):r(u)}catch(u){o(u)}};t.then(i(t),a(t)),Iy(t,c)}),_0.set(t,n)),n};function mA(t,e){const{delay:n,unstable_promiseStatus:r=!$.use}={},o=pA(),[[s,i,a],c]=$.useReducer(d=>{const f=o.get(t);return Object.is(d[0],f)&&d[1]===o&&d[2]===t?d:[f,o,t]},void 0,()=>[o.get(t),o,t]);let u=s;if((i!==o||a!==t)&&(c(),u=o.get(t)),$.useEffect(()=>{const d=o.sub(t,()=>{if(r)try{const f=o.get(t);Py(f)&&Dy(ZE(f,()=>o.get(t)))}catch{}if(typeof n=="number"){setTimeout(c,n);return}c()});return c(),d},[o,t,n,r]),$.useDebugValue(u),Py(u)){const d=ZE(u,()=>o.get(t));return r&&Dy(d),sZ(d)}return u}function iZ(t,e){const n=pA();return $.useCallback((...o)=>{if((rZ?"production":void 0)!=="production"&&!("write"in t))throw new Error("not writable atom");return n.set(t,...o)},[n,t])}function Rp(t,e){return[mA(t),iZ(t)]}const gA=Bv(0),yA=Bv(!0),aZ=Bv(null),bA=$.createContext(null),vA=$.createContext(null),xA=({children:t})=>{const e=$.useRef(null),[n,r]=Rp(gA),[o,s]=Rp(yA),[i,a]=$.useState(!1),[c,u]=$.useState(0),[d,f]=$.useState(!1),h=$.useRef(i);h.current=i,$.useEffect(()=>{const I=e.current;if(!I)return;const P=()=>{if(I.seekable&&I.seekable.length>0){const k=I.seekable.end(I.seekable.length-1);u(k),f(k>0)}else I.duration&&isFinite(I.duration)&&(u(I.duration),f(!0))},M=()=>a(!0),D=()=>a(!1);return I.addEventListener("durationchange",P),I.addEventListener("loadedmetadata",P),I.addEventListener("play",M),I.addEventListener("pause",D),P(),()=>{I.removeEventListener("durationchange",P),I.removeEventListener("loadedmetadata",P),I.removeEventListener("play",M),I.removeEventListener("pause",D)}},[]);const p=$.useCallback(I=>{r(I)},[r]),m=$.useCallback(I=>{s(I)},[s]),g=$.useRef(d);g.current=d;const y=$.useCallback(I=>{const P=e.current;!P||!g.current||(P.currentTime=I,r(I),s(!1))},[r,s]),v=$.useCallback(async()=>{const I=e.current;if(I)try{await I.play(),a(!0)}catch(P){console.error("Failed to play video:",P)}},[]),C=$.useCallback(()=>{const I=e.current;I&&(I.pause(),a(!1))},[]),S=$.useCallback(()=>{h.current?C():v()},[v,C]),w=$.useMemo(()=>({videoRef:e,setCurrentTime:p,setIsLive:m,seekTo:y,play:v,pause:C,togglePlay:S}),[p,m,y,v,C,S]),T=$.useMemo(()=>({currentTime:n,isLive:o,isPlaying:i,duration:c,canSeek:d}),[n,o,i,c,d]);return b.jsx(bA.Provider,{value:w,children:b.jsx(vA.Provider,{value:T,children:t})})},Lm=()=>{const t=$.useContext(bA),e=$.useContext(vA);return $.useMemo(()=>!t||!e?null:{...t,...e},[t,e])},lZ=()=>{const t=Lm();if(!t)throw new Error("useVideoControlRequired must be used within a VideoControlProvider. Wrap your VideoPlayer and VideoTimeline with <VideoControlProvider>.");return t};function cZ(t){return/\.m3u8(\?|$)/i.test(t)}function uZ(t,e){if(t===e)return!0;if(!t||!e)return!1;const n=t.getTracks().map(o=>o.id).sort(),r=e.getTracks().map(o=>o.id).sort();return n.length===r.length&&n.every((o,s)=>o===r[s])}const dZ=({stream:t,availableQualities:e,initialQuality:n,autoPlay:r,liveThresholdSeconds:o,allowPlaybackRateForStream:s})=>{const i=$.useRef(null),a=Lm(),c=$.useRef(null),u=$.useCallback(oe=>{c.current=oe,a!=null&&a.videoRef&&(a.videoRef.current=oe)},[a]),d=$.useMemo(()=>{if(!e||!e.length)return null;if(n){const oe=e.find(ce=>ce.value===n);if(oe)return oe}return e[0]},[e,n]),[f,h]=$.useState(d),[p,m]=$.useState(!1),[g,y]=$.useState(!0),[v,C]=$.useState(!1),[S,w]=$.useState(0),[T,I]=$.useState(0),[P,M]=$.useState(1),[D,k]=$.useState(1),[A,E]=$.useState(0),[L,O]=$.useState(0),_=$.useRef(!1),R=$.useRef({x:0,y:0}),B=$.useRef({x:0,y:0}),j=$.useRef(!1),[U,V]=$.useState(!1),[F,H]=$.useState(!0),[z,q]=$.useState(!1),[K,Y]=$.useState(!1),J=$.useRef(null),X=(f==null?void 0:f.stream)??t??null,ee=(f==null?void 0:f.src)??null,te=!!!X||s,ne=$.useCallback(()=>{const oe=c.current;m(!!(oe&&!oe.paused&&!oe.ended))},[]);$.useEffect(()=>{h(d)},[d]);const se=$.useRef(!1),ae=$.useRef({seekableEnd:0,currentTime:0,canSeek:!1,isLive:!0}),pe=$.useCallback(()=>{const oe=c.current;if(!oe)return;if(!oe.seekable||oe.seekable.length===0){y(!0),C(!1),a&&a.setIsLive(!0);return}const ce=Rm(oe),ie=Math.max(0,ce-oe.currentTime);ae.current={seekableEnd:ce,currentTime:oe.currentTime,canSeek:ce>0,isLive:ie<=(o??2)},se.current||(se.current=!0,requestAnimationFrame(()=>{se.current=!1;const ge=ae.current;I(ge.seekableEnd),w(ge.currentTime),C(ge.canSeek),y(ge.isLive),a&&(a.setCurrentTime(ge.currentTime),a.setIsLive(ge.isLive))}))},[o,a]);return $.useEffect(()=>{const oe=c.current;if(!oe)return;const ce=()=>ne(),ie=()=>ne(),ge=()=>H(!0),he=()=>H(!0),Z=()=>H(!1),Q=()=>{H(!1),ne()},de=()=>q(!0),ue=()=>q(!1),fe=()=>ne(),me=()=>{Y(!0),H(!1),ne()};return oe.addEventListener("play",ce),oe.addEventListener("pause",ie),oe.addEventListener("ended",fe),oe.addEventListener("emptied",fe),oe.addEventListener("waiting",ge),oe.addEventListener("loadstart",he),oe.addEventListener("canplay",Z),oe.addEventListener("playing",Q),oe.addEventListener("seeking",de),oe.addEventListener("seeked",ue),oe.addEventListener("error",me),oe.addEventListener("timeupdate",pe),oe.addEventListener("durationchange",pe),oe.addEventListener("loadedmetadata",pe),oe.addEventListener("progress",pe),()=>{oe.removeEventListener("play",ce),oe.removeEventListener("pause",ie),oe.removeEventListener("ended",fe),oe.removeEventListener("emptied",fe),oe.removeEventListener("waiting",ge),oe.removeEventListener("loadstart",he),oe.removeEventListener("canplay",Z),oe.removeEventListener("playing",Q),oe.removeEventListener("seeking",de),oe.removeEventListener("seeked",ue),oe.removeEventListener("error",me),oe.removeEventListener("timeupdate",pe),oe.removeEventListener("durationchange",pe),oe.removeEventListener("loadedmetadata",pe),oe.removeEventListener("progress",pe)}},[ne,pe]),$.useEffect(()=>{const oe=c.current;if(oe){if(J.current&&(J.current.destroy(),J.current=null),H(!0),Y(!1),m(!1),X)uZ(oe.srcObject,X)||(oe.srcObject=X),oe.getAttribute("src")&&oe.removeAttribute("src");else if(ee)if(oe.srcObject&&(oe.srcObject=null),cZ(ee)&&Hs.isSupported()){const ce=new Hs({manifestLoadingRetryDelay:2e3,manifestLoadingMaxRetry:10,levelLoadingRetryDelay:2e3,levelLoadingMaxRetry:10,fragLoadingRetryDelay:2e3,fragLoadingMaxRetry:10});J.current=ce,ce.on(Hs.Events.ERROR,(ie,ge)=>{ge.fatal&&(Y(!0),H(!1),ce.destroy(),J.current=null)}),ce.loadSource(ee),ce.attachMedia(oe)}else oe.src!==ee&&(oe.src=ee,oe.load());else oe.srcObject&&(oe.srcObject=null),oe.getAttribute("src")&&oe.removeAttribute("src");return r&&oe.play().then(()=>ne()).catch(()=>ne()),()=>{J.current&&(J.current.destroy(),J.current=null)}}},[X,ee,r,ne]),$.useEffect(()=>{const oe=c.current;oe&&(te?oe.playbackRate=P:(oe.playbackRate=1,M(1)))},[P,te]),$.useEffect(()=>{D<=1&&(E(0),O(0))},[D]),$.useEffect(()=>{const oe=()=>{V(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",oe),()=>{document.removeEventListener("fullscreenchange",oe)}},[]),$.useEffect(()=>{if(D<=1)return;const oe=i.current;if(!oe)return;const ce=requestAnimationFrame(()=>{const ie=oe.getBoundingClientRect(),ge=ul(A,L,D,ie.width,ie.height);E(ge.panX),O(ge.panY)});return()=>cancelAnimationFrame(ce)},[U]),{containerRef:i,videoRef:c,setVideoRef:u,selectedQuality:f,setSelectedQuality:h,isPlaying:p,isLive:g,canSeek:v,currentTime:S,setCurrentTime:w,seekableEnd:T,playbackRate:P,setPlaybackRate:M,zoom:D,setZoom:k,panX:A,setPanX:E,panY:L,setPanY:O,isDraggingRef:_,dragStartRef:R,panStartRef:B,didDragRef:j,isFullscreen:U,isLoading:F,isSeeking:z,hasError:K,canAdjustPlaybackRate:te,updateLiveStatus:pe,syncPlaybackState:ne}},fZ=60;function CA({targetRef:t,zoomLevels:e,zoom:n,panX:r,panY:o,onChange:s,enabled:i=!0}){const a=$.useRef(n),c=$.useRef(r),u=$.useRef(o),d=$.useRef(e),f=$.useRef(s),h=$.useRef(0);a.current=n,c.current=r,u.current=o,d.current=e,f.current=s,$.useEffect(()=>{const p=t.current;if(!p||!i)return;const m=g=>{const y=p.getBoundingClientRect(),v=aA({direction:g.deltaY<0?1:-1,pointerX:g.clientX-y.left,pointerY:g.clientY-y.top,zoom:a.current,panX:c.current,panY:u.current,zoomLevels:d.current,width:y.width,height:y.height});if(!v)return;g.preventDefault();const C=performance.now();C-h.current<fZ||(h.current=C,f.current(v))};return p.addEventListener("wheel",m,{passive:!1}),()=>p.removeEventListener("wheel",m)},[t,i])}const hZ=6,pZ=(t,e,n,r=hZ)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return{zoom:1,panX:0,panY:0};const o=Math.min(e/t.width,n/t.height),s=Math.max(1,Math.min(r,o));if(s<=1)return{zoom:1,panX:0,panY:0};const i=t.x+t.width/2,a=t.y+t.height/2,c=i-e/2,u=a-n/2,d=ul(-c,-u,s,e,n);return{zoom:s,panX:d.panX,panY:d.panY}},QE=8,mZ=({enabled:t,containerRef:e,videoRef:n,isLive:r,zoomRef:o,applyZoom:s})=>{const[i,a]=$.useState(null),c=$.useRef(!1),u=$.useRef(!1),d=$.useRef({x:0,y:0}),f=$.useRef(!1),h=$.useCallback(S=>{const w=e.current;if(!w)return null;const T=w.getBoundingClientRect();return{x:S.clientX-T.left,y:S.clientY-T.top,width:T.width,height:T.height}},[e]),p=$.useCallback(()=>{if(r||!f.current)return;f.current=!1;const S=n.current;S&&S.play().catch(()=>{})},[r,n]),m=$.useCallback(S=>{if(!t||S.button!==0||(o.current??1)>1)return!1;const w=h(S);return w?(c.current=!0,u.current=!1,f.current=!1,d.current={x:w.x,y:w.y},a({x:w.x,y:w.y,width:0,height:0}),!0):!1},[t,h,o]),g=$.useCallback(S=>{if(!c.current)return!1;const w=h(S);if(!w)return!0;const T=d.current.x,I=d.current.y,P=w.x-T,M=w.y-I;if(!u.current&&(Math.abs(P)>QE||Math.abs(M)>QE)&&(u.current=!0,!r)){const D=n.current;D&&(f.current=!D.paused,D.pause())}return a({x:Math.min(T,w.x),y:Math.min(I,w.y),width:Math.abs(P),height:Math.abs(M)}),!0},[h,r,n]),y=$.useCallback(S=>{if(!c.current)return!1;c.current=!1;const w=u.current;u.current=!1;const T=h(S);if(a(null),!w)return!1;if(T){const I=d.current.x,P=d.current.y,M={x:Math.min(I,T.x),y:Math.min(P,T.y),width:Math.abs(T.x-I),height:Math.abs(T.y-P)};s(pZ(M,T.width,T.height))}return p(),!0},[s,h,p]),v=$.useCallback(()=>c.current?(c.current=!1,u.current=!1,a(null),p(),!0):!1,[p]),C=$.useCallback(()=>{t&&s({zoom:1,panX:0,panY:0})},[s,t]);return{selectionRect:i,handleMouseDown:m,handleMouseMove:g,handleMouseUp:y,handleMouseLeave:v,handleDoubleClick:C}},gZ="_container_16vnv_1",yZ="_loader_16vnv_78",bZ="_loaderInitial_16vnv_89",vZ="_spinner_16vnv_93",xZ="_video_16vnv_116",CZ="_videoZoomed_16vnv_124",SZ="_videoAreaZooming_16vnv_132",wZ="_areaSelection_16vnv_136",TZ="_timestampOverlay_16vnv_146",EZ="_timestampText_16vnv_159",IZ="_badgeFloating_16vnv_171",kZ="_controlsOverlay_16vnv_178",PZ="_controlsVisible_16vnv_202",DZ="_timeline_16vnv_207",MZ="_controlsRow_16vnv_214",AZ="_controlGroup_16vnv_232",RZ="_iconButton_16vnv_249",LZ="_menuButton_16vnv_300",_Z="_liveBadge_16vnv_310",OZ="_liveBadgeInactive_16vnv_328",FZ="_liveBadgeActive_16vnv_338",NZ="_recordingDot_16vnv_367",BZ="_goLiveButton_16vnv_383",$Z="_emptyState_16vnv_401",jZ="_emptyStateText_16vnv_418",VZ="_controlMenuWrapper_16vnv_424",HZ="_zoomControl_16vnv_442",UZ="_zoomValue_16vnv_449",GZ="_playbackTime_16vnv_456",zZ="_watermarkOverlay_16vnv_474",WZ="_watermarkImage_16vnv_483",At={container:gZ,loader:yZ,loaderInitial:bZ,spinner:vZ,video:xZ,videoZoomed:CZ,videoAreaZooming:SZ,areaSelection:wZ,timestampOverlay:TZ,timestampText:EZ,badgeFloating:IZ,controlsOverlay:kZ,controlsVisible:PZ,timeline:DZ,controlsRow:MZ,controlGroup:AZ,iconButton:RZ,menuButton:LZ,liveBadge:_Z,liveBadgeInactive:OZ,liveBadgeActive:FZ,recordingDot:NZ,goLiveButton:BZ,emptyState:$Z,emptyStateText:jZ,controlMenuWrapper:VZ,zoomControl:HZ,zoomValue:UZ,playbackTime:GZ,watermarkOverlay:zZ,watermarkImage:WZ},qZ=({icon:t,label:e,valueLabel:n,selectedValue:r,options:o,onChange:s,disabled:i,ariaLabel:a})=>{const[c,u]=$.useState(null),d=!!c;return b.jsxs(b.Fragment,{children:[b.jsxs(G.ButtonBase,{disabled:i,className:`${At.menuButton} ${At.controlMenuWrapper}`,"aria-label":a,onClick:f=>u(f.currentTarget),children:[t,e?`${e}: ${n}`:n]}),b.jsx(G.Menu,{anchorEl:c,open:d,onClose:()=>u(null),children:o.map(f=>b.jsx(G.MenuItem,{selected:f.value===r,disabled:f.disabled,onClick:()=>{s(f.value),u(null)},children:f.label},`${e}-${String(f.value)}`))})]})},KZ=$.memo(qZ),YZ=["Dom","Seg","Ter","Qua","Qui","Sex","Sab"];function XZ(){const t=new Date,e=String(t.getDate()).padStart(2,"0"),n=String(t.getMonth()+1).padStart(2,"0"),r=t.getFullYear(),o=YZ[t.getDay()],s=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0"),a=String(t.getSeconds()).padStart(2,"0");return`${e}-${n}-${r}, ${o} ${s}:${i}:${a}`}const SA=$.memo(({show:t})=>{const[e,n]=$.useState("");return $.useEffect(()=>{if(!t)return;const r=()=>n(XZ());r();const o=setInterval(r,1e3);return()=>clearInterval(o)},[t]),!t||!e?null:b.jsx("div",{className:At.timestampOverlay,children:b.jsx("span",{className:At.timestampText,children:e})})});SA.displayName="Timestamp";const ZZ=(t,e)=>()=>{const n=t.current;n&&(n.paused?(n.play().then(()=>e==null?void 0:e()).catch(()=>e==null?void 0:e()),e==null||e()):(n.pause(),e==null||e()))},QZ=(t,e,n)=>r=>{const o=t.current;if(!o||!e)return;const s=Rm(o),i=Math.min(Math.max(o.currentTime+r,0),s);o.currentTime=i,n()},JZ=(t,e,n)=>()=>{const r=t.current;if(!r||!e)return;const o=Rm(r);r.currentTime=Math.max(o-.1,0),n()},eQ=t=>()=>{t.current&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):t.current.requestFullscreen().catch(()=>{}))},tQ=(t,e,n)=>r=>{const o=t.find(s=>s.value===r)??null;e(o),n==null||n(o)},nQ=t=>{const{width:e=20,height:n=20,...r}=t;return b.jsx("svg",{width:e,height:n,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r,children:b.jsx("path",{d:"M10.4167 2.5C14.2917 2.5 17.5667 5.025 18.725 8.51667L16.75 9.16667C15.875 6.50833 13.3667 4.58333 10.4167 4.58333C8.78333 4.58333 7.30833 5.18333 6.15 6.15L8.33333 8.33333H2.5V2.5L4.66667 4.66667C6.20833 3.33333 8.20833 2.5 10.4167 2.5ZM8.33333 10V18.3333H6.66667V11.6667H5V10H8.33333ZM10 10H15V11.6667H11.6667V13.3333H13.3333C14.2583 13.3333 15 14.0833 15 15V16.6667C15 17.5917 14.2583 18.3333 13.3333 18.3333H10V16.6667H13.3333V15H10V10Z",fill:"currentColor"})})},rQ=t=>{const{width:e=20,height:n=20,...r}=t;return b.jsx("svg",{width:e,height:n,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r,children:b.jsx("path",{d:"M9.58336 2.5C11.7917 2.5 13.7917 3.33333 15.3334 4.66667L17.5 2.5V8.33333H11.6667L13.85 6.15C12.6917 5.18333 11.2167 4.58333 9.58336 4.58333C6.63336 4.58333 4.12502 6.50833 3.25002 9.16667L1.27502 8.51667C2.43336 5.025 5.70836 2.5 9.58336 2.5ZM8.33336 10V18.3333H6.66669V11.6667H5.00002V10H8.33336ZM10 10H15V11.6667H11.6667V13.3333H13.3334C14.2584 13.3333 15 14.0833 15 15V16.6667C15 17.5917 14.2584 18.3333 13.3334 18.3333H10V16.6667H13.3334V15H10V10Z",fill:"currentColor"})})},oQ={color:"#C8E642","& .MuiSlider-thumb":{width:12,height:12,backgroundColor:"#fff"},"& .MuiSlider-track":{border:"none",backgroundColor:"#C8E642"},"& .MuiSlider-rail":{backgroundColor:"#424242",opacity:1}},$v=({stream:t=null,availableQualities:e=[],initialQuality:n,onQualityChange:r,autoPlay:o=!0,playsInline:s=!0,muted:i=!0,poster:a,className:c,sx:u,liveThresholdSeconds:d=2,allowPlaybackRateForStream:f=!1,playbackRates:h=[.5,1,1.5,2],zoomLevels:p=[1,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3],width:m,height:g,aspectRatio:y="16 / 9",showTimestamp:v=!1,showTimeline:C=!0,isRecording:S=!1,recordingLabel:w="Gravação",onGoLive:T,borderRadius:I,loading:P,unavailable:M=!1,unavailableIcon:D,unavailableMessage:k="O vídeo não está disponível.",showSeekButtons:A=!1,showPlaybackRate:E=!1,noControl:L=!1,noBorderRadius:O=!1,showLiveButton:_=!0,showWatermark:R=!0,startTimeSeconds:B,preload:j="auto",enableWheelZoom:U=!1,enableAreaZoom:V=!1})=>{const H=ye.useTheme().palette.mode==="dark",[z,q]=$.useState(!0),K=$.useRef(!0),Y=$.useRef(null);K.current=z;const{containerRef:J,videoRef:X,setVideoRef:ee,selectedQuality:re,setSelectedQuality:te,isPlaying:ne,isLive:se,canSeek:ae,currentTime:pe,setCurrentTime:oe,seekableEnd:ce,playbackRate:ie,setPlaybackRate:ge,zoom:he,setZoom:Z,panX:Q,setPanX:de,panY:ue,setPanY:fe,isDraggingRef:me,dragStartRef:Ce,panStartRef:Oe,didDragRef:Ie,isFullscreen:Se,isLoading:xe,isSeeking:Ne,canAdjustPlaybackRate:st,updateLiveStatus:Je,syncPlaybackState:He}=dZ({stream:t,availableQualities:e,initialQuality:n,autoPlay:o,liveThresholdSeconds:d,allowPlaybackRateForStream:f}),at=$.useRef({width:0,height:0});$.useEffect(()=>{const ze=J.current;if(!ze)return;const St=new ResizeObserver(([Qt])=>{at.current={width:Qt.contentRect.width,height:Qt.contentRect.height}});return St.observe(ze),()=>St.disconnect()},[J]),$.useEffect(()=>{const ze=J.current;if(!ze)return;const St=()=>{Y.current&&(clearTimeout(Y.current),Y.current=null),q(!0)},Qt=()=>{Y.current=setTimeout(()=>{},1e4)},tr=()=>{K.current||q(!0),Y.current&&clearTimeout(Y.current),Y.current=setTimeout(()=>{},1e4)};return ze.addEventListener("mouseenter",St),ze.addEventListener("mouseleave",Qt),ze.addEventListener("mousemove",tr),()=>{ze.removeEventListener("mouseenter",St),ze.removeEventListener("mouseleave",Qt),ze.removeEventListener("mousemove",tr),Y.current&&clearTimeout(Y.current)}},[]);const[We,mt]=$.useState(!1),wt=$.useRef(!1),Xe=(re==null?void 0:re.src)??(re==null?void 0:re.value)??null;$.useEffect(()=>{mt(!1),wt.current=!1},[Xe]),$.useEffect(()=>{const ze=X.current;if(!ze)return;const St=()=>mt(!0);return ze.addEventListener("play",St),()=>{ze.removeEventListener("play",St)}},[X]);const ft=$.useMemo(()=>ZZ(X,He),[He,X]),Ee=$.useCallback(()=>{const ze=X.current;if(ze&&ze.paused&&(We||mt(!0),B&&B>0&&!wt.current)){const St=Number.isFinite(ze.duration)?ze.duration:0,Qt=St>0?Math.min(B,Math.max(St-.1,0)):B;ze.currentTime<Qt&&(ze.currentTime=Qt),wt.current=!0}ft()},[ft,We,B,X]),Ge=$.useMemo(()=>QZ(X,ae,Je),[X,ae,Je]),Qe=$.useMemo(()=>JZ(X,ae,Je),[X,ae,Je]),tt=$.useMemo(()=>eQ(J),[J]);$.useMemo(()=>tQ(e,te,r),[e,te,r]);const Yt=$.useRef({wasPlaying:!1,active:!1}),[Ke,Mt]=$.useState(!1);$.useEffect(()=>{const ze=X.current;if(!ze||!Ke)return;const St=()=>Mt(!1);ze.addEventListener("playing",St),ze.addEventListener("canplay",St);const Qt=window.setTimeout(St,4e3);return()=>{ze.removeEventListener("playing",St),ze.removeEventListener("canplay",St),window.clearTimeout(Qt)}},[Ke,X]);const Ue=$.useCallback((ze,St)=>{if(!ae)return;const Qt=Array.isArray(St)?St[0]:St,tr=X.current;!Yt.current.active&&tr&&(Yt.current.active=!0,Yt.current.wasPlaying=!tr.paused,tr.paused||tr.pause(),Mt(!0)),oe(Qt),tr&&(tr.currentTime=Qt)},[ae,oe,X]),it=$.useCallback((ze,St)=>{const Qt=X.current;if(!Qt||!ae){Yt.current.active=!1;return}const tr=Array.isArray(St)?St[0]:St,Da=Rm(Qt);Qt.currentTime=Math.min(Math.max(tr,0),Da);const jl=Yt.current.wasPlaying;Yt.current.active=!1,Yt.current.wasPlaying=!1,jl&&Qt.play().catch(()=>{}),Je()},[ae,Je,X]),Ct=$.useRef(Q),Lt=$.useRef(ue);Ct.current=Q,Lt.current=ue;const _t=$.useRef(he);_t.current=he;const mr=$.useCallback(ze=>{if(Z(ze),ze<=1)de(0),fe(0);else{const{width:St,height:Qt}=at.current;if(St&&Qt){const tr=ul(Ct.current,Lt.current,ze,St,Qt);de(tr.panX),fe(tr.panY)}}},[Z,de,fe]),Zr=$.useCallback(ze=>{const St=p.indexOf(he),Qt=Math.max(0,Math.min(p.length-1,St+ze));mr(p[Qt])},[he,p,mr]),[ao,ui]=$.useState(!1),Mr=$.useRef(null);CA({targetRef:J,zoomLevels:p,zoom:he,panX:Q,panY:ue,enabled:U&&!V,onChange:({zoom:ze,panX:St,panY:Qt})=>{Z(ze),de(St),fe(Qt)}});const Qn=$.useCallback(ze=>{ui(!0),Z(ze.zoom),de(ze.panX),fe(ze.panY),Mr.current&&clearTimeout(Mr.current),Mr.current=setTimeout(()=>{ui(!1),Mr.current=null},360)},[Z,de,fe]),Zt=mZ({enabled:V,containerRef:J,videoRef:X,isLive:se,zoomRef:_t,applyZoom:Qn});$.useEffect(()=>()=>{Mr.current&&clearTimeout(Mr.current)},[]);const ts=$.useCallback(ze=>{Ie.current=!1,!(_t.current<=1)&&(ze.preventDefault(),me.current=!0,Ce.current={x:ze.clientX,y:ze.clientY},Oe.current={x:Ct.current,y:Lt.current})},[me,Ie,Ce,Oe]),$l=$.useCallback(()=>{const ze=Ie.current;me.current=!1,Ie.current=!1,!ze&&!L&&Ee()},[me,Ie,Ee,L]),$i=$.useCallback(ze=>{if(!me.current||_t.current<=1)return;ze.preventDefault();const St=ze.clientX-Ce.current.x,Qt=ze.clientY-Ce.current.y;(Math.abs(St)>3||Math.abs(Qt)>3)&&(Ie.current=!0);const{width:tr,height:Da}=at.current;if(!tr||!Da)return;const jl=Oe.current.x+St/_t.current,_g=Oe.current.y+Qt/_t.current,Uf=ul(jl,_g,_t.current,tr,Da);de(Uf.panX),fe(Uf.panY)},[me,Ce,Oe,Ie,de,fe]),Pa=$.useCallback(()=>{me.current=!1},[me]),Re=$.useCallback(ze=>{Zt.handleMouseDown(ze)||ts(ze)},[Zt,ts]),De=$.useCallback(ze=>{Zt.handleMouseMove(ze)||$i(ze)},[Zt,$i]),Ze=$.useCallback(ze=>{Zt.handleMouseUp(ze)||$l()},[Zt,$l]),vt=$.useCallback(()=>{Zt.handleMouseLeave()||Pa()},[Zt,Pa]),Tt=$.useCallback(ze=>{if(_t.current<=1||ze.touches.length!==1)return;const St=ze.touches[0];me.current=!0,Ie.current=!1,Ce.current={x:St.clientX,y:St.clientY},Oe.current={x:Ct.current,y:Lt.current}},[me,Ie,Ce,Oe]),Tn=$.useCallback(ze=>{if(!me.current||_t.current<=1||ze.touches.length!==1)return;const St=ze.touches[0],Qt=St.clientX-Ce.current.x,tr=St.clientY-Ce.current.y;(Math.abs(Qt)>3||Math.abs(tr)>3)&&(Ie.current=!0);const{width:Da,height:jl}=at.current;if(!Da||!jl)return;const _g=Oe.current.x+Qt/_t.current,Uf=Oe.current.y+tr/_t.current,CS=ul(_g,Uf,_t.current,Da,jl);de(CS.panX),fe(CS.panY)},[me,Ce,Oe,Ie,de,fe]),jn=$.useCallback(()=>{me.current=!1},[me]);$.useEffect(()=>{const ze=X.current;if(!ze)return;const St=Qt=>{_t.current>1&&me.current&&Qt.preventDefault()};return ze.addEventListener("touchmove",St,{passive:!1}),()=>{ze.removeEventListener("touchmove",St)}},[X,me]);const Ar=$.useMemo(()=>h.map(ze=>({value:ze,label:`${ze}x`})),[h]);$.useMemo(()=>e.map(ze=>({value:ze.value,label:ze.label})),[e]),re==null||re.label;const ji=`${Math.round(he*100)}%`,Hf=`${ie}x`,di=ae&&ce>0,Vi=RX(m,g,y),Xt=O?{...Vi,"--vp-radius":"0px"}:I!=null?{...Vi,"--vp-radius":typeof I=="number"?`${I}px`:I}:Vi,Ps=$.useMemo(()=>{const ze=he>1||ao;return{transform:ze?`scale(${he}) translate3d(${Q}px, ${ue}px, 0)`:void 0,willChange:ze?"transform":void 0}},[he,Q,ue,ao]);return b.jsx(G.Box,{ref:J,className:`${At.container} ${c||""}`.trim(),"data-theme":H?"dark":"light",style:Xt,sx:u,children:M?b.jsxs("div",{className:At.emptyState,children:[D??b.jsx(PD,{}),typeof k=="string"?b.jsx(G.Typography,{className:At.emptyStateText,children:k}):k]}):b.jsxs(b.Fragment,{children:[(P||xe&&We&&!Ne&&!Ke)&&b.jsx("div",{className:`${At.loader} ${a?"":At.loaderInitial}`.trim(),children:b.jsx("span",{className:At.spinner})}),b.jsx("video",{ref:ee,className:`${At.video} ${he>1?At.videoZoomed:""} ${ao?At.videoAreaZooming:""}`.trim(),autoPlay:o,playsInline:s,muted:i,poster:a,preload:j,style:Ps,onMouseDown:Re,onMouseMove:De,onMouseUp:Ze,onMouseLeave:vt,onDoubleClick:Zt.handleDoubleClick,onTouchStart:Tt,onTouchMove:Tn,onTouchEnd:jn}),Zt.selectionRect&&b.jsx("div",{className:At.areaSelection,style:{left:`${Zt.selectionRect.x}px`,top:`${Zt.selectionRect.y}px`,width:`${Zt.selectionRect.width}px`,height:`${Zt.selectionRect.height}px`}}),b.jsx(SA,{show:v}),R&&b.jsx("div",{className:At.watermarkOverlay,children:b.jsxs("svg",{className:At.watermarkImage,viewBox:"0 0 98 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M9.97803 15.3143C9.97803 15.9818 9.9994 16.6048 10.0648 17.1789H15.4093C16.3864 17.1789 17.1786 16.3867 17.1786 15.4096V10.0119C16.7309 9.94473 16.2429 9.91052 15.711 9.91052C10.9705 9.91052 9.97803 11.7427 9.97803 15.3143Z",fill:"white"}),b.jsx("path",{d:"M15.7111 7.24518C16.2192 7.24518 16.7078 7.27572 17.1787 7.33435V2.32267C17.1787 1.04014 16.1386 6.10352e-05 14.8561 6.10352e-05H2.32262C1.03947 6.10352e-05 0 1.04014 0 2.32267V15.4094C0 16.3866 0.79212 17.1787 1.76929 17.1787H7.2097C7.13763 16.67 7.09793 16.1362 7.09793 15.575C7.09793 10.1944 10.5431 7.24518 15.7111 7.24518Z",fill:"white"}),b.jsx("path",{d:"M17.1785 7.33435V10.0118C20.1381 10.4546 21.3046 12.3521 21.3046 15.5988C21.3046 19.2778 20.808 21.3378 15.7109 21.3378C11.5402 21.3378 10.3572 19.764 10.0646 17.1794H7.20947C7.83364 21.5724 11.0748 24 15.6638 24C20.8319 24 24.1286 21.0502 24.1286 15.6702C24.1286 10.7813 21.4524 7.86569 17.1791 7.33496L17.1785 7.33435Z",fill:"white"}),b.jsx("path",{d:"M48.2628 1.92908L40.6787 22.0741H37.713L30.1289 1.92908L32.4894 1.92725L39.1958 19.7112L45.9017 1.92725L48.2622 1.92908H48.2628Z",fill:"white"}),b.jsx("path",{d:"M49.8848 22.0692V1.92236H52.1121V22.0692H49.8848Z",fill:"white"}),b.jsx("path",{d:"M70.1892 16.5256C70.1892 19.1493 68.1713 22.4784 62.2711 22.4784C57.0188 22.4784 54.3413 19.0284 54.3413 16.0828H56.5564C56.5564 18.2106 58.7557 20.4434 62.4964 20.4434C66.5028 20.4434 67.9875 18.4018 67.9875 16.2905C67.9875 10.6094 54.902 15.0568 54.902 6.83571C54.902 3.87427 57.5086 1.52173 62.1581 1.52173C66.5163 1.52173 69.2163 3.99581 69.2157 7.45805H66.9981C66.9981 5.23804 65.183 3.57074 62.1581 3.57074C59.1331 3.57074 57.1226 4.71891 57.1226 6.91694C57.1226 12.8869 70.1898 8.39796 70.1898 16.525L70.1892 16.5256Z",fill:"white"}),b.jsx("path",{d:"M72.4399 22.0692V1.92236H74.6673V22.0692H72.4399Z",fill:"white"}),b.jsx("path",{d:"M97.5617 11.9995C97.5617 19.7246 92.2452 22.4772 87.2696 22.4772C81.0175 22.4772 76.9775 18.3645 76.9775 11.9995C76.9775 8.75463 78.0311 6.0497 80.0245 4.1772C81.8475 2.46531 84.4199 1.52173 87.2696 1.52173C93.5223 1.52173 97.5623 5.53485 97.5617 11.9995ZM95.3441 11.9995C95.3441 5.72479 91.232 3.56463 87.2696 3.56463C83.3072 3.56463 79.1951 5.95565 79.1951 11.9995C79.1951 18.0433 83.3072 20.4343 87.2696 20.4343C92.3246 20.4343 95.3441 17.3941 95.3441 11.9995Z",fill:"white"})]})}),!L&&se&&!S&&!z&&b.jsx("div",{className:At.badgeFloating,children:b.jsx("span",{className:`${At.liveBadge} ${At.liveBadgeActive}`,children:"ao vivo"})}),!L&&b.jsxs("div",{className:`${At.controlsOverlay} ${z?At.controlsVisible:""}`,children:[C&&b.jsx("div",{className:At.timeline,children:b.jsx(G.Slider,{size:"small",min:0,max:di?ce:1,step:.05,value:di?pe:0,disabled:!di,onChange:Ue,onChangeCommitted:it,"aria-label":"Linha do tempo do video",sx:oQ})}),b.jsxs("div",{className:At.controlsRow,children:[b.jsxs("div",{className:At.controlGroup,children:[_&&(S?b.jsx(b.Fragment,{children:b.jsx("button",{type:"button",className:`${At.liveBadge} ${At.liveBadgeInactive} ${At.goLiveButton}`,onClick:()=>{console.log("LIB"),T==null||T()},"aria-label":"Ir ao vivo",children:w})}):se?b.jsxs("div",{className:`${At.liveBadge} ${At.liveBadgeActive}`,children:[se&&b.jsx("span",{className:At.recordingDot}),"ao vivo"]}):b.jsx("button",{type:"button",className:`${At.liveBadge} ${At.liveBadgeInactive} ${At.goLiveButton}`,onClick:Qe,"aria-label":"Ir ao vivo",children:"ao vivo"})),A&&b.jsx(G.IconButton,{className:At.iconButton,onClick:()=>Ge(-15),disabled:!ae,"aria-label":"Voltar 15 segundos",children:b.jsx(nQ,{})}),b.jsx(G.IconButton,{className:At.iconButton,onClick:Ee,"aria-label":"Play/Pause",children:ne?b.jsx(on.Pause,{fontSize:"small"}):b.jsx(on.PlayArrow,{fontSize:"small"})}),A&&b.jsx(G.IconButton,{className:At.iconButton,onClick:()=>Ge(15),disabled:!ae,"aria-label":"Avançar 15 segundos",children:b.jsx(rQ,{})}),di&&!se&&b.jsxs("span",{className:At.playbackTime,"aria-label":"Tempo do vídeo",children:[YE(pe)," / ",YE(ce)]})]}),b.jsxs("div",{className:At.controlGroup,children:[E&&b.jsx(KZ,{icon:b.jsx(on.Speed,{fontSize:"small"}),label:"",valueLabel:Hf,selectedValue:ie,options:Ar,ariaLabel:"Selecionar velocidade de reprodução",onChange:ge,disabled:!st}),b.jsxs("div",{className:At.zoomControl,children:[b.jsx(G.IconButton,{className:At.iconButton,onClick:()=>mr(1),disabled:he<=1,"aria-label":"Resetar zoom",children:b.jsx(on.Undo,{fontSize:"small"})}),b.jsx(G.IconButton,{className:At.iconButton,onClick:()=>Zr(-1),disabled:he<=p[0],"aria-label":"Diminuir zoom",children:b.jsx(on.ZoomOut,{fontSize:"small"})}),b.jsx("span",{className:At.zoomValue,children:ji}),b.jsx(G.IconButton,{className:At.iconButton,onClick:()=>Zr(1),disabled:he>=p[p.length-1],"aria-label":"Aumentar zoom",children:b.jsx(on.ZoomIn,{fontSize:"small"})})]}),b.jsx(G.IconButton,{className:At.iconButton,onClick:tt,"aria-label":"Fullscreen",children:Se?b.jsx(on.CloseFullscreen,{fontSize:"small"}):b.jsx(on.OpenInFull,{fontSize:"small"})})]})]})]})]})})};$v.displayName="VideoPlayer";const sQ=Bt(b.jsx("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z"}),"Add"),iQ=Bt(b.jsx("path",{d:"M19 13H5v-2h14z"}),"Remove"),aQ=Bt(b.jsx("path",{d:"M18 15v3H6v-3H4v3c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-3zm-1-4-1.41-1.41L13 12.17V4h-2v8.17L8.41 9.59 7 11l5 5z"}),"FileDownloadOutlined"),lQ=Bt(b.jsx("path",{d:"M20 3h-1V1h-2v2H7V1H5v2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m0 18H4V10h16zm0-13H4V5h16z"}),"CalendarTodayOutlined");function N(){return N=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},N.apply(null,arguments)}function we(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function cQ(t){const{theme:e,name:n,props:r}=t;return!e||!e.components||!e.components[n]||!e.components[n].defaultProps?r:yl(e.components[n].defaultProps,r)}function uQ(t,e,n,r,o){const[s,i]=x.useState(()=>o&&n?n(t).matches:r?r(t).matches:e);return Ot(()=>{if(!n)return;const a=n(t),c=()=>{i(a.matches)};return c(),a.addEventListener("change",c),()=>{a.removeEventListener("change",c)}},[t,n]),s}const dQ={...x},wA=dQ.useSyncExternalStore;function fQ(t,e,n,r,o){const s=x.useCallback(()=>e,[e]),i=x.useMemo(()=>{if(o&&n)return()=>n(t).matches;if(r!==null){const{matches:d}=r(t);return()=>d}return s},[s,t,r,o,n]),[a,c]=x.useMemo(()=>{if(n===null)return[s,()=>()=>{}];const d=n(t);return[()=>d.matches,f=>(d.addEventListener("change",f),()=>{d.removeEventListener("change",f)})]},[s,n,t]);return wA(c,a,i)}function TA(t={}){const{themeId:e}=t;return function(r,o={}){let s=z4();s&&e&&(s=s[e]||s);const i=typeof window<"u"&&typeof window.matchMedia<"u",{defaultMatches:a=!1,matchMedia:c=i?window.matchMedia:null,ssrMatchMedia:u=null,noSsr:d=!1}=cQ({name:"MuiUseMediaQuery",props:o,theme:s});process.env.NODE_ENV!=="production"&&typeof r=="function"&&s===null&&console.error(["MUI: The `query` argument provided is invalid.","You are providing a function without a theme in the context.","One of the parent elements needs to use a ThemeProvider."].join(`
|
|
149
149
|
`));let f=typeof r=="function"?r(s):r;f=f.replace(/^@media( ?)/m,""),f.includes("print")&&console.warn(["MUI: You have provided a `print` query to the `useMediaQuery` hook.","Using the print media query to modify print styles can lead to unexpected results.","Consider using the `displayPrint` field in the `sx` prop instead.","More information about `displayPrint` on our docs: https://mui.com/system/display/#display-in-print."].join(`
|
|
150
150
|
`));const p=(wA!==void 0?fQ:uQ)(f,a,c,u,d);return process.env.NODE_ENV!=="production"&&x.useDebugValue({query:f,match:p}),p}}TA();const EA=TA({themeId:vm}),Ln=l.oneOfType([l.func,l.object]);function Uo(t,e,n){return typeof t=="function"?t(e,n):t}const Mu=(t,e)=>t.length!==e.length?!1:e.every(n=>t.includes(n)),hQ=({openTo:t,defaultOpenTo:e,views:n,defaultViews:r})=>{const o=n??r;let s;if(t!=null)s=t;else if(o.includes(e))s=e;else if(o.length>0)s=o[0];else throw new Error("MUI X: The `views` prop must contain at least one view.");return{views:o,openTo:s}},Lp=(t,e,n)=>{let r=e;return r=t.setHours(r,t.getHours(n)),r=t.setMinutes(r,t.getMinutes(n)),r=t.setSeconds(r,t.getSeconds(n)),r=t.setMilliseconds(r,t.getMilliseconds(n)),r},Hd=({date:t,disableFuture:e,disablePast:n,maxDate:r,minDate:o,isDateDisabled:s,adapter:i,timezone:a})=>{const c=Lp(i,i.date(void 0,a),t);n&&i.isBefore(o,c)&&(o=c),e&&i.isAfter(r,c)&&(r=c);let u=t,d=t;for(i.isBefore(t,o)&&(u=o,d=null),i.isAfter(t,r)&&(d&&(d=r),u=null);u||d;){if(u&&i.isAfter(u,r)&&(u=null),d&&i.isBefore(d,o)&&(d=null),u){if(!s(u))return u;u=i.addDays(u,1)}if(d){if(!s(d))return d;d=i.addDays(d,-1)}}return null},pQ=(t,e)=>t.isValid(e)?e:null,JE=(t,e,n)=>e==null||!t.isValid(e)?n:e,mQ=(t,e,n)=>!t.isValid(e)&&e!=null&&!t.isValid(n)&&n!=null?!0:t.isEqual(e,n),jv=(t,e)=>{const r=[t.startOfYear(e)];for(;r.length<12;){const o=r[r.length-1];r.push(t.addMonths(o,1))}return r},IA=(t,e,n)=>n==="date"?t.startOfDay(t.date(void 0,e)):t.date(void 0,e),gQ=["year","month","day"],e2=t=>gQ.includes(t),Vv=(t,{format:e,views:n},r)=>{if(e!=null)return e;const o=t.formats;return Mu(n,["year"])?o.year:Mu(n,["month"])?o.month:Mu(n,["day"])?o.dayOfMonth:Mu(n,["month","year"])?`${o.month} ${o.year}`:Mu(n,["day","month"])?`${o.month} ${o.dayOfMonth}`:r?/en/.test(t.getCurrentLocaleCode())?o.normalDateWithWeekday:o.normalDate:o.keyboardDate},yQ=(t,e)=>{const n=t.startOfWeek(e);return[0,1,2,3,4,5,6].map(r=>t.addDays(n,r))},bQ=["hours","minutes","seconds"],vQ=t=>bQ.includes(t),t2=(t,e)=>e.getHours(t)*3600+e.getMinutes(t)*60+e.getSeconds(t),xQ=(t,e)=>(n,r)=>t?e.isAfter(n,r):t2(n,e)>t2(r,e),Bs={year:1,month:2,day:3,hours:4,minutes:5,seconds:6,milliseconds:7},CQ=t=>Math.max(...t.map(e=>Bs[e.type]??1)),Au=(t,e,n)=>{if(e===Bs.year)return t.startOfYear(n);if(e===Bs.month)return t.startOfMonth(n);if(e===Bs.day)return t.startOfDay(n);let r=n;return e<Bs.minutes&&(r=t.setMinutes(r,0)),e<Bs.seconds&&(r=t.setSeconds(r,0)),e<Bs.milliseconds&&(r=t.setMilliseconds(r,0)),r},SQ=({props:t,adapter:e,granularity:n,timezone:r,getTodayDate:o})=>{let s=o?o():Au(e,n,IA(e,r));t.minDate!=null&&e.isAfterDay(t.minDate,s)&&(s=Au(e,n,t.minDate)),t.maxDate!=null&&e.isBeforeDay(t.maxDate,s)&&(s=Au(e,n,t.maxDate));const i=xQ(t.disableIgnoringDatePartForTimeValidation??!1,e);return t.minTime!=null&&i(t.minTime,s)&&(s=Au(e,n,t.disableIgnoringDatePartForTimeValidation?t.minTime:Lp(e,s,t.minTime))),t.maxTime!=null&&i(s,t.maxTime)&&(s=Au(e,n,t.disableIgnoringDatePartForTimeValidation?t.maxTime:Lp(e,s,t.maxTime))),s},Hv=(t,e)=>{const n=t.formatTokenMap[e];if(n==null)throw new Error([`MUI X: The token "${e}" is not supported by the Date and Time Pickers.`,"Please try using another token or open an issue on https://github.com/mui/mui-x/issues/new/choose if you think it should be supported."].join(`
|
|
151
151
|
`));return typeof n=="string"?{type:n,contentType:n==="meridiem"?"letter":"digit",maxLength:void 0}:{type:n.sectionType,contentType:n.contentType,maxLength:n.maxLength}},_m=(t,e)=>{const n=[],r=t.date(void 0,"default"),o=t.startOfWeek(r),s=t.endOfWeek(r);let i=o;for(;t.isBefore(i,s);)n.push(i),i=t.addDays(i,1);return n.map(a=>t.formatByString(a,e))},kA=(t,e,n,r)=>{switch(n){case"month":return jv(t,t.date(void 0,e)).map(o=>t.formatByString(o,r));case"weekDay":return _m(t,r);case"meridiem":{const o=t.date(void 0,e);return[t.startOfDay(o),t.endOfDay(o)].map(s=>t.formatByString(s,r))}default:return[]}},n2="s",wQ=["0","1","2","3","4","5","6","7","8","9"],TQ=t=>{const e=t.date(void 0);return t.formatByString(t.setSeconds(e,0),n2)==="0"?wQ:Array.from({length:10}).map((r,o)=>t.formatByString(t.setSeconds(e,o),n2))},xl=(t,e)=>{if(e[0]==="0")return t;const n=[];let r="";for(let o=0;o<t.length;o+=1){r+=t[o];const s=e.indexOf(r);s>-1&&(n.push(s.toString()),r="")}return n.join("")},Uv=(t,e)=>e[0]==="0"?t:t.split("").map(n=>e[Number(n)]).join(""),r2=(t,e)=>{const n=xl(t,e);return n!==" "&&!Number.isNaN(Number(n))},Gv=(t,e)=>Number(t).toString().padStart(e,"0"),PA=(t,e,n,r,o)=>{if(process.env.NODE_ENV!=="production"&&o.type!=="day"&&o.contentType==="digit-with-letter")throw new Error([`MUI X: The token "${o.format}" is a digit format with letter in it.'
|