hamrahi-player-library 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { aE as e, aG as i, aF as y } from "./index-XQMSuoNz.js";
1
+ import { aE as e, aG as i, aF as y } from "./index-CW_ClzaD.js";
2
2
  export {
3
3
  e as FeatureExcept,
4
4
  i as MiniPlayerLibrary,
@@ -61,4 +61,4 @@ Take a look at the reducer(s) handling this action type: ${g.type}.
61
61
  `),c=[],u=e?Zp(e.baseTime,e.timescale):0;let d="00:00.000",f=0,g=0,h,m=!0;o.oncue=function(p){const E=t[s];let x=t.ccOffset;const v=(f-u)/9e4;if(E!=null&&E.new&&(g!==void 0?x=t.ccOffset=E.start:_1(t,s,v)),v){if(!e){h=new Error("Missing initPTS for VTT MPEGTS");return}x=v-t.presentationOffset}const w=p.endTime-p.startTime,b=Ke((p.startTime+x-g)*9e4,r*9e4)/9e4;p.startTime=Math.max(b,0),p.endTime=Math.max(b+w,0);const I=p.text.trim();p.text=decodeURIComponent(encodeURIComponent(I)),p.id||(p.id=Di(p.startTime,p.endTime,I)),p.endTime>0&&c.push(p)},o.onparsingerror=function(p){h=p},o.onflush=function(){if(h){a(h);return}i(c)},l.forEach(p=>{if(m)if(Li(p,"X-TIMESTAMP-MAP=")){m=!1,p.slice(16).split(",").forEach(E=>{Li(E,"LOCAL:")?d=E.slice(6):Li(E,"MPEGTS:")&&(f=parseInt(E.slice(7)))});try{g=P1(d)/1e3}catch(E){h=E}return}else p===""&&(m=!1);o.parse(p+`
62
62
  `)}),o.flush()}const Ii="stpp.ttml.im1t",Oc=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Fc=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,F1={left:"start",center:"center",right:"end",start:"start",end:"end"};function Mc(n,e,t,s){const r=J(new Uint8Array(n),["mdat"]);if(r.length===0){s(new Error("Could not parse IMSC1 mdat"));return}const i=r.map(o=>Je(o)),a=Xp(e.baseTime,1,e.timescale);try{i.forEach(o=>t(M1(o,a)))}catch(o){s(o)}}function M1(n,e){const r=new DOMParser().parseFromString(n,"text/xml").getElementsByTagName("tt")[0];if(!r)throw new Error("Invalid ttml");const i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(i).reduce((d,f)=>(d[f]=r.getAttribute(`ttp:${f}`)||i[f],d),{}),o=r.getAttribute("xml:space")!=="preserve",l=Nc(Ri(r,"styling","style")),c=Nc(Ri(r,"layout","region")),u=Ri(r,"body","[begin]");return[].map.call(u,d=>{const f=Bc(d,o);if(!f||!d.hasAttribute("begin"))return null;const g=Pi(d.getAttribute("begin"),a),h=Pi(d.getAttribute("dur"),a);let m=Pi(d.getAttribute("end"),a);if(g===null)throw Uc(d);if(m===null){if(h===null)throw Uc(d);m=g+h}const p=new Ci(g-e,m-e,f);p.id=Di(p.startTime,p.endTime,p.text);const E=c[d.getAttribute("region")],x=l[d.getAttribute("style")],v=N1(E,x,l),{textAlign:w}=v;if(w){const b=F1[w];b&&(p.lineAlign=b),p.align=w}return ye(p,v),p}).filter(d=>d!==null)}function Ri(n,e,t){const s=n.getElementsByTagName(e)[0];return s?[].slice.call(s.querySelectorAll(t)):[]}function Nc(n){return n.reduce((e,t)=>{const s=t.getAttribute("xml:id");return s&&(e[s]=t),e},{})}function Bc(n,e){return[].slice.call(n.childNodes).reduce((t,s,r)=>{var i;return s.nodeName==="br"&&r?t+`
63
63
  `:(i=s.childNodes)!=null&&i.length?Bc(s,e):e?t+s.textContent.trim().replace(/\s+/g," "):t+s.textContent},"")}function N1(n,e,t){const s="http://www.w3.org/ns/ttml#styling";let r=null;const i=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=n!=null&&n.hasAttribute("style")?n.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(r=t[a]),i.reduce((o,l)=>{const c=ki(e,s,l)||ki(n,s,l)||ki(r,s,l);return c&&(o[l]=c),o},{})}function ki(n,e,t){return n&&n.hasAttributeNS(e,t)?n.getAttributeNS(e,t):null}function Uc(n){return new Error(`Could not parse ttml timestamp ${n}`)}function Pi(n,e){if(!n)return null;let t=kc(n);return t===null&&(Oc.test(n)?t=B1(n,e):Fc.test(n)&&(t=U1(n,e))),t}function B1(n,e){const t=Oc.exec(n),s=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+s/e.frameRate}function U1(n,e){const t=Fc.exec(n),s=Number(t[1]);switch(t[2]){case"h":return s*3600;case"m":return s*60;case"ms":return s*1e3;case"f":return s/e.frameRate;case"t":return s/e.tickRate}return s}class $1{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=Gc(),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(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(y.FRAG_LOADING,this.onFragLoading,this),e.on(y.FRAG_LOADED,this.onFragLoaded,this),e.on(y.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(y.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(y.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(y.FRAG_LOADING,this.onFragLoading,this),e.off(y.FRAG_LOADED,this.onFragLoaded,this),e.off(y.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(y.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(y.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){if(this.config.enableCEA708Captions&&(!this.cea608Parser1||!this.cea608Parser2)){const e=new $n(this,"textTrack1"),t=new $n(this,"textTrack2"),s=new $n(this,"textTrack3"),r=new $n(this,"textTrack4");this.cea608Parser1=new Rc(1,e,t),this.cea608Parser2=new Rc(3,s,r)}}addCues(e,t,s,r,i){let a=!1;for(let o=i.length;o--;){const l=i[o],c=V1(l[0],l[1],t,s);if(c>=0&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],s),a=!0,c/(s-t)>.5))return}if(a||i.push([t,s]),this.config.renderTextTracksNatively){const o=this.captionsTracks[e];this.Cues.newCue(o,t,s,r)}else{const o=this.Cues.newCue(null,t,s,r);this.hls.trigger(y.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:s,initPTS:r,timescale:i}){const{unparsedVttFrags:a}=this;s==="main"&&(this.initPTS[t.cc]={baseTime:r,timescale:i}),a.length&&(this.unparsedVttFrags=[],a.forEach(o=>{this.onFragLoaded(y.FRAG_LOADED,o)}))}getExistingTrack(e,t){const{media:s}=this;if(s)for(let r=0;r<s.textTracks.length;r++){const i=s.textTracks[r];if(Vc(i,{name:e,lang:t,attrs:{}}))return i}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:s,media:r}=this,{label:i,languageCode:a}=t[e],o=this.getExistingTrack(i,a);if(o)s[e]=o,zt(s[e]),kl(s[e],r);else{const l=this.createTextTrack("captions",i,a);l&&(l[e]=!0,s[e]=l)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const s=t.label,r={_id:e,label:s,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(y.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}createTextTrack(e,t,s){const r=this.media;if(r)return r.addTextTrack(e,t,s)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:e}=this;Object.keys(e).forEach(t=>{zt(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Gc(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let s=0;s<t.length;s++)zt(t[s])}onSubtitleTracksUpdated(e,t){const s=t.subtitleTracks||[],r=s.some(i=>i.textCodec===Ii);if(this.config.enableWebVTT||r&&this.config.enableIMSC1){if(bc(this.tracks,s)){this.tracks=s;return}if(this.textTracks=[],this.tracks=s,this.config.renderTextTracksNatively){const a=this.media,o=a?vn(a.textTracks):null;if(this.tracks.forEach((l,c)=>{let u;if(o){let d=null;for(let f=0;f<o.length;f++)if(o[f]&&Vc(o[f],l)){d=o[f],o[f]=null;break}d&&(u=d)}if(u)zt(u);else{const d=$c(l);u=this.createTextTrack(d,l.name,l.lang),u&&(u.mode="disabled")}u&&this.textTracks.push(u)}),o!=null&&o.length){const l=o.filter(c=>c!==null).map(c=>c.label);l.length&&L.warn(`Media element contains unused subtitle tracks: ${l.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const a=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(y.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(s=>{const r=/(?:CC|SERVICE)([1-4])/.exec(s.instreamId);if(!r)return;const i=`textTrack${r[1]}`,a=this.captionsProperties[i];a&&(a.label=s.name,s.lang&&(a.languageCode=s.lang),a.media=s)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===q.MAIN){var s,r;const{cea608Parser1:i,cea608Parser2:a,lastSn:o}=this,{cc:l,sn:c}=t.frag,u=(s=(r=t.part)==null?void 0:r.index)!=null?s:-1;i&&a&&(c!==o+1||c===o&&u!==this.lastPartIndex+1||l!==this.lastCc)&&(i.reset(),a.reset()),this.lastCc=l,this.lastSn=c,this.lastPartIndex=u}}onFragLoaded(e,t){const{frag:s,payload:r}=t;if(s.type===q.SUBTITLE)if(r.byteLength){const i=s.decryptdata,a="stats"in t;if(i==null||!i.encrypted||a){const o=this.tracks[s.level],l=this.vttCCs;l[s.cc]||(l[s.cc]={start:s.start,prevCC:this.prevCC,new:!0},this.prevCC=s.cc),o&&o.textCodec===Ii?this._parseIMSC1(s,r):this._parseVTTs(t)}}else this.hls.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:s,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const s=this.hls;Mc(t,this.initPTS[e.cc],r=>{this._appendCues(r,e.level),s.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},r=>{L.log(`Failed to parse IMSC1: ${r}`),s.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:r})})}_parseVTTs(e){var t;const{frag:s,payload:r}=e,{initPTS:i,unparsedVttFrags:a}=this,o=i.length-1;if(!i[s.cc]&&o===-1){a.push(e);return}const l=this.hls,c=(t=s.initSegment)!=null&&t.data?He(s.initSegment.data,new Uint8Array(r)):r;O1(c,this.initPTS[s.cc],this.vttCCs,s.cc,s.start,u=>{this._appendCues(u,s.level),l.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:s})},u=>{const d=u.message==="Missing initPTS for VTT MPEGTS";d?a.push(e):this._fallbackToIMSC1(s,r),L.log(`Failed to parse VTT cue: ${u}`),!(d&&o>s.cc)&&l.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:s,error:u})})}_fallbackToIMSC1(e,t){const s=this.tracks[e.level];s.textCodec||Mc(t,this.initPTS[e.cc],()=>{s.textCodec=Ii,this._parseIMSC1(e,t)},()=>{s.textCodec="wvtt"})}_appendCues(e,t){const s=this.hls;if(this.config.renderTextTracksNatively){const r=this.textTracks[t];if(!r||r.mode==="disabled")return;e.forEach(i=>Pl(r,i))}else{const r=this.tracks[t];if(!r)return;const i=r.default?"default":"subtitles"+t;s.trigger(y.CUES_PARSED,{type:"subtitles",cues:e,track:i})}}onFragDecrypted(e,t){const{frag:s}=t;s.type===q.SUBTITLE&&this.onFragLoaded(y.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){this.initCea608Parsers();const{cea608Parser1:s,cea608Parser2:r}=this;if(!this.enabled||!s||!r)return;const{frag:i,samples:a}=t;if(!(i.type===q.MAIN&&this.closedCaptionsForLevel(i)==="NONE"))for(let o=0;o<a.length;o++){const l=a[o].bytes;if(l){const c=this.extractCea608Data(l);s.addData(a[o].pts,c[0]),r.addData(a[o].pts,c[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:s,endOffsetSubtitles:r,type:i}){const{media:a}=this;if(!(!a||a.currentTime<s)){if(!i||i==="video"){const{captionsTracks:o}=this;Object.keys(o).forEach(l=>ti(o[l],t,s))}if(this.config.renderTextTracksNatively&&t===0&&r!==void 0){const{textTracks:o}=this;Object.keys(o).forEach(l=>ti(o[l],t,r))}}}extractCea608Data(e){const t=[[],[]],s=e[0]&31;let r=2;for(let i=0;i<s;i++){const a=e[r++],o=127&e[r++],l=127&e[r++];if(o===0&&l===0)continue;if((4&a)!==0){const u=3&a;(u===0||u===1)&&(t[u].push(o),t[u].push(l))}}return t}}function $c(n){return n.characteristics&&/transcribes-spoken-dialog/gi.test(n.characteristics)&&/describes-music-and-sound/gi.test(n.characteristics)?"captions":"subtitles"}function Vc(n,e){return!!n&&n.kind===$c(e)&&vi(e,n)}function V1(n,e,t,s){return Math.min(e,s)-Math.max(n,t)}function Gc(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class _i{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(y.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.BUFFER_CODECS,this.onBufferCodecs,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(y.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.BUFFER_CODECS,this.onBufferCodecs,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const s=this.hls.levels[t.droppedLevel];this.isLevelAllowed(s)&&this.restrictedLevels.push({bitrate:s.bitrate,height:s.height,width:s.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){const s=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,s.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&H(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}const e=this.hls.levels;if(e.length){const t=this.hls,s=this.getMaxLevel(e.length-1);s!==this.autoLevelCapping&&L.log(`Setting autoLevelCapping to ${s}: ${e[s].height}p@${e[s].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=s,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const s=t.filter((r,i)=>this.isLevelAllowed(r)&&i<=e);return this.clientRect=null,_i.getMaxLevelByMediaSize(s,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const e=this.media,t={width:0,height:0};if(e){const s=e.getBoundingClientRect();t.width=s.width,t.height=s.height,!t.width&&!t.height&&(t.width=s.right-s.left||e.width||0,t.height=s.bottom-s.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}isLevelAllowed(e){return!this.restrictedLevels.some(s=>e.bitrate===s.bitrate&&e.width===s.width&&e.height===s.height)}static getMaxLevelByMediaSize(e,t,s){if(!(e!=null&&e.length))return-1;const r=(o,l)=>l?o.width!==l.width||o.height!==l.height:!0;let i=e.length-1;const a=Math.max(t,s);for(let o=0;o<e.length;o+=1){const l=e[o];if((l.width>=a||l.height>=a)&&r(l,e[o+1])){i=o;break}}return i}}class G1{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const s=this.hls.config;if(s.capLevelOnFPSDrop){const r=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=r,r&&typeof r.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),s.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,s){const r=performance.now();if(t){if(this.lastTime){const i=r-this.lastTime,a=s-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*a/i,c=this.hls;if(c.trigger(y.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:s}),l>0&&a>c.config.fpsDroppedMonitoringThreshold*o){let u=c.currentLevel;L.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(c.autoLevelCapping===-1||c.autoLevelCapping>=u)&&(u=u-1,c.trigger(y.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:c.currentLevel}),c.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=r,this.lastDroppedFrames=s,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}const Gn="[eme]";class Jt{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=Jt.CDMCleanupPromise?[Jt.CDMCleanupPromise]:[],this.debug=L.debug.bind(L,Gn),this.log=L.log.bind(L,Gn),this.warn=L.warn.bind(L,Gn),this.error=L.error.bind(L,Gn),this.onMediaEncrypted=t=>{const{initDataType:s,initData:r}=t,i=`"${t.type}" event: init data type: "${s}"`;if(this.debug(i),r!==null){if(!this.keyFormatPromise){let a=Object.keys(this.keySystemAccessPromises);a.length||(a=pn(this.config));const o=a.map(Wr).filter(l=>!!l);this.keyFormatPromise=this.getKeyFormatPromise(o)}this.keyFormatPromise.then(a=>{const o=Hr(a);let l,c;if(s==="sinf"){if(o!==ae.FAIRPLAY){this.warn(`Ignoring unexpected "${t.type}" event with init data type: "${s}" for selected key-system ${o}`);return}const h=Te(new Uint8Array(r));try{const m=Vr(JSON.parse(h).sinf),p=dl(m);if(!p)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");l=p.subarray(8,24),c=ae.FAIRPLAY}catch(m){this.warn(`${i} Failed to parse sinf: ${m}`);return}}else{if(o!==ae.WIDEVINE&&o!==ae.PLAYREADY){this.warn(`Ignoring unexpected "${t.type}" event with init data type: "${s}" for selected key-system ${o}`);return}const h=S2(r),m=h.filter(E=>!!E.systemId&&Kr(E.systemId)===o);m.length>1&&this.warn(`${i} Using first of ${m.length} pssh found for selected key-system ${o}`);const p=m[0];if(!p){h.length===0||h.some(E=>!E.systemId)?this.warn(`${i} contains incomplete or invalid pssh data`):this.log(`ignoring ${i} for ${h.map(E=>Kr(E.systemId)).join(",")} pssh data in favor of playlist keys`);return}if(c=Kr(p.systemId),p.version===0&&p.data)if(c===ae.WIDEVINE){const E=p.data.length-22;l=p.data.subarray(E,E+16)}else c===ae.PLAYREADY&&(l=sl(p.data))}if(!c||!l){this.log(`Unable to handle ${i} with key-system ${o}`);return}const u=et.hexDump(l),{keyIdToKeySessionPromise:d,mediaKeySessions:f}=this;let g=d[u];for(let h=0;h<f.length;h++){const m=f[h],p=m.decryptdata;if(!p.keyId)continue;const E=et.hexDump(p.keyId);if(u===E||p.uri.replace(/-/g,"").indexOf(u)!==-1){if(g=d[E],p.pssh)break;delete d[E],p.pssh=new Uint8Array(r),p.keyId=l,g=d[u]=g.then(()=>this.generateRequestWithPreferredKeySession(m,s,r,"encrypted-event-key-match")),g.catch(x=>this.handleError(x));break}}if(!g){if(c!==o){this.log(`Ignoring "${i}" with ${c} init data for selected key-system ${o}`);return}g=d[u]=this.getKeySystemSelectionPromise([c]).then(({keySystem:h,mediaKeys:m})=>{var p;this.throwIfDestroyed();const E=new Es("ISO-23001-7",u,(p=Wr(h))!=null?p:"");return E.pssh=new Uint8Array(r),E.keyId=l,this.attemptSetMediaKeys(h,m).then(()=>{this.throwIfDestroyed();const x=this.createMediaKeySessionContext({decryptdata:E,keySystem:h,mediaKeys:m});return this.generateRequestWithPreferredKeySession(x,s,r,"encrypted-event-no-match")})}),g.catch(h=>this.handleError(h))}})}},this.onWaitingForKey=t=>{this.log(`"${t.type}" event`)},this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}registerListeners(){this.hls.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(y.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(y.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(y.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(y.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:s}=this.config,r=t[e];if(r)return r.licenseUrl;if(e===ae.WIDEVINE&&s)return s}getLicenseServerUrlOrThrow(e){const t=this.getLicenseServerUrl(e);if(t===void 0)throw new Error(`no license server URL configured for key-system "${e}"`);return t}getServerCertificateUrl(e){const{drmSystems:t}=this.config,s=t[e];if(s)return s.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,s=(a,o,l)=>!!a&&l.indexOf(a)===o,r=t.map(a=>a.audioCodec).filter(s),i=t.map(a=>a.videoCodec).filter(s);return r.length+i.length===0&&i.push("avc1.42e01e"),new Promise((a,o)=>{const l=c=>{const u=c.shift();this.getMediaKeysPromise(u,r,i).then(d=>a({keySystem:u,mediaKeys:d})).catch(d=>{c.length?l(c):d instanceof We?o(d):o(new We({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_NO_ACCESS,error:d,fatal:!0},d.message))})};l(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:s}=this.config;if(typeof s!="function"){let r=`Configured requestMediaKeySystemAccess is not a function ${s}`;return tl===null&&self.location.protocol==="http:"&&(r=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(r))}return s(e,t)}getMediaKeysPromise(e,t,s){const r=qh(e,t,s,this.config.drmSystemOptions),i=this.keySystemAccessPromises[e];let a=i==null?void 0:i.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(r)}`),a=this.requestMediaKeySystemAccess(e,r);const o=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),a.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);const c=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),o.mediaKeys=l.createMediaKeys().then(u=>(this.log(`Media-keys created for "${e}"`),c.then(d=>d?this.setMediaKeysServerCertificate(u,e,d):u))),o.mediaKeys.catch(u=>{this.error(`Failed to create media-keys for "${e}"}: ${u}`)}),o.mediaKeys})}return a.then(()=>i.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:s}){this.log(`Creating key-system session "${t}" keyId: ${et.hexDump(e.keyId||[])}`);const r=s.createSession(),i={decryptdata:e,keySystem:t,mediaKeys:s,mediaKeysSession:r,keyStatus:"status-pending"};return this.mediaKeySessions.push(i),i}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const s=this.createMediaKeySessionContext(e),r=this.getKeyIdString(t),i="cenc";this.keyIdToKeySessionPromise[r]=this.generateRequestWithPreferredKeySession(s,i,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return et.hexDump(e.keyId)}updateKeySession(e,t){var s;const r=e.mediaKeysSession;return this.log(`Updating key-session "${r.sessionId}" for keyID ${et.hexDump(((s=e.decryptdata)==null?void 0:s.keyId)||[])}
64
- } (data length: ${t&&t.byteLength})`),r.update(t)}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,s)=>{const r=pn(this.config),i=e.map(Hr).filter(a=>!!a&&r.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(i).then(({keySystem:a})=>{const o=Wr(a);o?t(o):s(new Error(`Unable to find format for key-system "${a}"`))}).catch(s)})}loadKey(e){const t=e.keyInfo.decryptdata,s=this.getKeyIdString(t),r=`(keyId: ${s} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${r}`);let i=this.keyIdToKeySessionPromise[s];return i||(i=this.keyIdToKeySessionPromise[s]=this.getKeySystemForKeyPromise(t).then(({keySystem:a,mediaKeys:o})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${r}`),this.attemptSetMediaKeys(a,o).then(()=>{this.throwIfDestroyed();const l=this.createMediaKeySessionContext({keySystem:a,mediaKeys:o,decryptdata:t});return this.generateRequestWithPreferredKeySession(l,"cenc",t.pssh,"playlist-key")}))),i.catch(a=>this.handleError(a))),i}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof We?this.hls.trigger(y.ERROR,e.data):this.hls.trigger(y.ERROR,{type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){const t=this.getKeyIdString(e),s=this.keyIdToKeySessionPromise[t];if(!s){const r=Hr(e.keyFormat),i=r?[r]:pn(this.config);return this.attemptKeySystemAccess(i)}return s}getKeySystemSelectionPromise(e){if(e.length||(e=pn(this.config)),e.length===0)throw new We({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){const s=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const r=Promise.all(s).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(r),r.then(()=>{this.log(`Media-keys set for "${e}"`),s.push(r),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(i=>s.indexOf(i)===-1)})}generateRequestWithPreferredKeySession(e,t,s,r){var i,a;const o=(i=this.config.drmSystems)==null||(a=i[e.keySystem])==null?void 0:a.generateRequest;if(o)try{const h=o.call(this.hls,t,s,e);if(!h)throw new Error("Invalid response from configured generateRequest filter");t=h.initDataType,s=e.decryptdata.pssh=h.initData?new Uint8Array(h.initData):null}catch(h){var l;if(this.warn(h.message),(l=this.hls)!=null&&l.config.debug)throw h}if(s===null)return this.log(`Skipping key-session request for "${r}" (no initData)`),Promise.resolve(e);const c=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${r}": ${c} (init data type: ${t} length: ${s?s.byteLength:null})`);const u=new xi,d=e._onmessage=h=>{const m=e.mediaKeysSession;if(!m){u.emit("error",new Error("invalid state"));return}const{messageType:p,message:E}=h;this.log(`"${p}" message event for session "${m.sessionId}" message size: ${E.byteLength}`),p==="license-request"||p==="license-renewal"?this.renewLicense(e,E).catch(x=>{this.handleError(x),u.emit("error",x)}):p==="license-release"?e.keySystem===ae.FAIRPLAY&&(this.updateKeySession(e,Gr("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${p}"`)},f=e._onkeystatuseschange=h=>{if(!e.mediaKeysSession){u.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);const p=e.keyStatus;u.emit("keyStatus",p),p==="expired"&&(this.warn(`${e.keySystem} expired for key ${c}`),this.renewKeySession(e))};e.mediaKeysSession.addEventListener("message",d),e.mediaKeysSession.addEventListener("keystatuseschange",f);const g=new Promise((h,m)=>{u.on("error",m),u.on("keyStatus",p=>{p.startsWith("usable")?h():p==="output-restricted"?m(new We({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):p==="internal-error"?m(new We({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${p}"`)):p==="expired"?m(new Error("key expired while generating request")):this.warn(`unhandled key status change "${p}"`)})});return e.mediaKeysSession.generateRequest(t,s).then(()=>{var h;this.log(`Request generated for key-session "${(h=e.mediaKeysSession)==null?void 0:h.sessionId}" keyId: ${c}`)}).catch(h=>{throw new We({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_NO_SESSION,error:h,fatal:!1},`Error generating key-session request: ${h}`)}).then(()=>g).catch(h=>{throw u.removeAllListeners(),this.removeSession(e),h}).then(()=>(u.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,s)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${et.hexDump("buffer"in s?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):new Uint8Array(s))} session keyId: ${et.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){const t=this.config,s=t.loader,r=new s(t),i=this.getServerCertificateUrl(e);return i?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,o)=>{const l={responseType:"arraybuffer",url:i},c=t.certLoadPolicy.default,u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(f,g,h,m)=>{a(f.data)},onError:(f,g,h,m)=>{o(new We({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:h,response:be({url:l.url,data:void 0},f)},`"${e}" certificate request failed (${i}). Status: ${f.code} (${f.text})`))},onTimeout:(f,g,h)=>{o(new We({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:h,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${i})`))},onAbort:(f,g,h)=>{o(new Error("aborted"))}};r.load(l,u,d)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,s){return new Promise((r,i)=>{e.setServerCertificate(s).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${s==null?void 0:s.byteLength}) on "${t}"`),r(e)}).catch(a=>{i(new We({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(s=>this.updateKeySession(e,new Uint8Array(s)).catch(r=>{throw new We({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:r,fatal:!0},r.message)}))}unpackPlayReadyKeyMessage(e,t){const s=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!s.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const r=new DOMParser().parseFromString(s,"application/xml"),i=r.querySelectorAll("HttpHeader");if(i.length>0){let u;for(let d=0,f=i.length;d<f;d++){var a,o;u=i[d];const g=(a=u.querySelector("name"))==null?void 0:a.textContent,h=(o=u.querySelector("value"))==null?void 0:o.textContent;g&&h&&e.setRequestHeader(g,h)}}const l=r.querySelector("Challenge"),c=l==null?void 0:l.textContent;if(!c)throw new Error("Cannot find <Challenge> in key message");return Gr(atob(c))}setupLicenseXHR(e,t,s,r){const i=this.config.licenseXhrSetup;return i?Promise.resolve().then(()=>{if(!s.decryptdata)throw new Error("Key removed");return i.call(this.hls,e,t,s,r)}).catch(a=>{if(!s.decryptdata)throw a;return e.open("POST",t,!0),i.call(this.hls,e,t,s,r)}).then(a=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:a||r})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:r}))}requestLicense(e,t){const s=this.config.keyLoadPolicy.default;return new Promise((r,i)=>{const a=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${a}`);const o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return i(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let l=o.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);const c=this.config.licenseResponseCallback;if(c)try{l=c.call(this.hls,o,a,e)}catch(u){this.error(u)}r(l)}else{const l=s.errorRetry,c=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>c||o.status>=400&&o.status<500)i(new We({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{const u=c-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${u} attempts left`),this.requestLicense(e,t).then(r,i)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:l,licenseChallenge:c})=>{e.keySystem==ae.PLAYREADY&&(c=this.unpackPlayReadyKeyMessage(l,c)),l.send(c)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const s=t.media;this.media=s,s.removeEventListener("encrypted",this.onMediaEncrypted),s.removeEventListener("waitingforkey",this.onWaitingForKey),s.addEventListener("encrypted",this.onMediaEncrypted),s.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Es.clearKeyUriToKeyIdMap();const s=t.length;Jt.CDMCleanupPromise=Promise.all(t.map(r=>this.removeSession(r)).concat(e==null?void 0:e.setMediaKeys(null).catch(r=>{this.log(`Could not clear media keys: ${r}`)}))).then(()=>{s&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(r=>{this.log(`Could not close sessions and clear media keys: ${r}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){const s=t.reduce((r,i)=>(r.indexOf(i.keyFormat)===-1&&r.push(i.keyFormat),r),[]);this.log(`Selecting key-system from session-keys ${s.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(s)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:s}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),s&&s.readyState!==XMLHttpRequest.DONE&&s.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const r=this.mediaKeySessions.indexOf(e);return r>-1&&this.mediaKeySessions.splice(r,1),t.remove().catch(i=>{this.log(`Could not remove session: ${i}`)}).then(()=>t.close()).catch(i=>{this.log(`Could not close session: ${i}`)})}}}Jt.CDMCleanupPromise=void 0;class We extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}var Pe;(function(n){n.MANIFEST="m",n.AUDIO="a",n.VIDEO="v",n.MUXED="av",n.INIT="i",n.CAPTION="c",n.TIMED_TEXT="tt",n.KEY="k",n.OTHER="o"})(Pe||(Pe={}));var Oi;(function(n){n.DASH="d",n.HLS="h",n.SMOOTH="s",n.OTHER="o"})(Oi||(Oi={}));var Bt;(function(n){n.OBJECT="CMCD-Object",n.REQUEST="CMCD-Request",n.SESSION="CMCD-Session",n.STATUS="CMCD-Status"})(Bt||(Bt={}));const H1={[Bt.OBJECT]:["br","d","ot","tb"],[Bt.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[Bt.SESSION]:["cid","pr","sf","sid","st","v"],[Bt.STATUS]:["bs","rtp"]};class es{constructor(e,t){this.value=void 0,this.params=void 0,Array.isArray(e)&&(e=e.map(s=>s instanceof es?s:new es(s))),this.value=e,this.params=t}}class Hc{constructor(e){this.description=void 0,this.description=e}}const K1="Dict";function W1(n){return Array.isArray(n)?JSON.stringify(n):n instanceof Map?"Map{}":n instanceof Set?"Set{}":typeof n=="object"?JSON.stringify(n):String(n)}function j1(n,e,t,s){return new Error(`failed to ${n} "${W1(e)}" as ${t}`,{cause:s})}const Kc="Bare Item",z1="Boolean",q1="Byte Sequence",Y1="Decimal",X1="Integer";function Z1(n){return n<-999999999999999||999999999999999<n}const Q1=/[\x00-\x1f\x7f]+/,J1="Token",eg="Key";function it(n,e,t){return j1("serialize",n,e,t)}function tg(n){if(typeof n!="boolean")throw it(n,z1);return n?"?1":"?0"}function sg(n){return btoa(String.fromCharCode(...n))}function ng(n){if(ArrayBuffer.isView(n)===!1)throw it(n,q1);return`:${sg(n)}:`}function Wc(n){if(Z1(n))throw it(n,X1);return n.toString()}function rg(n){return`@${Wc(n.getTime()/1e3)}`}function jc(n,e){if(n<0)return-jc(-n,e);const t=Math.pow(10,e);if(Math.abs(n*t%1-.5)<Number.EPSILON){const r=Math.floor(n*t);return(r%2===0?r:r+1)/t}else return Math.round(n*t)/t}function ig(n){const e=jc(n,3);if(Math.floor(Math.abs(e)).toString().length>12)throw it(n,Y1);const t=e.toString();return t.includes(".")?t:`${t}.0`}const ag="String";function og(n){if(Q1.test(n))throw it(n,ag);return`"${n.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function lg(n){return n.description||n.toString().slice(7,-1)}function zc(n){const e=lg(n);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw it(e,J1);return e}function Fi(n){switch(typeof n){case"number":if(!H(n))throw it(n,Kc);return Number.isInteger(n)?Wc(n):ig(n);case"string":return og(n);case"symbol":return zc(n);case"boolean":return tg(n);case"object":if(n instanceof Date)return rg(n);if(n instanceof Uint8Array)return ng(n);if(n instanceof Hc)return zc(n);default:throw it(n,Kc)}}function Mi(n){if(/^[a-z*][a-z0-9\-_.*]*$/.test(n)===!1)throw it(n,eg);return n}function Ni(n){return n==null?"":Object.entries(n).map(([e,t])=>t===!0?`;${Mi(e)}`:`;${Mi(e)}=${Fi(t)}`).join("")}function qc(n){return n instanceof es?`${Fi(n.value)}${Ni(n.params)}`:Fi(n)}function cg(n){return`(${n.value.map(qc).join(" ")})${Ni(n.params)}`}function ug(n,e={whitespace:!0}){if(typeof n!="object")throw it(n,K1);const t=n instanceof Map?n.entries():Object.entries(n),s=e!=null&&e.whitespace?" ":"";return Array.from(t).map(([r,i])=>{i instanceof es||(i=new es(i));let a=Mi(r);return i.value===!0?a+=Ni(i.params):(a+="=",Array.isArray(i.value)?a+=cg(i):a+=qc(i)),a}).join(`,${s}`)}function dg(n,e){return ug(n,e)}const fg=n=>n==="ot"||n==="sf"||n==="st",hg=n=>typeof n=="number"?H(n):n!=null&&n!==""&&n!==!1;function pg(n,e){const t=new URL(n),s=new URL(e);if(t.origin!==s.origin)return n;const r=t.pathname.split("/").slice(1),i=s.pathname.split("/").slice(1,-1);for(;r[0]===i[0];)r.shift(),i.shift();for(;i.length;)i.shift(),r.unshift("..");return r.join("/")}function gg(){try{return crypto.randomUUID()}catch{try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{const i=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(r=="x"?i:i&3|8).toString(16)})}}}const Hn=n=>Math.round(n),mg=(n,e)=>(e!=null&&e.baseUrl&&(n=pg(n,e.baseUrl)),encodeURIComponent(n)),Kn=n=>Hn(n/100)*100,yg={br:Hn,d:Hn,bl:Kn,dl:Kn,mtp:Kn,nor:mg,rtp:Kn,tb:Hn};function Eg(n,e){const t={};if(n==null||typeof n!="object")return t;const s=Object.keys(n).sort(),r=ye({},yg,e==null?void 0:e.formatters),i=e==null?void 0:e.filter;return s.forEach(a=>{if(i!=null&&i(a))return;let o=n[a];const l=r[a];l&&(o=l(o,e)),!(a==="v"&&o===1)&&(a=="pr"&&o===1||hg(o)&&(fg(a)&&typeof o=="string"&&(o=new Hc(o)),t[a]=o))}),t}function Yc(n,e={}){return n?dg(Eg(n,e),ye({whitespace:!1},e)):""}function Sg(n,e={}){if(!n)return{};const t=Object.entries(n),s=Object.entries(H1).concat(Object.entries((e==null?void 0:e.customHeaderMap)||{})),r=t.reduce((i,a)=>{var o,l;const[c,u]=a,d=((o=s.find(f=>f[1].includes(c)))==null?void 0:o[0])||Bt.REQUEST;return(l=i[d])!=null||(i[d]={}),i[d][c]=u,i},{});return Object.entries(r).reduce((i,[a,o])=>(i[a]=Yc(o,e),i),{})}function Tg(n,e,t){return ye(n,Sg(e,t))}const xg="CMCD";function vg(n,e={}){if(!n)return"";const t=Yc(n,e);return`${xg}=${encodeURIComponent(t)}`}const Xc=/CMCD=[^&#]+/;function bg(n,e,t){const s=vg(e,t);if(!s)return n;if(Xc.test(n))return n.replace(Xc,s);const r=n.includes("?")?"&":"?";return`${n}${r}${s}`}class Cg{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=r=>{try{this.apply(r,{ot:Pe.MANIFEST,su:!this.initialized})}catch(i){L.warn("Could not generate manifest CMCD data.",i)}},this.applyFragmentData=r=>{try{const i=r.frag,a=this.hls.levels[i.level],o=this.getObjectType(i),l={d:i.duration*1e3,ot:o};(o===Pe.VIDEO||o===Pe.AUDIO||o==Pe.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(r,l)}catch(i){L.warn("Could not generate segment CMCD data.",i)}},this.hls=e;const t=this.config=e.config,{cmcd:s}=t;s!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=s.sessionId||gg(),this.cid=s.contentId,this.useHeaders=s.useHeaders===!0,this.includeKeys=s.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHED,this.onMediaDetached,this),e.on(y.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHED,this.onMediaDetached,this),e.off(y.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var s,r;this.audioBuffer=(s=t.tracks.audio)==null?void 0:s.buffer,this.videoBuffer=(r=t.tracks.video)==null?void 0:r.buffer}createData(){var e;return{v:1,sf:Oi.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){ye(t,this.createData());const s=t.ot===Pe.INIT||t.ot===Pe.VIDEO||t.ot===Pe.MUXED;this.starved&&s&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);const{includeKeys:r}=this;r&&(t=Object.keys(t).reduce((i,a)=>(r.includes(a)&&(i[a]=t[a]),i),{})),this.useHeaders?(e.headers||(e.headers={}),Tg(e.headers,t)):e.url=bg(e.url,t)}getObjectType(e){const{type:t}=e;if(t==="subtitle")return Pe.TIMED_TEXT;if(e.sn==="initSegment")return Pe.INIT;if(t==="audio")return Pe.AUDIO;if(t==="main")return this.hls.audioTracks.length?Pe.VIDEO:Pe.MUXED}getTopBandwidth(e){let t=0,s;const r=this.hls;if(e===Pe.AUDIO)s=r.audioTracks;else{const i=r.maxAutoLevel,a=i>-1?i+1:r.levels.length;s=r.levels.slice(0,a)}for(const i of s)i.bitrate>t&&(t=i.bitrate);return t>0?t:NaN}getBufferLength(e){const t=this.hls.media,s=e===Pe.AUDIO?this.audioBuffer:this.videoBuffer;return!s||!t?NaN:de.bufferInfo(s,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,s=e||this.config.loader;return class{constructor(i){this.loader=void 0,this.loader=new s(i)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(i,a,o){t(i),this.loader.load(i,a,o)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,s=e||this.config.loader;return class{constructor(i){this.loader=void 0,this.loader=new s(i)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(i,a,o){t(i),this.loader.load(i,a,o)}}}}const wg=3e5;class Lg{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=L.log.bind(L,"[content-steering]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.ERROR,this.onError,this))}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter(s=>s!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:s}=t;s!==null&&(this.pathwayId=s.pathwayId,this.uri=s.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:s}=t;if((s==null?void 0:s.action)===Ie.SendAlternateToPenaltyBox&&s.flags===Ye.MoveAllAlternatesMatchingHost){const r=this.levels;let i=this.pathwayPriority,a=this.pathwayId;if(t.context){const{groupId:o,pathwayId:l,type:c}=t.context;o&&r?a=this.getPathwayForGroupId(o,c,a):l&&(a=l)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!i&&r&&(i=r.reduce((o,l)=>(o.indexOf(l.pathwayId)===-1&&o.push(l.pathwayId),o),[])),i&&i.length>1&&(this.updatePathwayPriority(i),s.resolved=this.pathwayId!==a),s.resolved||L.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${r&&r.length} priorities: ${JSON.stringify(i)} penalized: ${JSON.stringify(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){const s=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${s}"`),t=this.getLevelsForPathway(s),this.pathwayId=s}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t;const s=this.penalizedPathways,r=performance.now();Object.keys(s).forEach(i=>{r-s[i]>wg&&delete s[i]});for(let i=0;i<e.length;i++){const a=e[i];if(a in s)continue;if(a===this.pathwayId)return;const o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,Vl(t),this.hls.trigger(y.LEVELS_UPDATED,{levels:t});const c=this.hls.levels[o];l&&c&&this.levels&&(c.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&c.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${c.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,s){const r=this.getLevelsForPathway(s).concat(this.levels||[]);for(let i=0;i<r.length;i++)if(t===se.AUDIO_TRACK&&r[i].hasAudioGroup(e)||t===se.SUBTITLE_TRACK&&r[i].hasSubtitleGroup(e))return r[i].pathwayId;return s}clonePathways(e){const t=this.levels;if(!t)return;const s={},r={};e.forEach(i=>{const{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=i;if(t.some(u=>u.pathwayId===a))return;const c=this.getLevelsForPathway(o).map(u=>{const d=new pe(u.attrs);d["PATHWAY-ID"]=a;const f=d.AUDIO&&`${d.AUDIO}_clone_${a}`,g=d.SUBTITLES&&`${d.SUBTITLES}_clone_${a}`;f&&(s[d.AUDIO]=f,d.AUDIO=f),g&&(r[d.SUBTITLES]=g,d.SUBTITLES=g);const h=Qc(u.uri,d["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),m=new qt({attrs:d,audioCodec:u.audioCodec,bitrate:u.bitrate,height:u.height,name:u.name,url:h,videoCodec:u.videoCodec,width:u.width});if(u.audioGroups)for(let p=1;p<u.audioGroups.length;p++)m.addGroupId("audio",`${u.audioGroups[p]}_clone_${a}`);if(u.subtitleGroups)for(let p=1;p<u.subtitleGroups.length;p++)m.addGroupId("text",`${u.subtitleGroups[p]}_clone_${a}`);return m});t.push(...c),Zc(this.audioTracks,s,l,a),Zc(this.subtitleTracks,r,l,a)})}loadSteeringManifest(e){const t=this.hls.config,s=t.loader;this.loader&&this.loader.destroy(),this.loader=new s(t);let r;try{r=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(r.protocol!=="data:"){const u=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;r.searchParams.set("_HLS_pathway",this.pathwayId),r.searchParams.set("_HLS_throughput",""+u)}const i={responseType:"json",url:r.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},c={onSuccess:(u,d,f,g)=>{this.log(`Loaded steering manifest: "${r}"`);const h=u.data;if(h.VERSION!==1){this.log(`Steering VERSION ${h.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=h.TTL;const{"RELOAD-URI":m,"PATHWAY-CLONES":p,"PATHWAY-PRIORITY":E}=h;if(m)try{this.uri=new self.URL(m,r).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${m}`);return}this.scheduleRefresh(this.uri||f.url),p&&this.clonePathways(p);const x={steeringManifest:h,url:r.toString()};this.hls.trigger(y.STEERING_MANIFEST_LOADED,x),E&&this.updatePathwayPriority(E)},onError:(u,d,f,g)=>{if(this.log(`Error loading steering manifest: ${u.code} ${u.text} (${d.url})`),this.stopLoad(),u.code===410){this.enabled=!1,this.log(`Steering manifest ${d.url} no longer available`);return}let h=this.timeToLoad*1e3;if(u.code===429){const m=this.loader;if(typeof(m==null?void 0:m.getResponseHeader)=="function"){const p=m.getResponseHeader("Retry-After");p&&(h=parseFloat(p)*1e3)}this.log(`Steering manifest ${d.url} rate limited`);return}this.scheduleRefresh(this.uri||d.url,h)},onTimeout:(u,d,f)=>{this.log(`Timeout loading steering manifest (${d.url})`),this.scheduleRefresh(this.uri||d.url)}};this.log(`Requesting steering manifest: ${r}`),this.loader.load(i,l,c)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var s;const r=(s=this.hls)==null?void 0:s.media;if(r&&!r.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}}function Zc(n,e,t,s){n&&Object.keys(e).forEach(r=>{const i=n.filter(a=>a.groupId===r).map(a=>{const o=ye({},a);return o.details=void 0,o.attrs=new pe(o.attrs),o.url=o.attrs.URI=Qc(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[r],o.attrs["PATHWAY-ID"]=s,o});n.push(...i)})}function Qc(n,e,t,s){const{HOST:r,PARAMS:i,[t]:a}=s;let o;e&&(o=a==null?void 0:a[e],o&&(n=o));const l=new self.URL(n);return r&&!o&&(l.host=r),i&&Object.keys(i).sort().forEach(c=>{c&&l.searchParams.set(c,i[c])}),l.href}const Ag=/^age:\s*[\d.]+\s*$/im;class Jc{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 fn,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,t,s){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=s,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const s=this.loader=new self.XMLHttpRequest,r=this.stats;r.loading.first=0,r.loaded=0,r.aborted=!1;const i=this.xhrSetup;i?Promise.resolve().then(()=>{if(!(this.loader!==s||this.stats.aborted))return i(s,t.url)}).catch(a=>{if(!(this.loader!==s||this.stats.aborted))return s.open("GET",t.url,!0),i(s,t.url)}).then(()=>{this.loader!==s||this.stats.aborted||this.openAndSendXhr(s,t,e)}).catch(a=>{this.callbacks.onError({code:s.status,text:a.message},t,s,r)}):this.openAndSendXhr(s,t,e)}openAndSendXhr(e,t,s){e.readyState||e.open("GET",t.url,!0);const r=t.headers,{maxTimeToFirstByteMs:i,maxLoadTimeMs:a}=s.loadPolicy;if(r)for(const o in r)e.setRequestHeader(o,r[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),s.timeout=i&&H(i)?i:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:s}=this;if(!e||!t)return;const r=t.readyState,i=this.config;if(!s.aborted&&r>=2&&(s.loading.first===0&&(s.loading.first=Math.max(self.performance.now(),s.loading.start),i.timeout!==i.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),i.timeout=i.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.loadPolicy.maxLoadTimeMs-(s.loading.first-s.loading.start)))),r===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const a=t.status,o=t.responseType==="text"?t.responseText:null;if(a>=200&&a<300){const d=o??t.response;if(d!=null){s.loading.end=Math.max(self.performance.now(),s.loading.first);const f=t.responseType==="arraybuffer"?d.byteLength:d.length;if(s.loaded=s.total=f,s.bwEstimate=s.total*8e3/(s.loading.end-s.loading.first),!this.callbacks)return;const g=this.callbacks.onProgress;if(g&&g(s,e,d,t),!this.callbacks)return;const h={url:t.responseURL,data:d,code:a};this.callbacks.onSuccess(h,s,e,t);return}}const l=i.loadPolicy.errorRetry,c=s.retry,u={url:e.url,data:void 0,code:a};An(l,c,!1,u)?this.retry(l):(L.error(`${a} while loading ${e.url}`),this.callbacks.onError({code:a,text:t.statusText},e,t,s))}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(An(e,t,!0))this.retry(e);else{var s;L.warn(`timeout while loading ${(s=this.context)==null?void 0:s.url}`);const r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:s}=this;this.retryDelay=oi(e,s.retry),s.retry++,L.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t==null?void 0:t.url}, retrying ${s.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&Ag.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}function Dg(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const Ig=/(\d+)-(\d+)\/(\d+)/;class eu{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||_g,this.controller=new self.AbortController,this.stats=new fn}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,s){const r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now();const i=Rg(e,this.controller.signal),a=s.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:c,maxLoadTimeMs:u}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=s,this.request=this.fetchSetup(e,i),self.clearTimeout(this.requestTimeout),t.timeout=c&&H(c)?c:u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),s.onTimeout(r,e,this.response)},t.timeout),self.fetch(this.request).then(d=>{this.response=this.loader=d;const f=Math.max(self.performance.now(),r.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),s.onTimeout(r,e,this.response)},u-(f-r.loading.start)),!d.ok){const{status:g,statusText:h}=d;throw new Og(h||"fetch, bad network response",g,d)}return r.loading.first=f,r.total=Pg(d.headers)||r.total,a&&H(t.highWaterMark)?this.loadProgressively(d,r,e,t.highWaterMark,a):o?d.arrayBuffer():e.responseType==="json"?d.json():d.text()}).then(d=>{const f=this.response;if(!f)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first);const g=d[l];g&&(r.loaded=r.total=g);const h={url:f.url,data:d,code:f.status};a&&!H(t.highWaterMark)&&a(r,e,d,f),s.onSuccess(h,r,e,f)}).catch(d=>{if(self.clearTimeout(this.requestTimeout),r.aborted)return;const f=d&&d.code||0,g=d?d.message:null;s.onError({code:f,text:g},e,d?d.details:null,r)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,s,r=0,i){const a=new Jl,o=e.body.getReader(),l=()=>o.read().then(c=>{if(c.done)return a.dataLength&&i(t,s,a.flush(),e),Promise.resolve(new ArrayBuffer(0));const u=c.value,d=u.length;return t.loaded+=d,d<r||a.dataLength?(a.push(u),a.dataLength>=r&&i(t,s,a.flush(),e)):i(t,s,u,e),l()}).catch(()=>Promise.reject());return l()}}function Rg(n,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(ye({},n.headers))};return n.rangeEnd&&t.headers.set("Range","bytes="+n.rangeStart+"-"+String(n.rangeEnd-1)),t}function kg(n){const e=Ig.exec(n);if(e)return parseInt(e[2])-parseInt(e[1])+1}function Pg(n){const e=n.get("Content-Range");if(e){const s=kg(e);if(H(s))return s}const t=n.get("Content-Length");if(t)return parseInt(t)}function _g(n,e){return new self.Request(n.url,e)}class Og extends Error{constructor(e,t,s){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=s}}const Fg=/\s/,Mg={newCue(n,e,t,s){const r=[];let i,a,o,l,c;const u=self.VTTCue||self.TextTrackCue;for(let f=0;f<s.rows.length;f++)if(i=s.rows[f],o=!0,l=0,c="",!i.isEmpty()){var d;for(let m=0;m<i.chars.length;m++)Fg.test(i.chars[m].uchar)&&o?l++:(c+=i.chars[m].uchar,o=!1);i.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;const g=_c(c.trim()),h=Di(e,t,g);n!=null&&(d=n.cues)!=null&&d.getCueById(h)||(a=new u(e,t,g),a.id=h,a.line=f+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),r.push(a))}return n&&r.length&&(r.sort((f,g)=>f.line==="auto"||g.line==="auto"?0:f.line>8&&g.line>8?g.line-f.line:f.line-g.line),r.forEach(f=>Pl(n,f))),r}},Ng={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},tu=be(be({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Jc,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:up,bufferController:p1,capLevelController:_i,errorController:Q2,fpsController:G1,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:tl,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,certLoadPolicy:{default:Ng},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},Bg()),{},{subtitleStreamController:u1,subtitleTrackController:f1,timelineController:$1,audioStreamController:l1,audioTrackController:c1,emeController:Jt,cmcdController:Cg,contentSteeringController:Lg});function Bg(){return{cueHandler:Mg,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 Ug(n,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const t=Bi(n),s=["manifest","level","frag"],r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return s.forEach(i=>{const a=`${i==="level"?"playlist":i}LoadPolicy`,o=e[a]===void 0,l=[];r.forEach(c=>{const u=`${i}Loading${c}`,d=e[u];if(d!==void 0&&o){l.push(u);const f=t[a].default;switch(e[a]={default:f},c){case"TimeOut":f.maxLoadTimeMs=d,f.maxTimeToFirstByteMs=d;break;case"MaxRetry":f.errorRetry.maxNumRetry=d,f.timeoutRetry.maxNumRetry=d;break;case"RetryDelay":f.errorRetry.retryDelayMs=d,f.timeoutRetry.retryDelayMs=d;break;case"MaxRetryTimeout":f.errorRetry.maxRetryDelayMs=d,f.timeoutRetry.maxRetryDelayMs=d;break}}}),l.length&&L.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(e[a])}`)}),be(be({},t),e)}function Bi(n){return n&&typeof n=="object"?Array.isArray(n)?n.map(Bi):Object.keys(n).reduce((e,t)=>(e[t]=Bi(n[t]),e),{}):n}function $g(n){const e=n.loader;e!==eu&&e!==Jc?(L.log("[config]: Custom loader detected, cannot enable progressive streaming"),n.progressive=!1):Dg()&&(n.loader=eu,n.progressive=!0,n.enableSoftwareAES=!0,L.log("[config]: Progressive streaming enabled, using FetchLoader"))}let Ui;class Vg extends ci{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this),e.on(y.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this),e.off(y.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const s=this.hls.config.preferManagedMediaSource,r=[],i={},a={};let o=!1,l=!1,c=!1;t.levels.forEach(u=>{var d,f;const g=u.attrs;let{audioCodec:h,videoCodec:m}=u;((d=h)==null?void 0:d.indexOf("mp4a.40.34"))!==-1&&(Ui||(Ui=/chrome|firefox/i.test(navigator.userAgent)),Ui&&(u.audioCodec=h=void 0)),h&&(u.audioCodec=h=xn(h,s)),((f=m)==null?void 0:f.indexOf("avc1"))===0&&(m=u.videoCodec=A2(m));const{width:p,height:E,unknownCodecs:x}=u;if(o||(o=!!(p&&E)),l||(l=!!m),c||(c=!!h),x!=null&&x.length||h&&!Qr(h,"audio",s)||m&&!Qr(m,"video",s))return;const{CODECS:v,"FRAME-RATE":w,"HDCP-LEVEL":b,"PATHWAY-ID":I,RESOLUTION:A,"VIDEO-RANGE":F}=g,O=`${`${I||"."}-`}${u.bitrate}-${A}-${w}-${v}-${F}-${b}`;if(i[O])if(i[O].uri!==u.url&&!u.attrs["PATHWAY-ID"]){const B=a[O]+=1;u.attrs["PATHWAY-ID"]=new Array(B+1).join(".");const Y=new qt(u);i[O]=Y,r.push(Y)}else i[O].addGroupId("audio",g.AUDIO),i[O].addGroupId("text",g.SUBTITLES);else{const B=new qt(u);i[O]=B,a[O]=1,r.push(B)}}),this.filterAndSortMediaOptions(r,t,o,l,c)}filterAndSortMediaOptions(e,t,s,r,i){let a=[],o=[],l=e;if((s||r)&&i&&(l=l.filter(({videoCodec:h,videoRange:m,width:p,height:E})=>(!!h||!!(p&&E))&&$2(m))),l.length===0){Promise.resolve().then(()=>{if(this.hls){t.levels.length&&this.warn(`One or more CODECS in variant not supported: ${JSON.stringify(t.levels[0].attrs)}`);const h=new Error("no level with compatible codecs found in manifest");this.hls.trigger(y.ERROR,{type:Z.MEDIA_ERROR,details:k.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:h,reason:h.message})}});return}if(t.audioTracks){const{preferManagedMediaSource:h}=this.hls.config;a=t.audioTracks.filter(m=>!m.audioCodec||Qr(m.audioCodec,"audio",h)),su(a)}t.subtitles&&(o=t.subtitles,su(o));const c=l.slice(0);l.sort((h,m)=>{if(h.attrs["HDCP-LEVEL"]!==m.attrs["HDCP-LEVEL"])return(h.attrs["HDCP-LEVEL"]||"")>(m.attrs["HDCP-LEVEL"]||"")?1:-1;if(s&&h.height!==m.height)return h.height-m.height;if(h.frameRate!==m.frameRate)return h.frameRate-m.frameRate;if(h.videoRange!==m.videoRange)return Cn.indexOf(h.videoRange)-Cn.indexOf(m.videoRange);if(h.videoCodec!==m.videoCodec){const p=Sl(h.videoCodec),E=Sl(m.videoCodec);if(p!==E)return E-p}if(h.uri===m.uri&&h.codecSet!==m.codecSet){const p=Tn(h.codecSet),E=Tn(m.codecSet);if(p!==E)return E-p}return h.averageBitrate!==m.averageBitrate?h.averageBitrate-m.averageBitrate:0});let u=c[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==c.length)){for(let h=0;h<c.length;h++)if(c[h].pathwayId===l[0].pathwayId){u=c[h];break}}this._levels=l;for(let h=0;h<l.length;h++)if(l[h]===u){var d;this._firstLevel=h;const m=u.bitrate,p=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${m}`),((d=this.hls.userConfig)==null?void 0:d.abrEwmaDefaultEstimate)===void 0){const E=Math.min(m,this.hls.config.abrEwmaDefaultEstimateMax);E>p&&p===tu.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=E)}break}const f=i&&!r,g={levels:l,audioTracks:a,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:i,video:r,altAudio:!f&&a.some(h=>!!h.url)};this.hls.trigger(y.MANIFEST_PARSED,g),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){const u=new Error("invalid level idx"),d=e<0;if(this.hls.trigger(y.ERROR,{type:Z.OTHER_ERROR,details:k.LEVEL_SWITCH_ERROR,level:e,fatal:d,error:u,reason:u.message}),d)return;e=Math.min(e,t.length-1)}const s=this.currentLevelIndex,r=this.currentLevel,i=r?r.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,s===e&&a.details&&r&&i===o)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${o?" with Pathway "+o:""} from level ${s}${i?" with Pathway "+i:""}`);const l={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(y.LEVEL_SWITCHING,l);const c=a.details;if(!c||c.live){const u=this.switchParams(a.uri,r==null?void 0:r.details,c);this.loadPlaylist(u)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){const e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){t.fatal||!t.context||t.context.type===se.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===q.MAIN){const s=t.elementaryStreams;if(!Object.keys(s).some(i=>!!s[i]))return;const r=this._levels[t.level];r!=null&&r.loadError&&(this.log(`Resetting level error count of ${r.loadError} on frag buffered`),r.loadError=0)}}onLevelLoaded(e,t){var s;const{level:r,details:i}=t,a=this._levels[r];if(!a){var o;this.warn(`Invalid level index ${r}`),(o=t.deliveryDirectives)!=null&&o.skip&&(i.deltaUpdateFailed=!0);return}r===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0),this.playlistLoaded(r,t,a.details)):(s=t.deliveryDirectives)!=null&&s.skip&&(i.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist();const t=this.currentLevelIndex,s=this.currentLevel;if(s&&this.shouldLoadPlaylist(s)){let r=s.uri;if(e)try{r=e.addDirectives(r)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}const i=s.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${i?" Pathway "+i:""} ${r}`),this.clearTimer(),this.hls.trigger(y.LEVEL_LOADING,{url:r,level:t,pathwayId:s.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;const s=this._levels.filter((r,i)=>i!==e?!0:(this.steering&&this.steering.removeLevel(r),r===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,r.details&&r.details.fragments.forEach(a=>a.level=-1)),!1));Vl(s),this._levels=s,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(y.LEVELS_UPDATED,{levels:s})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:s}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(y.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:s}))}}function su(n){const e={};n.forEach(t=>{const s=t.groupId||"";t.id=e[s]=e[s]||0,e[s]++})}class Gg{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const s in this.keyUriToKeyInfo){const r=this.keyUriToKeyInfo[s].loader;if(r){var t;if(e&&e!==((t=r.context)==null?void 0:t.frag.type))return;r.abort()}}}detach(){for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=k.KEY_LOAD_ERROR,s,r,i){return new dt({type:Z.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:i,error:s,networkDetails:r})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){const{sn:s,cc:r}=e;for(let i=0;i<t.length;i++){const a=t[i];if(r<=a.cc&&(s==="initSegment"||a.sn==="initSegment"||s<a.sn)){this.emeController.selectKeySystemFormat(a).then(o=>{a.setKeyFormat(o)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var s,r;t&&e.setKeyFormat(t);const i=e.decryptdata;if(!i){const c=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,k.KEY_LOAD_ERROR,c))}const a=i.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,k.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if((s=o)!=null&&s.decryptdata.key)return i.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if((r=o)!=null&&r.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(c=>(i.key=c.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[a]={decryptdata:i,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},i.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return i.keyFormat==="identity"?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,k.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${i.method}"`)))}}loadKeyEME(e,t){const s={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const r=this.emeController.loadKey(s);if(r)return(e.keyLoadPromise=r.then(i=>(e.mediaKeySessionContext=i,s))).catch(i=>{throw e.keyLoadPromise=null,i})}return Promise.resolve(s)}loadKeyHTTP(e,t){const s=this.config,r=s.loader,i=new r(s);return t.keyLoader=e.loader=i,e.keyLoadPromise=new Promise((a,o)=>{const l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},c=s.keyLoadPolicy.default,u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(f,g,h,m)=>{const{frag:p,keyInfo:E,url:x}=h;if(!p.decryptdata||E!==this.keyUriToKeyInfo[x])return o(this.createKeyLoadError(p,k.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),m));E.decryptdata.key=p.decryptdata.key=new Uint8Array(f.data),p.keyLoader=null,E.loader=null,a({frag:p,keyInfo:E})},onError:(f,g,h,m)=>{this.resetLoader(g),o(this.createKeyLoadError(t,k.KEY_LOAD_ERROR,new Error(`HTTP Error ${f.code} loading key ${f.text}`),h,be({url:l.url,data:void 0},f)))},onTimeout:(f,g,h)=>{this.resetLoader(g),o(this.createKeyLoadError(t,k.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),h))},onAbort:(f,g,h)=>{this.resetLoader(g),o(this.createKeyLoadError(t,k.INTERNAL_ABORTED,new Error("key loading aborted"),h))}};i.load(l,u,d)})}resetLoader(e){const{frag:t,keyInfo:s,url:r}=e,i=s.loader;t.keyLoader===i&&(t.keyLoader=null,s.loader=null),delete this.keyUriToKeyInfo[r],i&&i.destroy()}}function nu(){return self.SourceBuffer||self.WebKitSourceBuffer}function ru(){if(!Ot())return!1;const e=nu();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function Hg(){if(!ru())return!1;const n=Ot();return typeof(n==null?void 0:n.isTypeSupported)=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>n.isTypeSupported(Ss(e,"video")))||["mp4a.40.2","fLaC"].some(e=>n.isTypeSupported(Ss(e,"audio"))))}function Kg(){var n;const e=nu();return typeof(e==null||(n=e.prototype)==null?void 0:n.changeType)=="function"}const Wg=250,Wn=2,jg=.1,zg=.05;class qg{constructor(e,t,s,r){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=s,this.hls=r}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){const{config:s,media:r,stalled:i}=this;if(r===null)return;const{currentTime:a,seeking:o}=r,l=this.seeking&&!o,c=!this.seeking&&o;if(this.seeking=o,a!==e){if(this.moved=!0,o||(this.nudgeRetry=0),i!==null){if(this.stallReported){const p=self.performance.now()-i;L.warn(`playback not stuck anymore @${a}, after ${Math.round(p)}ms`),this.stallReported=!1}this.stalled=null}return}if(c||l){this.stalled=null;return}if(r.paused&&!o||r.ended||r.playbackRate===0||!de.getBuffered(r).length){this.nudgeRetry=0;return}const u=de.bufferInfo(r,a,0),d=u.nextStart||0;if(o){const p=u.len>Wn,E=!d||t&&t.start<=a||d-a>Wn&&!this.fragmentTracker.getPartialFragment(a);if(p||E)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var f;if(!(u.len>0)&&!d)return;const E=Math.max(d,u.start||0)-a,x=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,w=(x==null||(f=x.details)==null?void 0:f.live)?x.details.targetduration*2:Wn,b=this.fragmentTracker.getPartialFragment(a);if(E>0&&(E<=w||b)){r.paused||this._trySkipBufferHole(b);return}}const g=self.performance.now();if(i===null){this.stalled=g;return}const h=g-i;if(!o&&h>=Wg&&(this._reportStall(u),!this.media))return;const m=de.bufferInfo(r,a,s.maxBufferHole);this._tryFixBufferStall(m,h)}_tryFixBufferStall(e,t){const{config:s,fragmentTracker:r,media:i}=this;if(i===null)return;const a=i.currentTime,o=r.getPartialFragment(a);o&&(this._trySkipBufferHole(o)||!this.media)||(e.len>s.maxBufferHole||e.nextStart&&e.nextStart-a<s.maxBufferHole)&&t>s.highBufferWatchdogPeriod*1e3&&(L.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){const{hls:t,media:s,stallReported:r}=this;if(!r&&s){this.stallReported=!0;const i=new Error(`Playback stalling at @${s.currentTime} due to low buffer (${JSON.stringify(e)})`);L.warn(i.message),t.trigger(y.ERROR,{type:Z.MEDIA_ERROR,details:k.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len})}}_trySkipBufferHole(e){const{config:t,hls:s,media:r}=this;if(r===null)return 0;const i=r.currentTime,a=de.bufferInfo(r,i,0),o=i<a.start?a.start:a.nextStart;if(o){const l=a.len<=t.maxBufferHole,c=a.len>0&&a.len<1&&r.readyState<3,u=o-i;if(u>0&&(l||c)){if(u>t.maxBufferHole){const{fragmentTracker:f}=this;let g=!1;if(i===0){const h=f.getAppendedFrag(0,q.MAIN);h&&o<h.end&&(g=!0)}if(!g){const h=e||f.getAppendedFrag(i,q.MAIN);if(h){let m=!1,p=h.end;for(;p<o;){const E=f.getPartialFragment(p);if(E)p+=E.duration;else{m=!0;break}}if(m)return 0}}}const d=Math.max(o+zg,i+jg);if(L.warn(`skipping hole, adjusting currentTime from ${i} to ${d}`),this.moved=!0,this.stalled=null,r.currentTime=d,e&&!e.gap){const f=new Error(`fragment loaded with buffer holes, seeking from ${i} to ${d}`);s.trigger(y.ERROR,{type:Z.MEDIA_ERROR,details:k.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:f,reason:f.message,frag:e})}return d}}return 0}_tryNudgeBuffer(){const{config:e,hls:t,media:s,nudgeRetry:r}=this;if(s===null)return;const i=s.currentTime;if(this.nudgeRetry++,r<e.nudgeMaxRetry){const a=i+(r+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${i} to ${a}`);L.warn(o.message),s.currentTime=a,t.trigger(y.ERROR,{type:Z.MEDIA_ERROR,details:k.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{const a=new Error(`Playhead still not moving while enough data buffered @${i} after ${e.nudgeMaxRetry} nudges`);L.error(a.message),t.trigger(y.ERROR,{type:Z.MEDIA_ERROR,details:k.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}}const Yg=100;class Xg extends fi{constructor(e,t,s){super(e,t,s,"[stream-controller]",q.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(y.ERROR,this.onError,this),e.on(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(y.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(y.BUFFER_CREATED,this.onBufferCreated,this),e.on(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(y.ERROR,this.onError,this),e.off(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(y.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(y.BUFFER_CREATED,this.onBufferCreated,this),e.off(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying()}startLoad(e){if(this.levels){const{lastCurrentTime:t,hls:s}=this;if(this.stopLoad(),this.setInterval(Yg),this.level=-1,!this.startFragRequested){let r=s.startLevel;r===-1&&(s.config.testBandwidth&&this.levels.length>1?(r=0,this.bitrateTest=!0):r=s.firstAutoLevel),s.nextLoadLevel=r,this.level=s.loadLevel,this.loadedmetadata=!1}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=M.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=M.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case M.WAITING_LEVEL:{const{levels:t,level:s}=this,r=t==null?void 0:t[s],i=r==null?void 0:r.details;if(i&&(!i.live||this.levelLastLoaded===r)){if(this.waitForCdnTuneIn(i))break;this.state=M.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=M.IDLE;break}break}case M.FRAG_LOADING_WAITING_RETRY:{var e;const t=self.performance.now(),s=this.retryDate;if(!s||t>=s||(e=this.media)!=null&&e.seeking){const{levels:r,level:i}=this,a=r==null?void 0:r[i];this.resetStartWhenNotLoaded(a||null),this.state=M.IDLE}}break}this.state===M.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:s,media:r}=this;if(t===null||!r&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;const i=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(s!=null&&s[i]))return;const a=s[i],o=this.getMainFwdBufferInfo();if(o===null)return;const l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){const m={};this.altAudio&&(m.type="video"),this.hls.trigger(y.BUFFER_EOS,m),this.state=M.ENDED;return}if(!this.buffering)return;e.loadLevel!==i&&e.manualLevel===-1&&this.log(`Adapting to level ${i} from level ${this.level}`),this.level=e.nextLoadLevel=i;const c=a.details;if(!c||this.state===M.WAITING_LEVEL||c.live&&this.levelLastLoaded!==a){this.level=i,this.state=M.WAITING_LEVEL;return}const u=o.len,d=this.getMaxBufferLength(a.maxBitrate);if(u>=d)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);const f=this.backtrackFragment?this.backtrackFragment.start:o.end;let g=this.getNextFragment(f,c);if(this.couldBacktrack&&!this.fragPrevious&&g&&g.sn!=="initSegment"&&this.fragmentTracker.getState(g)!==Ce.OK){var h;const p=((h=this.backtrackFragment)!=null?h:g).sn-c.startSN,E=c.fragments[p-1];E&&g.cc===E.cc&&(g=E,this.fragmentTracker.removeFragment(E))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(g&&this.isLoopLoading(g,f)){if(!g.gap){const p=this.audioOnly&&!this.altAudio?le.AUDIO:le.VIDEO,E=(p===le.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;E&&this.afterBufferFlushed(E,p,q.MAIN)}g=this.getNextFragmentLoopLoading(g,c,o,q.MAIN,d)}g&&(g.initSegment&&!g.initSegment.data&&!this.bitrateTest&&(g=g.initSegment),this.loadFragment(g,a,f))}loadFragment(e,t,s){const r=this.fragmentTracker.getState(e);this.fragCurrent=e,r===Ce.NOT_LOADED||r===Ce.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,s)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,q.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(t!=null&&t.readyState){let s;const r=this.getAppendedFrag(t.currentTime);r&&r.start>1&&this.flushMainBuffer(0,r.start-1);const i=this.getLevelDetails();if(i!=null&&i.live){const o=this.getMainFwdBufferInfo();if(!o||o.len<i.targetduration*2)return}if(!t.paused&&e){const o=this.hls.nextLoadLevel,l=e[o],c=this.fragLastKbps;c&&this.fragCurrent?s=this.fragCurrent.duration*l.maxBitrate/(1e3*c)+1:s=0}else s=0;const a=this.getBufferedFrag(t.currentTime+s);if(a){const o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();const l=o.maxStartPTS?o.maxStartPTS:o.start,c=o.duration,u=Math.max(a.end,l+Math.min(Math.max(c-this.config.maxFragLookUpTolerance,c*(this.couldBacktrack?.5:.125)),c*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(u,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case M.KEY_LOADING:case M.FRAG_LOADING:case M.FRAG_LOADING_WAITING_RETRY:case M.PARSING:case M.PARSED:this.state=M.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const s=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),s.addEventListener("playing",this.onvplaying),s.addEventListener("seeked",this.onvseeked),this.gapController=new qg(this.config,s,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const e=this.media,t=e?e.currentTime:null;H(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);const s=this.getMainFwdBufferInfo();if(s===null||s.len===0){this.warn(`Main forward buffer length on "seeked" event ${s?s.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(y.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1}onManifestParsed(e,t){let s=!1,r=!1;t.levels.forEach(i=>{const a=i.audioCodec;a&&(s=s||a.indexOf("mp4a.40.2")!==-1,r=r||a.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=s&&r&&!Kg(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:s}=this;if(!s||this.state!==M.IDLE)return;const r=s[t.level];(!r.details||r.details.live&&this.levelLastLoaded!==r||this.waitForCdnTuneIn(r.details))&&(this.state=M.WAITING_LEVEL)}onLevelLoaded(e,t){var s;const{levels:r}=this,i=t.level,a=t.details,o=a.totalduration;if(!r){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:${o}`);const l=r[i],c=this.fragCurrent;c&&(this.state===M.FRAG_LOADING||this.state===M.FRAG_LOADING_WAITING_RETRY)&&c.level!==t.level&&c.loader&&this.abortCurrentFrag();let u=0;if(a.live||(s=l.details)!=null&&s.live){var d;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;u=this.alignPlaylists(a,l.details,(d=this.levelLastLoaded)==null?void 0:d.details)}if(l.details=a,this.levelLastLoaded=l,this.hls.trigger(y.LEVEL_UPDATED,{details:a,level:i}),this.state===M.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=M.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,u),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:s,part:r,payload:i}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${s.sn} of level ${s.level} will not be buffered`);return}const o=a[s.level],l=o.details;if(!l){this.warn(`Dropping fragment ${s.sn} of level ${s.level} after level details were reset`),this.fragmentTracker.removeFragment(s);return}const c=o.videoCodec,u=l.PTSKnown||!l.live,d=(t=s.initSegment)==null?void 0:t.data,f=this._getAudioCodec(o),g=this.transmuxer=this.transmuxer||new xc(this.hls,q.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),h=r?r.index:-1,m=h!==-1,p=new ui(s.level,s.sn,s.stats.chunkCount,i.byteLength,h,m),E=this.initPTS[s.cc];g.push(i,d,f,c,s,r,l.totalduration,u,p,E)}onAudioTrackSwitching(e,t){const s=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const i=this.hls;s&&(i.trigger(y.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),i.trigger(y.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const s=t.id,r=!!this.hls.audioTracks[s].url;if(r){const i=this.videoBuffer;i&&this.mediaBuffer!==i&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=r,this.tick()}onBufferCreated(e,t){const s=t.tracks;let r,i,a=!1;for(const o in s){const l=s[o];if(l.id==="main"){if(i=o,r=l,o==="video"){const c=s[o];c&&(this.videoBuffer=c.buffer)}}else a=!0}a&&r?(this.log(`Alternate track found, use ${i}.buffered to schedule main fragment loading`),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:s,part:r}=t;if(s&&s.type!==q.MAIN)return;if(this.fragContextChanged(s)){this.warn(`Fragment ${s.sn}${r?" p: "+r.index:""} of level ${s.level} finished buffering, but was aborted. state: ${this.state}`),this.state===M.PARSED&&(this.state=M.IDLE);return}const i=r?r.stats:s.stats;this.fragLastKbps=Math.round(8*i.total/(i.buffering.end-i.loading.first)),s.sn!=="initSegment"&&(this.fragPrevious=s),this.fragBufferedComplete(s,r)}onError(e,t){var s;if(t.fatal){this.state=M.ERROR;return}switch(t.details){case k.FRAG_GAP:case k.FRAG_PARSING_ERROR:case k.FRAG_DECRYPT_ERROR:case k.FRAG_LOAD_ERROR:case k.FRAG_LOAD_TIMEOUT:case k.KEY_LOAD_ERROR:case k.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(q.MAIN,t);break;case k.LEVEL_LOAD_ERROR:case k.LEVEL_LOAD_TIMEOUT:case k.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===M.WAITING_LEVEL&&((s=t.context)==null?void 0:s.type)===se.LEVEL&&(this.state=M.IDLE);break;case k.BUFFER_APPEND_ERROR:case k.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;if(t.details===k.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case k.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){const{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!de.getBuffered(e).length){const s=this.state!==M.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,s)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=M.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==le.AUDIO||this.audioOnly&&!this.altAudio){const s=(t===le.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(s,t,q.MAIN),this.tick()}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let s=this.startPosition;if(s>=0&&t<s){if(e.seeking){this.log(`could not seek to ${s}, already seeking at ${t}`);return}const r=de.getBuffered(e),a=(r.length?r.start(0):0)-s;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${a} to match buffer start`),s+=a,this.startPosition=s),this.log(`seek to target start position ${s} from current time ${t}`),e.currentTime=s}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(s=>{const{hls:r}=this;if(!s||this.fragContextChanged(e))return;t.fragmentError=0,this.state=M.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const i=e.stats;i.parsing.start=i.parsing.end=i.buffering.start=i.buffering.end=self.performance.now(),r.trigger(y.FRAG_LOADED,s),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;const s="main",{hls:r}=this,{remuxResult:i,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}const{frag:l,part:c,level:u}=o,{video:d,text:f,id3:g,initSegment:h}=i,{details:m}=u,p=this.altAudio?void 0:i.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=M.PARSING,h){if(h!=null&&h.tracks){const v=l.initSegment||l;this._bufferInitSegment(u,h.tracks,v,a),r.trigger(y.FRAG_PARSING_INIT_SEGMENT,{frag:v,id:s,tracks:h.tracks})}const E=h.initPTS,x=h.timescale;H(E)&&(this.initPTS[l.cc]={baseTime:E,timescale:x},r.trigger(y.INIT_PTS_FOUND,{frag:l,id:s,initPTS:E,timescale:x}))}if(d&&m&&l.sn!=="initSegment"){const E=m.fragments[l.sn-1-m.startSN],x=l.sn===m.startSN,v=!E||l.cc>E.cc;if(i.independent!==!1){const{startPTS:w,endPTS:b,startDTS:I,endDTS:A}=d;if(c)c.elementaryStreams[d.type]={startPTS:w,endPTS:b,startDTS:I,endDTS:A};else if(d.firstKeyFrame&&d.independent&&a.id===1&&!v&&(this.couldBacktrack=!0),d.dropped&&d.independent){const F=this.getMainFwdBufferInfo(),U=(F?F.end:this.getLoadPosition())+this.config.maxBufferHole,O=d.firstKeyFramePTS?d.firstKeyFramePTS:w;if(!x&&U<O-this.config.maxBufferHole&&!v){this.backtrack(l);return}else v&&(l.gap=!0);l.setElementaryStreamInfo(d.type,l.start,b,l.start,A,!0)}else x&&w>Wn&&(l.gap=!0);l.setElementaryStreamInfo(d.type,w,b,I,A),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(d,l,c,a,x||v)}else if(x||v)l.gap=!0;else{this.backtrack(l);return}}if(p){const{startPTS:E,endPTS:x,startDTS:v,endDTS:w}=p;c&&(c.elementaryStreams[le.AUDIO]={startPTS:E,endPTS:x,startDTS:v,endDTS:w}),l.setElementaryStreamInfo(le.AUDIO,E,x,v,w),this.bufferFragmentData(p,l,c,a)}if(m&&g!=null&&(t=g.samples)!=null&&t.length){const E={id:s,frag:l,details:m,samples:g.samples};r.trigger(y.FRAG_PARSING_METADATA,E)}if(m&&f){const E={id:s,frag:l,details:m,samples:f.samples};r.trigger(y.FRAG_PARSING_USERDATA,E)}}_bufferInitSegment(e,t,s,r){if(this.state!==M.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;const{audio:i,video:a,audiovideo:o}=t;if(i){let l=e.audioCodec;const c=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5");const u=i.metadata;u&&"channelCount"in u&&(u.channelCount||1)!==1&&c.indexOf("firefox")===-1&&(l="mp4a.40.5")}l&&l.indexOf("mp4a.40.5")!==-1&&c.indexOf("android")!==-1&&i.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),i.levelCodec=l,i.id="main",this.log(`Init audio buffer, container:${i.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${i.codec}]`)}a&&(a.levelCodec=e.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),this.hls.trigger(y.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{const u=t[l].initSegment;u!=null&&u.byteLength&&this.hls.trigger(y.BUFFER_APPENDING,{type:l,data:u,frag:s,part:null,chunkMeta:r,parent:s.type})}),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,q.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=M.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const s=e.currentTime;if(de.isBuffered(e,s)?t=this.getAppendedFrag(s):de.isBuffered(e,s+.1)&&(t=this.getAppendedFrag(s+.1)),t){this.backtrackFragment=null;const r=this.fragPlaying,i=t.level;(!r||t.sn!==r.sn||r.level!==i)&&(this.fragPlaying=t,this.hls.trigger(y.FRAG_CHANGED,{frag:t}),(!r||r.level!==i)&&this.hls.trigger(y.LEVEL_SWITCHED,{level:i}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){const e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){const e=this.media;if(e){const t=e.currentTime,s=this.currentFrag;if(s&&H(t)&&H(s.programDateTime)){const r=s.programDateTime+(t-s.start)*1e3;return new Date(r)}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class he{static get version(){return"1.5.20"}static isMSESupported(){return ru()}static isSupported(){return Hg()}static getMediaSource(){return Ot()}static get Events(){return y}static get ErrorTypes(){return Z}static get ErrorDetails(){return k}static get DefaultConfig(){return he.defaultConfig?he.defaultConfig:tu}static set DefaultConfig(e){he.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new xi,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,Bh(e.debug||!1,"Hls instance");const t=this.config=Ug(he.DefaultConfig,e);this.userConfig=e,t.progressive&&$g(t);const{abrController:s,bufferController:r,capLevelController:i,errorController:a,fpsController:o}=t,l=new a(this),c=this.abrController=new s(this),u=this.bufferController=new r(this),d=this.capLevelController=new i(this),f=new o(this),g=new P2(this),h=new N2(this),m=t.contentSteeringController,p=m?new m(this):null,E=this.levelController=new Vg(this,p),x=new fp(this),v=new Gg(this.config),w=this.streamController=new Xg(this,x,v);d.setStreamController(w),f.setStreamController(w);const b=[g,E,w];p&&b.splice(1,0,p),this.networkControllers=b;const I=[c,u,d,f,h,x];this.audioTrackController=this.createController(t.audioTrackController,b);const A=t.audioStreamController;A&&b.push(new A(this,x,v)),this.subtitleTrackController=this.createController(t.subtitleTrackController,b);const F=t.subtitleStreamController;F&&b.push(new F(this,x,v)),this.createController(t.timelineController,I),v.emeController=this.emeController=this.createController(t.emeController,I),this.cmcdController=this.createController(t.cmcdController,I),this.latencyController=this.createController(B2,I),this.coreComponents=I,b.push(l);const U=l.onErrorOut;typeof U=="function"&&this.on(y.ERROR,U,l)}createController(e,t){if(e){const s=new e(this);return t&&t.push(s),s}return null}on(e,t,s=this){this._emitter.on(e,t,s)}once(e,t,s=this){this._emitter.once(e,t,s)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,s=this,r){this._emitter.off(e,t,s,r)}listeners(e){return this._emitter.listeners(e)}emit(e,t,s){return this._emitter.emit(e,t,s)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(s){if(L.error("An internal error happened while handling event "+e+'. Error message: "'+s.message+'". Here is a stacktrace:',s),!this.triggeringException){this.triggeringException=!0;const r=e===y.ERROR;this.trigger(y.ERROR,{type:Z.OTHER_ERROR,details:k.INTERNAL_EXCEPTION,fatal:r,event:e,error:s}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){L.log("destroy"),this.trigger(y.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){L.log("attachMedia"),this._media=e,this.trigger(y.MEDIA_ATTACHING,{media:e})}detachMedia(){L.log("detachMedia"),this.trigger(y.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();const t=this.media,s=this.url,r=this.url=Br.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,L.log(`loadSource:${r}`),t&&s&&(s!==r||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(y.MANIFEST_LOADING,{url:e})}startLoad(e=-1){L.log(`startLoad(${e})`),this.started=!0,this.resumeBuffering();for(let t=0;t<this.networkControllers.length&&(this.networkControllers[t].startLoad(e),!(!this.started||!this.networkControllers));t++);}stopLoad(){L.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!(this.started||!this.networkControllers));e++);}resumeBuffering(){L.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()})}pauseBuffering(){L.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()})}swapAudioCodec(){L.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){L.log("recoverMediaError");const e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e){this.levelController.removeLevel(e)}get levels(){const e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){L.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){L.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){L.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){L.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){L.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(L.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){U2(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const s=e.length;for(let r=0;r<s;r++)if(e[r].maxBitrate>=t)return r;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:s}=this;let r;if(t===-1&&e!=null&&e.length?r=e.length-1:r=t,s)for(let i=r;i--;){const a=e[i].attrs["HDCP-LEVEL"];if(a&&a<=s)return i}return r}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}setAudioOption(e){var t;return(t=this.audioTrackController)==null?void 0:t.setAudioOption(e)}setSubtitleOption(e){var t;return(t=this.subtitleTrackController)==null||t.setSubtitleOption(e),null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}he.defaultConfig=void 0;const jn=n=>{n.preventDefault();let e=(N()||Ge()).error;if(e)switch(e.code){case e.MEDIA_ERR_ABORTED:ct({type:"videoTagError",message:"You aborted the video playback."});break;case e.MEDIA_ERR_NETWORK:ct({type:"videoTagError",message:"A network error caused the video download to fail part-way."});break;case e.MEDIA_ERR_DECODE:ct({type:"videoTagError",message:"The video playback was aborted due to a corruption problem or because the video used features your browser did not support."});break;case e.MEDIA_ERR_SRC_NOT_SUPPORTED:ct({type:"videoTagError",message:"The video could not be loaded, either because the server or network failed or because the format is not supported."});break;default:ct({type:"videoTagError",message:"An unknown error occurred."});break}else ct({type:"videoTagError",message:"An error occurred, but the error object is not available."})},iu=()=>{const n=R.dispatch,{params:e}=R.getState().videoData,t=s=>{s.requestFullScreen?s.requestFullScreen():s.mozRequestFullScreen?s.mozRequestFullScreen():s.webkitRequestFullScreen&&s.webkitRequestFullScreen()};n(Ws()),t(document.documentElement),n(is(e.fullscreen==="true"))},au=()=>{let n=".ts",e=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(){arguments[1].endsWith(n)&&(arguments[1]=arguments[1]+"?uuid="+lt()),e.apply(this,arguments)}},Zg=(n,e)=>{const t=R.dispatch;e.current=setInterval(()=>{const r=n.target.buffered.end(0)/N().duration*100;t(_a(r))},500)},Qg=()=>{const n=za("mainPlayer");return{xhrSetup:(e,t)=>{t.split("m3u8")[1]||(t=`${t}${n}`),e.open("GET",t,!0)},startLevel:-1,debug:!1,enableWorker:!0,abrBandWidthUpFactor:.7,abrBandWidthFactor:.95,backBufferLength:1/0,maxBufferLength:30,maxMaxBufferLength:60,manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:10,retryDelayMs:5e3,maxRetryDelayMs:1e4},errorRetry:{maxNumRetry:10,retryDelayMs:5e3,maxRetryDelayMs:1e4}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:10,retryDelayMs:5e3,maxRetryDelayMs:1e4},errorRetry:{maxNumRetry:10,retryDelayMs:5e3,maxRetryDelayMs:1e4}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:10,retryDelayMs:5e3,maxRetryDelayMs:1e4},errorRetry:{maxNumRetry:10,retryDelayMs:5e3,maxRetryDelayMs:1e4}}}}},Jg=()=>{const n=za("miniPlayer");return{xhrSetup:(e,t)=>{t=`${t}${n}`,e.open("GET",t,!0)},startLevel:1,debug:!1,maxMaxBufferLength:60,playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1e3,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1e3,retryDelayMs:1e3,maxRetryDelayMs:1e3}}}}},ou=n=>{const e=R.dispatch;let t=[],s=[];n.levels.map(r=>{t.push(r.attrs.RESOLUTION.split("x")[1].trim()),s.push(r.attrs.RESOLUTION)}),n.autoLevelCapping=Za(s,window.innerWidth,window.innerHeight),e(l0(t)),["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","msfullscreenchange"].forEach(r=>document.addEventListener(r,()=>{C(T.isAutoQuality)&&(n.autoLevelCapping=Za(s,window.innerWidth,window.innerHeight),n.nextLevel=-1)},!1))},lu=(n,e)=>{const{details:t}=R.getState().videoData;let s=t.stream_link;e.loadSource(s),e.on(n.Events.MANIFEST_PARSED,()=>ou(e))},cu=(n,e,t)=>{if(e.frag.type!=="audio"){const s=R.dispatch,{settings:r}=R.getState().user,{qualityLevels:i,manualQuality:a,autoQuality:o}=R.getState().controller;C(T.isAutoQuality)?C(T.isAutoQuality)&&o===void 0?(n.nextLevel=-1,t(i[e.frag.level]),s(Us(e.frag.level))):C(T.isAutoQuality)&&(t(i[e.frag.level]),o!==e.frag.level&&s(Us(e.frag.level))):(e.frag.level!==a&&(n.nextLevel=i[r.quality]?r.quality:-1),i[r.quality]?(s(c0(r.quality)),s(Us(void 0))):(t(i[e.frag.level]),s(Us(e.frag.level)),s(ot({...r,quality:-1}))))}},uu=n=>{var r;const e=R.dispatch,s=((r=n.mainForwardBufferInfo)==null?void 0:r.end)/N().duration*100;e(_a(s))},du=(n,e,t)=>{const{params:s}=R.getState().videoData;s.type&&cu(n,e,t)},fu=(n,e,t)=>{const{type:s}=R.getState().videoData.params;s&&cu(n,e,t)},hu=n=>{if(n.event!=="hlsAudioTrackLoading")return{type:"HLS_"+n.type,message:n.error.message}},pu=(n,e)=>{const t=R.dispatch;n.preventDefault(),e.current=Date.now(),t(Gt(!0))},em=(n,e)=>{const t=R.dispatch;n.preventDefault(),e.current=0,t(Gt(!0))},tm=(n,e)=>{const t=R.dispatch,{videoSettings:s}=R.getState().user,{params:r}=R.getState().videoData;n.preventDefault(),e.current=Date.now(),t(Ze(!0)),C(T.hasOnPlayParams)&&r.onPlay(),C(T.isFirstPlay)&&(C(T.hasCurrentTimeParams)||(N().currentTime=s.time,t(Vt(s.time))),C(T.hasFullScreenParams)&&iu(),C(T.isFullScreen)&&Nr(),t($s([Math.floor(N().currentTime)]))),oe(Ho(!0)),t(as(""))},sm=(n,e,t,s,r,i,a,o)=>{const l=R.dispatch,{autoQuality:c,canPlayVideo:u,firstPlay:d,qualityLevels:f}=R.getState().controller,{settings:g}=R.getState().user,h=g.quality===-1&&c?f[c]:f[g.quality];let m=0;a.current&&(m=Date.now()-a.current),d&&N().played&&oe(Ko(e.current,Date.now()-t.current,s.current-t.current,Date.now()-r.current,r)),l(hr(!1)),u&&m>0&&h!==void 0&&(i.current=m,a.current=0,oe(mh(m,h,r,n,o.current)),n.current=n.current+1,r.current=Date.now())},gu=n=>{const e=R.dispatch,{params:t}=R.getState().videoData;n.preventDefault(),oe(Ho(!1)),e(Ze(!1)),C(T.hasOnPauseParams)&&t.onPause()},nm=n=>{const e=R.dispatch,{selectedSubtitle:t}=R.getState().videoData;n.preventDefault(),e(Vt(n.target.currentTime)),C(T.hasActiveCue)&&e(as(t.activeCues[0].text))},mu=n=>{const e=R.dispatch,{settings:t}=R.getState().user;if(n.preventDefault(),e(Gt(!1)),e(Fa(!0)),N().volume=t.volume/100,e(Pa(n.target.duration)),C(T.isIOS)){const s=Object.values(n.target.textTracks);s&&s.length&&e(Vs(Object.values(s[0]).length?s:[]))}else e(Vs(Object.values(n.target.textTracks)))},rm=n=>{const e=R.dispatch,{params:t}=R.getState().videoData;n.preventDefault(),e(gr(!0)),e(Se(!0)),ps(N().duration),C(T.hasOnFinishedParams)&&t.onFinished()},im=(n,e)=>{const t=R.dispatch;n.preventDefault(),e.current=Date.now(),t(hr(!1))},am=()=>{const n=R.dispatch;n(Gt(!1))},om=n=>{const e=R.dispatch;n.preventDefault(),e(Vt(n.target.currentTime))},lm=()=>{const n=R.dispatch,{params:e}=R.getState().videoData;n(gr(!0)),n(Se(!0)),C(T.hasOnFinishedParams)&&e.onFinished()},cm=n=>{const e=R.dispatch;n.preventDefault(),e(Ze(!1))},um=(n,e)=>{const t=R.dispatch;n.preventDefault(),t(Ze(!0)),e.current=Date.now(),t(as("")),C(T.isFirstPlay)&&C(T.hasFullScreenParams)&&(iu(),C(T.isFullScreen)&&Nr())},dm=(n,e,t)=>{const s=R.dispatch,{firstPlay:r}=R.getState().controller;s(Gt(!1)),r&&N().played&&oe(Ko(Math.round(n.current),Date.now()-e.current,0,Date.now()-t.current,t)),s(hr(!1))},fm=n=>{const e=R.dispatch,{selectedSubtitle:t}=R.getState().videoData;n.preventDefault(),e(Vt(n.target.currentTime)),e(Pa(n.target.duration)),C(T.hasActiveCue)&&e(as(t.activeCues[0].text))},hm=n=>{const e=R.dispatch;if(n.preventDefault(),e(Gt(!1)),e(Fa(!0)),C(T.isIOS)){const t=Object.values(n.target.textTracks);t&&t.length&&e(Vs(Object.values(t[0]).length?t:[]))}else e(Vs(Object.values(n.target.textTracks)))},pm=(n,e)=>{n.preventDefault(),Zg(n,e)},yu=async n=>{const{stream_link:e}=R.getState().miniPlayer.details;n.loadSource(e)},Eu=()=>{ps(N().currentTime)},gm=()=>{const n=ve(),e=V(s=>s.miniPlayer.details),t=V(s=>s.miniPlayer.params);return P.useEffect(()=>{let s=new he(Jg());return he.isSupported()?(s.attachMedia(document.getElementById("mini-player-video-tag")),s.on(he.Events.MEDIA_ATTACHED,()=>yu(s))):N().canPlayType("application/vnd.apple.mpegurl")&&(N().src=e.stream_link,au()),()=>{n(C0()),s.detachMedia(),s.off(he.Events.MEDIA_ATTACHED,()=>yu(s))}},[]),P.useEffect(()=>{t.currentTime&&(n(mt(!0)),Ge().currentTime=t.currentTime,n(Ze(!1)),N().pause())},[t.currentTime]),S.jsx(S.Fragment,{children:S.jsx("video",{onPlay:()=>n(mt(!0)),onEnded:()=>n(mt(!1)),onError:jn,poster:t.banner?t.banner:e.banner,id:"mini-player-video-tag",className:"pl-absolute pl-h-full pl-w-full pl-bg-black",autoPlay:!0,muted:!0})})},mm=()=>{const n=ve(),e=V(t=>t.miniPlayer.params);return P.useEffect(()=>{e.currentTime&&(n(mt(!0)),Ge().currentTime=e.currentTime,n(Ze(!1)),N().pause())},[e.currentTime]),S.jsx("video",{poster:e.banner,onPlay:()=>n(mt(!0)),onEnded:()=>n(mt(!1)),onError:jn,src:e.id,id:"mini-player-video-tag",className:"pl-absolute pl-h-full pl-w-full pl-bg-black",autoPlay:!0})},ym=()=>{const n=V(e=>e.miniPlayer.params.type);return S.jsx(S.Fragment,{children:n===xt.static?S.jsx(mm,{}):S.jsx(gm,{})})},Em=({params:n})=>{const e=ve(),t=V(a=>a.miniPlayer.details),s=V(a=>a.miniPlayer.params);V(a=>a.miniPlayer.play);const r=V(a=>a.videoData.params);P.useEffect(()=>{e(v0(n))},[]);const i=async()=>await qo(n.id);return P.useEffect(()=>{n.id&&n.type==="vod"&&i()},[n.id]),S.jsx(S.Fragment,{children:t.stream_link||s.type==="static"&&s.id?S.jsxs("div",{id:"miniPlayer-video-area",style:{zIndex:_e.miniPlayer},className:"pl-relative pl-h-full pl-w-full",children:[S.jsx("div",{className:`pl-absolute pl-right-3 pl-top-3 pl-z-[1000000] pl-cursor-pointer ${C(T.isActiveElements)?"animate__fadeIn pl-pointer-events-auto":"animate__fadeOut pl-pointer-events-none"}`,onClick:()=>{r.id===s.id&&(N().currentTime=Ge().currentTime,e(Vt(Ge().currentTime))),localStorage.setItem("close-miniPlayer","true"),n.onClose()},children:S.jsx("img",{className:"pl-size-4 pl-cursor-pointer",src:re.closeSquare,alt:"close-square"})}),S.jsx("div",{className:`animate__animated animate__faster pl-absolute pl-bottom-0 pl-z-[1000000] pl-w-full ${C(T.isActiveElements)&&!C(T.isLoading)?"animate__fadeIn pl-pointer-events-auto":"animate__fadeOut pl-pointer-events-none"}`,children:S.jsx("div",{className:"pl-flex pl-w-full pl-justify-center",children:S.jsx(Ih,{})})}),S.jsx(ym,{})]}):S.jsx("div",{className:"pl-h-full pl-w-full pl-bg-white"})})},Sm=({params:n})=>S.jsx(Yi,{store:R,children:S.jsx(Yo,{children:S.jsx(Em,{params:n})})}),Tm=()=>{const{details:n,params:e}=V(({videoData:{details:t,params:s}})=>({details:t,params:s}),K);return S.jsx("div",{className:`animate__animated animate__faster pl-ml-4 pl-w-full pl-max-w-[80%] pl-self-start pl-truncate pl-break-words pl-text-left pl-text-[16px] pl-font-normal pl-text-white ${C(T.isActiveElements)?"animate__fadeIn pl-opacity-100":"animate__fadeOut pl-opacity-0"}`,children:C(T.hasTitle)?n.title:e.id})},xm=()=>S.jsxs("div",{className:`animate__animated animate__faster pl-relative ${C(T.isActiveElements)?"animate__fadeIn pl-pointer-events-auto":"animate__fadeOut pl-pointer-events-none"}`,children:[S.jsx("img",{src:re.lock,alt:"lock-icon",width:20,height:20,onClick:()=>jo("unlock")}),!localStorage.getItem("unlock-click")&&S.jsx("p",{className:"pl-absolute pl-left-0 pl-w-max pl-rounded-[8px] pl-bg-[#F7F7F7] pl-px-4 pl-py-3 pl-text-[10px] pl-text-black/[0.87]",children:xe("clickToUnlock")})]}),vm=()=>(V(({controller:{lock:n,activeElements:e}})=>({lock:n,activeElements:e}),K),S.jsxs("div",{className:`pl-mx-4 pl-mt-5 pl-flex pl-items-start pl-justify-end ${C(T.isTouchScreenPortrait)?"pl-h-4":"pl-h-[60px]"}`,children:[C(T.showTitle)&&S.jsx(Tm,{}),C(T.isLock)&&S.jsx(xm,{})]}));function bm(n,e=300,t={}){const s=P.useRef(null),r=P.useCallback(i=>{s.current?(clearTimeout(s.current),s.current=null,n&&n(i)):s.current=setTimeout(()=>{t.onSingleTap&&t.onSingleTap(i),s.current=null},e)},[n,e,t.onSingleTap]);return n?{onClick:r}:{}}const Su=1e3,$i=({type:n,isRightDoubleTouched:e,isLeftDoubleTouched:t,setIsRightDoubleTouched:s,setIsLeftDoubleTouched:r})=>{const[i,a]=P.useState(15),[o,l]=P.useState(!1),c=P.useRef(i),u=ve(),{duration:d}=V(({controller:{currentTime:E,duration:x}})=>({currentTime:E,duration:x}),K),{videoElementSizeInfo:f}=V(({videoData:{videoElementSizeInfo:E,params:x}})=>({videoElementSizeInfo:E,params:x}),K),g=P.useRef(null);P.useEffect(()=>{c.current=i},[i]);let h;h=bm(E=>{["touchBackward","touchForward"].includes(n)&&(E.stopPropagation(),n==="touchBackward"&&r?r(!0):n==="touchForward"&&s&&s(!0),clearTimeout(g.current),g.current=setTimeout(()=>l(!0),Su))},200),P.useEffect(()=>{o&&(l(!1),u(Se(!1)),e&&s?(s(!1),N().duration-N().currentTime<=c.current?Rt(n,N().duration):Rt(n,c.current),a(15)):t&&r&&(r(!1),N().currentTime<=c.current?Rt(n,0):Rt(n,c.current),a(15)))},[o]);const m=E=>{a(x=>x+15),C(T.isTouchScreenLandscape)&&R0(E,n),clearTimeout(g.current),g.current=setTimeout(()=>l(!0),Su)};let p;return["backward","forward"].includes(n)?p=S.jsx("div",{className:`${C(T.isTouchScreen)?"pl-flex pl-size-8 pl-items-center pl-justify-center pl-rounded-full pl-bg-black/50":"hover:pl-scale-125"} pl-cursor-pointer pl-transition-transform pl-ease-in-out ${n==="backward"&&(N().currentTime>=15?"pl-opacity-100":"pl-cursor-default pl-opacity-30 hover:pl-scale-100")} ${n==="forward"&&(d-N().currentTime>=15?"pl-opacity-100":"pl-cursor-default pl-opacity-30 hover:pl-scale-100")}}`,onContextMenu:E=>E.preventDefault(),children:S.jsx("img",{alt:n==="backward"?"backward-icon":"forward-icon",src:n==="backward"?re.backward15:re.forward15,onClick:()=>Rt(n,i),onDoubleClick:E=>E.stopPropagation(),className:"pl-size-6"})}):["touchBackward","touchForward"].includes(n)&&(p=S.jsx("div",{id:n,className:`pl-relative pl-flex pl-flex-col pl-items-center pl-justify-center pl-gap-2 pl-overflow-hidden ${n==="touchBackward"?"pl-rounded-r-full":"pl-rounded-l-full"}`,style:{width:f.width,height:f.width},...h,children:(e||t)&&S.jsxs("div",{className:"pl-flex pl-h-full pl-w-full pl-flex-col pl-items-center pl-justify-center pl-gap-2 pl-bg-secondary-100/[0.3] pl-p-5",onTouchStart:m,children:[S.jsxs("div",{className:`${n==="touchBackward"?"pl-arrow-left":"pl-arrow-right pl-gap-2"} pl-flex pl-items-center pl-justify-center`,children:[S.jsx("img",{alt:"arrow-left-icon",src:re.arrowLeft,className:`pl-size-6 ${n==="touchForward"&&"pl-rotate-180"}`}),S.jsx("img",{alt:"arrow-left-icon",src:re.arrowLeft,className:`pl-size-6 ${n==="touchForward"&&"pl-rotate-180"}`}),S.jsx("img",{alt:"arrow-left-icon",src:re.arrowLeft,className:`pl-size-6 ${n==="touchForward"&&"pl-rotate-180"}`})]}),S.jsxs("p",{className:"pl-text-center pl-text-[14px] pl-font-normal pl-text-white",children:[i," ثانیه"]})]})})),S.jsx(S.Fragment,{children:p})},Cm=Object.freeze(Object.defineProperty({__proto__:null,default:$i},Symbol.toStringTag,{value:"Module"})),wm=()=>(V(({controller:{play:n}})=>({play:n}),K),V(({videoData:{videoElementSizeInfo:n,params:e}})=>({videoElementSizeInfo:n,params:e}),K),S.jsx("div",{className:`${C(T.isTouchScreen)?"pl-flex pl-size-14 pl-items-center pl-justify-center pl-rounded-full pl-bg-black/50":"hover:pl-scale-125"} pl-cursor-pointer pl-transition-transform pl-ease-in-out`,onContextMenu:n=>n.preventDefault(),children:S.jsx("img",{alt:C(T.isPlay)?"pause":"play",src:C(T.isPlay)?re.bigPause:re.bigPlay,onClick:n=>Fr(n),onDoubleClick:n=>n.stopPropagation(),className:`pl-size-8 desktop:pl-size-10 ${C(T.isPlay)?"pl-big-play-icon":"pl-big-pause-icon"}`})})),Lm=()=>S.jsxs("div",{className:"loader-spinner pl-absolute pl-left-[50%] pl-top-[50%] pl-ml-[-42px] pl-mt-[-50px] pl-h-full pl-w-screen pl-overflow-hidden",children:[S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"})]}),vs=1e3,Am=3e3,Dm=6e4,Im=()=>{const[n,e]=P.useState(!1),[t,s]=P.useState(!1);V(({controller:{lock:a,firstPlay:o}})=>({lock:a,firstPlay:o}),K);const{activeElements:r,isLoading:i}=V(({controller:{activeElements:a,isLoading:o}})=>({activeElements:a,isLoading:o}),K);return P.useEffect(()=>{let a=null;return C(T.isFirstPlay)||C(T.isActiveElements)?a=setTimeout(()=>s(!0),100):s(!1),()=>clearTimeout(a)},[r]),P.useEffect(()=>{let a;return C(T.isLoading)?a=setTimeout(()=>e(!0),C(T.isFirstPlay)?0:Am):e(!1),()=>{clearTimeout(a),e(!1)}},[i]),S.jsx("main",{className:"pl-mt-1 pl-flex-1",children:n?S.jsx(Lm,{}):S.jsx(S.Fragment,{children:t&&!C(T.isLock)&&S.jsx("div",{id:"main-content",className:`pl-relative pl-flex pl-h-full pl-items-center pl-justify-center pl-text-center ${C(T.isActiveElements)?"pl-pointer-events-auto":"pl-pointer-events-none"}`,children:S.jsxs("div",{className:"pl-flex pl-w-max pl-items-center pl-justify-center pl-gap-8",style:{zIndex:_e.mainIcons},children:[!C(T.isFirstPlay)&&S.jsx($i,{type:"forward"}),S.jsx(wm,{}),!C(T.isFirstPlay)&&S.jsx($i,{type:"backward"})]})})})})},Vi=n=>{const{videoElementSizeInfo:e}=R.getState().videoData,{duration:t}=R.getState().controller,s=n.clientX!==void 0?n.clientX:n.touches[0].clientX;if(s<=e.right&&s>0)return(s-e.left)/e.width*t},Ut=n=>{const{videoElementSizeInfo:e}=R.getState().videoData,t=n.clientX!==void 0?n.clientX:n.touches[0].clientX;if(t<=e.right&&t>0)return t-e.left},Rm=n=>{const{duration:e}=R.getState().controller;return n*Ys()/e},zn=n=>{n&&(n.style.opacity="0.0",n.style.pointerEvents="none",n.style.zIndex=_e.vttDisable)},km=n=>{n.style.display="block",n.style.zIndex=_e.vtt,n.style.opacity=R.getState().videoData.details.vtt?"1.0":"0.6",n.style.pointerEvents="auto",n.style.transition="opacity 1s ease-out"},Pm=(n,e)=>{const{videoElementSizeInfo:t}=R.getState().videoData,s=document.getElementsByClassName("pl-progressTooltip")[0],r=document.getElementById("parent-player");s&&r&&(Ut(n)>s.getBoundingClientRect().width/2&&Ut(n)<t.right-t.left-s.getBoundingClientRect().width/2?e.style.left=`${Ut(n)-s.offsetWidth/2}px`:Ut(n)<(r.offsetLeft===0?s.offsetWidth:r.offsetLeft)?e.style.left="0px":N().offsetLeft+N().offsetWidth<Ut(n)+s.offsetWidth&&(e.style.left=`${N().offsetWidth-s.offsetWidth}px`))},_m=(n,e,t)=>{e&&km(e),R.getState().videoData.details.vtt?Pm(n,e):e.style.left=`${Ut(n)-30}px`,R.dispatch(d0(Number(Vi(n)))),t.textContent=`${zs(Vi(n))}`},qn=(n,e=!1)=>{const{videoElementSizeInfo:t}=R.getState().videoData,s=document.querySelector(".pl-progressTooltip"),r=document.querySelector(".pl-progressTimeTooltip"),i=n.clientX!==void 0?n.clientX:n.touches[0].clientX;s&&r&&i<=t.right&&i>t.left?(_m(n,s,r),e&&setTimeout(()=>zn(s),2e3)):zn(s)},Tu=n=>{const e=n.clientX!==void 0?n.clientX:n.touches[0].clientX;yt()&&(e<=n.view.innerWidth&&e>0?yt().style.width=`${Ut(n)}px`:e<=n.view.innerWidth?yt().style.width=0:e>0&&(yt().style.width="100%"))},Om=(n,e,t)=>{n.preventDefault(),n.stopPropagation(),t(!0);const s=R.dispatch,r=n.clientX!==void 0?n.clientX:n.touches[0].clientX;r<=n.view.innerWidth&&r>0&&(s(Oa(!0)),s(pr(!0)),sessionStorage.setItem("previousVideoTime",String(N().currentTime)),n.target.setPointerCapture(n.pointerId),e.length>0&&e.map(i=>clearTimeout(i)))},xu=n=>{n.preventDefault(),n.stopPropagation();const e=R.dispatch,{activePointerProgressBar:t}=R.getState().controller,{left:s}=R.getState().videoData.videoElementSizeInfo,r=n.clientX!==void 0?n.clientX:n.touches[0].clientX,i=document.querySelector(".pl-progressTooltip");r>s?(i&&(i.style.display="block !important",i.style.pointerEvents="auto"),t&&(e(pr(!0)),qn(n),Tu(n),N().pause())):i&&(i.style.display="none !important",i.style.pointerEvents="none")},Fm=(n,e,t,s)=>{s(!1),n.preventDefault(),n.stopPropagation();const r=R.dispatch,{duration:i}=R.getState().controller,{left:a,right:o}=R.getState().videoData.videoElementSizeInfo;n.target.removeEventListener("pointermove",xu);const l=n.clientX!==void 0?n.clientX:n.touches[0].clientX;let c=0;l>a&&l<o?c=Vi(n):l<a?c=0:l>0&&(c=i),C(T.isStaticFormat)||ps(N().currentTime,c),N().currentTime=c,R.getState().controller.activePointerProgressBar&&(r(Oa(!1)),r(pr(!1)),N().play(),qn(n,!0),sessionStorage.setItem("current-time",String(c)),Tu(n),Mm(n,r,e,t))},Mm=(n,e,t,s)=>{const r=s;let i=setTimeout(()=>{const{settingPopover:a}=R.getState().popovers,{delayTurnOffControlbar:o}=R.getState().controller;n.pointerType==="touch"&&!a&&o&&e(Se(!1))},vs);r.push(i),t(r)},Nm=()=>{const n=Date.now();N().play().then(()=>oe(ch(Date.now()-n)))},Bm=n=>qn(n),Um=()=>{const n=document.querySelector(".pl-progressTooltip");zn(n)},$m=n=>{const e=n.split("."),s=e[0].split(":");return{milliseconds:parseInt(e[1],10)||0,seconds:parseInt(s.pop(),10)||0,minutes:parseInt(s.pop(),10)||0,hours:parseInt(s.pop(),10)||0}},vu=n=>{const e=$m(n);return parseInt(e.hours*(60*60)+e.minutes*60+e.seconds+e.milliseconds/1e3,10)},Vm=n=>{const e=n.split(/#xywh=/i),t=e[0],r=e[1].match(/[0-9]+/gi);return{x:r[0],y:r[1],w:r[2],h:r[3],image:t}},Gm=(n,e)=>n.indexOf("//")>=0?n:e.indexOf("//")===0?[e.replace(/\/$/gi,""),n.trim()].join("/"):e.indexOf("//")>0?[e.trim(),n.trim()].join("/"):n,Hm=(n,e)=>{const t={};let s=e.split(/\/\w+\.vtt\s?/)[0];if(n=Gm(n,s),!n.match(/#xywh=/i))return t.background='url("'+n+e.split(/\/\w+\.vtt\s?/)[1]+'")',t;const r=Vm(n);return t.background='url("'+r.image+e.split(/\/\w+\.vtt\s?/)[1]+'") no-repeat -'+r.x+"px -"+r.y+"px",t.width=r.w+"px",t.height=r.h+"px",t.url=r.image,t},Km=(n,e)=>{fetch(n).then(t=>{if(!t.ok)throw R.dispatch(Na({...R.getState().videoData.details,vtt:void 0,vtt_mobile:void 0})),new Error("Network response was not ok");return t.text()}).then(t=>{const s=[];t.split(/[\r\n][\r\n]/i).forEach(i=>{if(i.match(/([0-9]{2}:)?([0-9]{2}:)?[0-9]{2}(.[0-9]{3})?( ?--> ?)([0-9]{2}:)?([0-9]{2}:)?[0-9]{2}(.[0-9]{3}).*/gi)){const a=i.split(/[\r\n]/i),l=a[0].split(/ ?--> ?/i),c=l[0],u=l[1],d=a[1],f=Hm(d,n);s.push({start:vu(c),end:vu(u),css:f})}}),e(s)}).catch(t=>{console.error("Error fetching file:",t)})},Wm=(n,e,t)=>{for(let s=0;s<e.length;++s){const r=e[s];if(n>=r.start&&n<r.end){if(r.css.url&&!t[r.css.url]){const i={background:r.css.background,width:r.css.width,height:r.css.height};return t[r.css.url]=i,i}else if(r.css.url)return t[r.css.url]}}},jm=()=>{const{details:n}=V(({videoData:{details:o}})=>({details:o}),K),{tooltipTime:e}=V(({controller:{tooltipTime:o,activeElements:l,isFullScreen:c}})=>({tooltipTime:o,activeElements:l,isFullScreen:c}),K),t={},[s,r]=P.useState(void 0),[i,a]=P.useState(C(T.isTouchScreen)?n.vtt_mobile:n.vtt);return P.useEffect(()=>{a(n.vtt_mobile)},[n.vtt_mobile]),P.useEffect(()=>{i&&Km(n.vtt_mobile,r)},[i]),C(T.isActiveElements)?S.jsxs("div",{className:`pl-progressTooltip pl-absolute pl-bottom-[calc(100%+10px)] pl-mr-[-25px] pl-flex pl-flex-col pl-px-[10px] pl-pt-[5px] pl-text-[14px] pl-text-white ${i&&s?"":"pl-bg-z-gray-700"} pl-rounded-[6px] pl-opacity-0`,children:[i&&!!s&&S.jsx("div",{className:"pl-mb-2 pl-flex-1 pl-rounded-[8px] pl-border pl-border-white",children:S.jsx("div",{className:"pl-rounded-[8px]",style:Wm(e,s,t)})}),S.jsx("div",{className:"pl-progressTimeTooltip pl-flex pl-items-center pl-justify-center pl-text-white !pl-opacity-100"})]}):S.jsx(S.Fragment,{})},zm=P.memo(jm),bs=(n,e)=>{P.useEffect(()=>{const t=s=>{!n.current||n.current.contains(s.target)||e(s)};return document.addEventListener("mousedown",t),document.addEventListener("touchstart",t),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("touchstart",t)}},[n,e])},Gi=({name:n,className:e,dataMarker:t})=>S.jsx("img",{"data-marker":t,src:`${ah()}/${n}.png`,alt:n,className:e}),qm=()=>{const{duration:n,activeElements:e}=V(({controller:{duration:p,activeElements:E,isFullScreen:x}})=>({duration:p,activeElements:E,isFullScreen:x}),K),{markers:t}=V(({videoData:{markers:p,videoElementSizeInfo:E}})=>({markers:p,videoElementSizeInfo:E}),K),[s,r]=P.useState(void 0),[i,a]=P.useState([]),[o,l]=P.useState({}),[c,u]=P.useState(!1),d=p=>n?Ys()*p/n:0,f=(p,E,x,v,w,b,I,A)=>{p.stopPropagation();const U=24*E/(Ys()+5);let O=[],B=0;A.map(Y=>{Y.time>E-U&&Y.time<E+U&&(O.push(Y),B+=Y.time)}),O.length>1?a(O):(O=[],a([]),g(p,E,x,v,w,b,I))},g=(p,E,x,v,w,b,I)=>{p.stopPropagation(),qn(p,I),ps(N().currentTime,E),N().currentTime=E,yt()&&(yt().style.width=d(E)),oe(Wo(x,E,v,w,b))};P.useEffect(()=>{C(T.isActiveElements)||a([])},[e]);const h=P.useRef(null);bs(h,()=>a([])),P.useEffect(()=>{if(i.length>0){const p=_0(document.getElementsByClassName("pl-overlapMarkers")[0]);if(p==="inViewport")return u(!0),l({left:d(i[0].time)});if(p==="OutViewPortFromLeft")return u(!1),l({left:0});if(p==="OutViewPortFromRight")return u(!1),l({right:0})}},[i,document.getElementsByClassName("pl-overlapMarkers")[0]]);const m=p=>{p.preventDefault(),C(T.isTouchScreen)&&r(Number(p.target.getAttribute("data-marker")))};return S.jsxs(S.Fragment,{children:[t.map(p=>S.jsx("div",{onContextMenu:m,"data-marker":p.time,onClick:E=>f(E,p.time,p.id,p.title,p.description,p.sticker,!0,t),onDoubleClick:E=>E.stopPropagation(),children:S.jsxs("div",{className:`pl-emoji-image pl-absolute pl-bottom-[200%] pl-rounded-[6px] pl-bg-z-gray-700/[0.4] pl-p-1 ${C(T.isTouchScreenPortrait),"pl-mb-5"} pl-ml-[-12px] pl-cursor-pointer`,style:{left:d(p.time),zIndex:_e.markers},"data-marker":p.time,children:[p.isPersonal!==null&&p.isPersonal!==void 0&&S.jsx("div",{className:"pl-bg-main pl-absolute pl-right-[-1px] pl-top-[-2px] pl-h-2 pl-w-2 pl-rounded-full"}),S.jsx(Gi,{dataMarker:p.time,name:p.sticker,className:"pl-h-[16px] pl-w-[16px] !pl-max-w-max"})]})},p.id)),i.length>0&&S.jsx("div",{className:`pl-overlapMarkers ${c?"pl-overlayMarkersInViewport":"pl-overlayMarkersOutViewport"} animate__animated animate__fadeInUp pl-absolute pl-bottom-[45px] pl-ml-[-10px] pl-flex pl-flex-row-reverse pl-justify-end pl-gap-3 pl-rounded-[6px] pl-bg-z-gray-700/[0.4] pl-px-1 pl-py-2 pl-opacity-100`,ref:h,style:o,children:i.map(p=>S.jsx("div",{className:"pl-emoji-image pl-cursor-pointer pl-rounded-[6px]","data-marker":p.time,onClick:E=>g(E,p.time,p.id,p.title,p.description,p.sticker,!0),onDoubleClick:E=>E.stopPropagation(),children:S.jsx(Gi,{dataMarker:p.time,name:p.sticker,className:"pl-h-[24px] pl-w-[24px] !pl-max-w-max"})},p.id))})]})},Ym=P.memo(qm),Xm=()=>{const[n,e]=P.useState(!1);P.useEffect(()=>{zn(document.querySelector(".progressTooltip"))},[]);const{duration:t,currentTime:s,bufferedTimeWidth:r}=V(({controller:{duration:o,currentTime:l,bufferedTimeWidth:c}})=>({duration:o,currentTime:l,bufferedTimeWidth:c}),K);V(({videoData:{params:o,videoElementSizeInfo:l}})=>({params:o,videoElementSizeInfo:l}),K);const[i,a]=P.useState([]);return S.jsxs("div",{className:"pl-relative",children:[S.jsxs("div",{className:"pl-relative",children:[S.jsx(zm,{}),S.jsx(Ym,{})]}),S.jsx("div",{className:"pl-flex pl-w-full pl-items-end",onPointerDown:o=>Om(o,i,e),onPointerMove:xu,onPointerUp:o=>Fm(o,a,i,e),onMouseMove:Bm,onMouseOut:Um,onClick:Nm,onDoubleClick:o=>o.stopPropagation(),children:S.jsxs("div",{id:"progress-area",className:"pl-absolute pl-w-full",children:[S.jsx("div",{className:"pl-h-10 pl-w-full"}),S.jsxs("div",{id:"time-progress-area",className:"pl-m-auto !pl-h-[5px] !pl-w-full pl-cursor-pointer pl-rounded !pl-bg-gray-highLight pl-transition-transform pl-duration-300",style:{transform:n?"scaleY(1.8)":"unset"},children:[S.jsx("div",{id:"time-progress-buffer",className:"pl-absolute pl-h-[5px] pl-rounded pl-bg-z-gray-400/[0.7]",style:{width:`${r}%`}}),S.jsx("div",{id:"time-progress-bar",className:`pl-relative pl-h-[5px] pl-cursor-pointer pl-rounded pl-bg-primary before:pl-inline-block before:pl-h-4 before:pl-w-4 before:pl-bg-primary ${n&&"before:pl-h-3 before:pl-w-7"}`,style:{width:`${s/t*Ys()}px`}})]})]})})]})},Tt=({title:n,className:e})=>S.jsx("span",{className:`pl-absolute pl-w-max pl-bg-paper pl-text-white/[0.9] ${C(T.isFullScreen)?"pl-bottom-[300%]":"pl-bottom-[270%]"} pl-rounded-[8px] pl-px-4 pl-py-[13px] pl-text-[10px] pl-font-normal ${e}`,children:n}),Zm=()=>{const{isFullScreen:n}=V(({controller:{firstPlay:r,isFullScreen:i}})=>({firstPlay:r,isFullScreen:i}),K),[e,t]=P.useState(!1),s=ve();return P.useEffect(()=>{C(T.isFirstPlay)||s(Se(!1))},[n]),S.jsxs("div",{className:"pl-relative pl-flex pl-items-center",children:[S.jsx("img",{src:C(T.isFullScreen)?re.nonFullScreen:re.fullScreen,alt:"fullScreen-icon",className:"pl-size-5 pl-cursor-pointer",onMouseOver:()=>!C(T.isTouchScreen)&&t(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&t(!1),onClick:()=>{Mr(),Nr()}}),e&&S.jsx(Tt,{title:`${C(T.isFullScreen)?xe("existFrom"):""} ${xe("fullscreen")}`})]})},Qm=()=>{const[n,e]=P.useState(!1);return S.jsxs("div",{className:"pl-relative pl-flex pl-items-center",children:[S.jsx("img",{alt:"pictureInPicture",onMouseOver:()=>!C(T.isTouchScreen)&&e(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&e(!1),src:re.pictureInPicture,className:"pl-flex pl-size-5 pl-cursor-pointer",onClick:()=>N().requestPictureInPicture()}),n&&S.jsx(Tt,{title:xe("pictureInPicture")})]})},Jm=()=>{const[n,e]=P.useState(!1),t=ve(),{settings:s}=V(({user:{settings:o}})=>({settings:o}),K),r=P.useRef(s.volume),i=()=>{if(r.current!==s.volume){const{settings:o}=R.getState().user;oe(ln(r.current,o.volume)),r.current=o.volume,t(ot({...o,volume:o.volume}))}},a=o=>{const{settings:l}=R.getState().user;o==="mute"?(un(0),oe(ln(l.volume,0))):(oe(ln(l.volume,100)),un(100))};return S.jsxs("div",{className:"pl-sound-icon pl-relative pl-inline-flex pl-items-center pl-gap-2",children:[!C(T.isTouchScreen)&&S.jsx("input",{onMouseUp:i,type:"range",min:"0",max:"100",value:s.volume,onChange:o=>un(+o.target.value),className:"pl-soundVolume rounded-full pl-cursor-pointer",style:{background:`linear-gradient(to right, white ${s.volume}%, rgba(255,255,255,0.3) 0)`}}),S.jsxs("div",{className:"pl-relative pl-flex pl-items-center",children:[S.jsx("img",{src:C(T.hasSound)?re.unMute:re.mute,alt:C(T.hasSound)?"unmute-icon":"mute-icon",className:"pl-flex pl-size-5 pl-cursor-pointer pl-items-center",onClick:()=>C(T.hasSound)?a("mute"):a("unmute"),onDoubleClick:o=>o.stopPropagation(),onMouseOver:()=>!C(T.isTouchScreen)&&e(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&e(!1)}),n&&S.jsx(Tt,{className:"pl-left-0",title:xe("volume")})]})]})},ey=({className:n,onClick:e})=>S.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,onClick:e,children:[S.jsx("path",{d:"M6 6L18.7742 18.7742",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),S.jsx("path",{d:"M6 18.7744L18.7742 6.00022",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Cs=P.forwardRef(({children:n,status:e,onClose:t,type:s,classNames:r,parentClassNames:i,styles:a,isBlurBackground:o,isFullHeight:l=!1,isHeader:c,isHasCatchUpLineOnTop:u=!1,animation:d,scrollbar:f=!1,isFocusOnInput:g=!1,headerTitle:h="",customHeader:m,headerClassName:p,showCloseIcon:E=!0},x)=>{const[v,w]=P.useState(e),[b,I]=P.useState(0),[A,F]=P.useState(0),{videoElementSizeInfo:U}=V(({videoData:{videoElementSizeInfo:j}})=>({videoElementSizeInfo:j}),K),O=P.useRef(0);P.useEffect(()=>{let j;return e?w(!0):j=setTimeout(()=>{t(!1),I(0),w(!1)},500),()=>clearTimeout(j)},[e]);const B=j=>{const Q=document.getElementById("popover-content");O.current||(O.current=window.innerHeight-U.top-(Q==null?void 0:Q.getBoundingClientRect().top)),j.stopPropagation(),window.innerHeight-U.top-j.touches[0].clientY<O.current&&I(window.innerHeight-j.touches[0].clientY),F(_e.maxPopover)},Y=()=>{t()},$=S.jsxs(S.Fragment,{children:[o&&S.jsx("div",{className:`animate__animated animate__faster pl-fixed pl-right-0 pl-top-0 pl-h-screen pl-w-screen pl-bg-black/[0.5] ${e?"animate__fadeIn":"animate__fadeOut"}`,style:{zIndex:_e.popoverBlurBackground}}),S.jsx("div",{className:`${s==="modal"&&"pl-fixed pl-left-0 pl-top-0 pl-flex pl-h-full pl-w-full pl-items-end pl-justify-center sm:pl-items-center"} ${i}`,style:{zIndex:l&&!g?A:_e.popoverContent},children:S.jsx("div",{className:`animate__animated animate__faster pl-flex pl-flex-col pl-rounded-lg pl-bg-new-net_1-9 pl-text-white ${l&&"pl-h-full"} ${d||(window.innerWidth>768&&s==="modal"?e?"animate__fadeIn":"animate__fadeOut":e?"animate__fadeInUp":"animate__fadeOutDown")} ${C(T.isTouchScreenPortrait)?"!pl-fixed !pl-bottom-0 !pl-left-0 !pl-right-0 !pl-mb-0 !pl-w-full pl-rounded-[12px] !pl-rounded-b-none !pl-bg-bg-primary":"before:pl-hidden"} ${s!=="modal"&&"no-scrollbar pl-absolute pl-bottom-[130%] pl-overflow-auto"} ${r} `,style:{height:b||"max-content",maxHeight:"80vh",zIndex:_e.popoverContent,...a},ref:x,id:"popover-content",children:S.jsxs(S.Fragment,{children:[c&&S.jsxs("div",{onTouchMove:u?B:()=>{},onTouchEndCapture:u?Y:()=>{},className:"pl-flex pl-flex-col pl-pt-4",children:[u&&S.jsx("div",{className:"pl-absolute pl-mb-4 pl-h-1 pl-w-8 pl-self-center pl-rounded-[20px] pl-bg-new-net_1-7"}),S.jsx("div",{className:`pl-mx-4 pl-mb-4 ${p}`,children:m||S.jsxs("div",{className:"pl-flex pl-items-center pl-justify-between pl-py-[19px]",children:[S.jsx("p",{className:"pl-text-[18px] pl-font-bold pl-text-black dark:pl-text-white",children:h}),E&&S.jsx(ey,{className:"pl-stroke-secondary-400 dark:pl-stroke-dark-5 pl-cursor-pointer",onClick:t})]})})]}),S.jsx("div",{className:`pl-h-full pl-w-full pl-overflow-y-auto ${!f&&"no-scrollbar"}`,onTouchMove:j=>j.stopPropagation(),children:n})]})})})]});return S.jsx(S.Fragment,{children:v&&S.jsx(S.Fragment,{children:s==="modal"?ku.createPortal(S.jsx(S.Fragment,{children:$}),document.getElementById("dialog-react-root-videoPlayer")):S.jsx("div",{children:$})})})});Cs.displayName="popover";const ty=({className:n,onClick:e,onMouseOver:t,onMouseLeave:s})=>S.jsxs("svg",{width:"18",height:"15",viewBox:"0 0 18 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,onClick:e,onMouseOver:t,onMouseLeave:s,children:[S.jsx("path",{d:"M10.5488 1.53559C8.20532 1.02852 5.66339 1.68608 3.84359 3.50588C1.15649 6.19298 1.00481 10.4572 3.39041 13.3215C3.55135 13.5148 3.8176 13.6347 4.13036 13.6347H13.8687C14.1816 13.6347 14.4476 13.5149 14.6085 13.3217C16.0815 11.5533 16.5884 9.25027 16.1258 7.11249C16.0528 6.77512 16.2671 6.44245 16.6045 6.36945C16.9418 6.29645 17.2745 6.51077 17.3475 6.84814C17.8886 9.34866 17.2968 12.0474 15.569 14.1217C15.1326 14.6455 14.489 14.8847 13.8687 14.8847H4.13036C3.50995 14.8847 2.86616 14.6453 2.42991 14.1215C-0.36559 10.765 -0.188583 5.77029 2.95971 2.622C5.09241 0.489299 8.07189 -0.279272 10.8132 0.31386C11.1505 0.386857 11.3648 0.719527 11.2918 1.0569C11.2188 1.39427 10.8862 1.60859 10.5488 1.53559Z"}),S.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M14.9976 2.66523C15.2417 2.9093 15.2417 3.30503 14.9976 3.54911L10.7129 7.83399C10.8469 8.09798 10.9225 8.39667 10.9225 8.713C10.9225 9.78688 10.0519 10.6574 8.97805 10.6574C7.90417 10.6574 7.03362 9.78688 7.03362 8.713C7.03362 7.63912 7.90417 6.76856 8.97805 6.76856C9.27953 6.76856 9.56498 6.83718 9.81965 6.95963C9.82222 6.95697 9.82483 6.95432 9.82746 6.95168L14.1137 2.66525C14.3578 2.42116 14.7535 2.42115 14.9976 2.66523ZM9.67249 8.713C9.67249 9.09652 9.36158 9.40743 8.97805 9.40743C8.59453 9.40743 8.28362 9.09652 8.28362 8.713C8.28362 8.32947 8.59453 8.01856 8.97805 8.01856C9.36158 8.01856 9.67249 8.32947 9.67249 8.713Z"})]}),sy=[.5,1,1.5,2],ny=({setSection:n,showSpeedIcon:e})=>{const t=ve();V(({videoData:{videoElementSizeInfo:c,params:u}})=>({videoElementSizeInfo:c,params:u}),K);const{speedPopover:s}=V(({popovers:{speedPopover:c}})=>({speedPopover:c}),K),{settings:r}=V(({user:{settings:c}})=>({settings:c}),K),i=P.useRef(null),[a,o]=P.useState(!1);bs(i,()=>t(Gs(!1))),P.useEffect(()=>{N()&&(N().playbackRate=r.speed)},[]);const l=S.jsxs("div",{id:me.speed,className:"animate__animated animate__fadeIn pl-flex pl-flex-col pl-gap-4 pl-py-4 pl-text-white",children:[S.jsxs("div",{className:"pl-flex pl-items-center pl-gap-3 pl-px-4",children:[S.jsx("img",{src:re.chevronRight,alt:"chevronRight",onClick:()=>{n&&n(me.main)},className:"pl-size-4 pl-cursor-pointer"}),S.jsx("p",{className:"pl-text-[15px] pl-font-medium",children:xe("speed")})]}),S.jsx("ul",{className:"pl-flex pl-flex-col pl-gap-2",children:sy.map((c,u)=>S.jsxs("li",{className:`pl-relative pl-flex pl-cursor-pointer pl-items-center pl-gap-4 pl-rounded-[4px] pl-px-4 pl-text-sm pl-font-medium desktop:pl-gap-3 ${r.speed===c&&"!pl-cursor-default pl-bg-primary"} ${C(T.isTouchScreen)?"pl-py-1.5":"pl-py-[9.5px]"}`,onClick:r.speed===c?()=>{}:()=>{C(T.isStaticFormat)||oe(oh(c)),t(Se(!1)),t(Lt(!1)),t(Gs(!1)),t(ot({...r,speed:c})),N().playbackRate=c,n&&n(me.main)},children:[S.jsx("img",{src:re.tick,alt:"tick",className:`pl-h-auto pl-w-[15px] pl-opacity-0 ${r.speed===c&&"pl-opacity-100"}`}),S.jsxs("p",{className:"pl-flex pl-w-full pl-items-center pl-gap-1",children:[c===1?xe("normalSpeed"):c,c!==1&&S.jsx("img",{src:re.close,alt:"x",className:"pl-size-[14px]"})]})]},u))})]});return S.jsx(S.Fragment,{children:e?S.jsxs("div",{className:"pl-relative pl-flex pl-items-center",ref:i,children:[S.jsx(ty,{className:"size-5 pl-size-5 pl-cursor-pointer pl-fill-white",onClick:()=>t(Gs(!s)),onMouseOver:()=>!C(T.isTouchScreen)&&!C(T.showSpeedPopover)&&o(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&o(!1)}),a&&S.jsx(Tt,{title:xe("speed")}),S.jsx(Cs,{classNames:`!pl-p-0 pl-overflow-hidden !pl-bg-white ${C(T.isTouchScreen)?"!pl-fixed !pl-bottom-0 !pl-rounded-t-[20px] pl-rounded-b-none":"!pl-w-[230px] pl-right-0 pl-mb-[33px] !pl-rounded-[12px]"} ${C(T.isTouchScreenPortrait)&&"!pl-w-screen tablet:!pl-max-w-[440px] tablet:!pl-mx-auto"} ${C(T.isTouchScreenLandscape)&&"pl-w-full pl-max-w-[440px]"}`,status:s,onClose:()=>t(Gs(!1)),type:C(T.isTouchScreen)?"modal":"popover",isBlurBackground:C(T.isTouchScreenPortrait),ref:C(T.isTouchScreenPortrait)?i:void 0,isHeader:C(T.isTouchScreen),customHeader:S.jsx(S.Fragment,{}),isHasCatchUpLineOnTop:C(T.isTouchScreen),children:l})]}):S.jsx(S.Fragment,{children:l})})},ry=({enabled:n,setEnabled:e})=>S.jsx("div",{className:`pl-relative pl-h-[22px] pl-w-[37px] pl-cursor-pointer pl-rounded-[15px] pl-transition-colors pl-duration-150 pl-ease-linear ${n?"pl-border pl-border-transparent pl-bg-primary":"pl-border pl-border-gray-highLight pl-bg-secondary-200"}`,onClick:e,children:S.jsx("div",{className:`pl-absolute pl-left-1 pl-top-[2px] pl-h-[16px] pl-w-[16px] pl-rounded-full pl-transition-transform pl-duration-150 pl-ease-linear ${n?"pl-translate-x-[13px] pl-bg-white":"-pl-translate-x-0.5 pl-bg-black/[0.16]"}`})}),iy=({setSection:n})=>{const e=ve(),{subtitles:t,selectedSubtitle:s}=V(({videoData:{subtitles:r,selectedSubtitle:i}})=>({subtitles:r,selectedSubtitle:i}),K);return S.jsx("div",{id:me.subtitles,className:"animate__animated animate__fadeIn pl-p-[14px]",children:S.jsxs("ul",{className:"pl-m-0 pl-flex pl-flex-col pl-p-0",children:[S.jsx("li",{className:`hover:pl-bg-main/[0.1] pl-relative pl-flex pl-cursor-pointer pl-items-center pl-rounded-[4px] pl-p-1 pl-pr-2 pl-text-[14px] pl-leading-6 hover:dark:pl-bg-white/[0.25] ${!s&&"pl-bg-main-light hover:!pl-bg-main-light pl-text-dark-5"}`,onClick:()=>{e(Se(!1)),e(Lt(!1)),e(os(void 0)),n(me.main);const r=Object.values(N().textTracks).find(i=>i.mode==="showing");r&&(r.mode="disabled"),e(as("")),oe(hs("empty"))},children:"بدون زیرنویس"}),t.map((r,i)=>S.jsx("li",{className:`hover:pl-bg-main/[0.1] pl-relative pl-flex pl-cursor-pointer pl-items-center pl-rounded-[4px] pl-p-1 pl-pr-2 pl-text-[14px] pl-leading-6 hover:dark:pl-bg-white/[0.25] ${s&&s.language===r.language&&"pl-bg-main-light hover:!pl-bg-main-light pl-text-dark-5"}`,onClick:()=>{e(Se(!1)),e(Lt(!1)),e(os(r)),N().textTracks[i].mode="showing",n(me.main),oe(hs(r.language))},children:S.jsx("span",{children:r.label})},i))]})})},ay=P.memo(iy),oy=({setSection:n,showQualityLevelsIcon:e})=>{const t=ve();let{qualityLevels:s}=V(({controller:{qualityLevels:d,manualQuality:f,autoQuality:g}})=>({qualityLevels:d,manualQuality:f,autoQuality:g}),K);const{settings:r}=V(({user:{settings:d}})=>({settings:d}),K),{qualityLevelsPopover:i}=V(({popovers:{qualityLevelsPopover:d}})=>({qualityLevelsPopover:d}),K);V(({videoData:{params:d,videoElementSizeInfo:f}})=>({params:d,videoElementSizeInfo:f}),K);const[a,o]=P.useState(!1);s=[-1,...s];const l=(d,f)=>C(T.isAutoQuality)&&f===-1?!0:!C(T.isAutoQuality)&&r.quality===d,c=P.useRef(null);bs(c,()=>t(Hs(!1)));const u=S.jsx("div",{id:me.qualityLevels,className:"animate__animated animate__fadeIn pl-py-2",children:S.jsx("ul",{className:"pl-flex pl-flex-col pl-gap-2",children:s.map((d,f)=>S.jsxs("li",{className:`pl-relative pl-flex pl-cursor-pointer pl-items-center pl-rounded-[4px] pl-ps-[24.2px] pl-text-[14px] pl-font-medium ${l(f-1,d)&&"!pl-cursor-default pl-bg-primary/[0.12]"} ${C(T.isTouchScreen)?"pl-py-[13.5px]":"pl-py-[9.5px]"}`,onClick:l(f-1,d)?()=>{}:()=>{oe(lh(d===-1?"auto":`${d}P`)),t(Se(!1)),t(Lt(!1)),t(Hs(!1)),t(ot({...r,quality:d===-1?-1:f-1})),n&&n(me.main)},children:[!C(T.isTouchScreen)&&l(f-1,d)&&S.jsx("div",{className:"pl-absolute pl-right-[11.8px]",children:S.jsx("img",{src:re.tick,alt:"",width:12,height:9})}),C(T.isTouchScreen)&&S.jsx("div",{className:`pl-h-5 pl-w-5 pl-rounded-full pl-border pl-border-black/[0.5] pl-p-0.5 ${l(f-1,d)&&"pl-border-primary"}`,children:l(f-1,d)&&S.jsx("div",{className:"pl-h-full pl-w-full pl-rounded-full pl-bg-primary"})}),S.jsx("span",{className:`pl-w-full pl-text-[14px] pl-text-black/[0.87] ${C(T.isTouchScreen)?"pl-pr-[21px]":"pl-pr-[10px]"}`,children:d===-1?S.jsxs("span",{children:[S.jsx("span",{children:"خودکار "}),S.jsx("span",{className:"pl-text-[10px] pl-font-normal pl-text-black/[0.5]",children:"(بر اساس سرعت اینترنت شما)"})]}):`${d}p`})]},f))})});return S.jsx(S.Fragment,{children:e?S.jsxs("div",{className:"pl-relative pl-flex pl-items-center",ref:c,children:[S.jsx("img",{src:re.qualitySetting1,alt:"speed-icon",onClick:()=>t(Hs(!i)),onMouseOver:()=>!C(T.isTouchScreen)&&!C(T.showQualityLevelsPopover)&&o(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&o(!1),className:"pl-size-5 pl-cursor-pointer"}),a&&S.jsx(Tt,{title:xe("quality")}),S.jsx(Cs,{classNames:`!pl-p-0 pl-overflow-hidden !pl-bg-white ${C(T.isTouchScreen)?"!pl-fixed !pl-bottom-0 !pl-rounded-t-[20px] pl-rounded-b-none":"pl-right-0 pl-mb-[33px] !pl-rounded-[12px] pl-w-[230px]"} ${C(T.isTouchScreenPortrait)&&"!pl-w-screen tablet:pl-max-w-[440px]"} ${C(T.isTouchScreenLandscape)&&"pl-w-full pl-max-w-[440px]"}`,status:i,onClose:()=>t(Hs(!1)),type:C(T.isTouchScreen)?"modal":"popover",isBlurBackground:C(T.isTouchScreenPortrait),ref:C(T.isTouchScreenPortrait)?c:void 0,isHeader:C(T.isTouchScreen),customHeader:S.jsx(S.Fragment,{}),isHasCatchUpLineOnTop:C(T.isTouchScreen),children:u})]}):S.jsx(S.Fragment,{children:u})})},bu=P.memo(oy),ly=()=>{const n=ve(),{selectedSubtitle:e}=V(({videoData:{params:l,subtitles:c,selectedSubtitle:u}})=>({params:l,subtitles:c,selectedSubtitle:u}),K),{settingPopover:t}=V(({popovers:{settingPopover:l}})=>({settingPopover:l}),K);V(({user:{settings:l}})=>({settings:l}),K);const[s,r]=P.useState(me.main),[i,a]=P.useState(!1),o=P.useRef(null);return bs(o,()=>{n(Lt(!1)),setTimeout(()=>r(me.main),500)}),S.jsxs("div",{className:`pl-inline-flex ${C(T.isLandscape)&&"pl-relative"}`,ref:o,children:[S.jsxs("div",{className:"pl-relative pl-flex pl-cursor-pointer pl-items-center",onClick:()=>n(Lt(!t)),onMouseOver:()=>!C(T.isTouchScreen)&&!C(T.showSettingPopover)&&a(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&a(!1),children:[S.jsx("img",{src:re.settings,alt:"settings",className:"pl-size-5"}),i&&S.jsx(Tt,{title:xe("setting")})]}),S.jsx(Cs,{classNames:`!pl-p-0 pl-overflow-hidden ${C(T.isTouchScreen)?"!pl-fixed !pl-bottom-0 !pl-rounded-t-[28px] pl-rounded-b-none":"!pl-w-[230px] pl-right-0 pl-mb-[33px]"} ${C(T.isTouchScreenPortrait)&&"!pl-w-screen tablet:!pl-max-w-[285px] tablet:!pl-mx-auto"} ${C(T.isTouchScreenLandscape)&&"pl-w-full pl-max-w-[285px]"}`,status:t,onClose:()=>{n(Lt(!1)),setTimeout(()=>r(me.main),500)},type:C(T.isTouchScreen)?"modal":"popover",isBlurBackground:C(T.isTouchScreenPortrait),ref:C(T.isTouchScreenPortrait)?o:void 0,isHeader:C(T.isTouchScreen),customHeader:S.jsx(S.Fragment,{}),isHasCatchUpLineOnTop:C(T.isTouchScreen),children:S.jsxs(S.Fragment,{children:[s===me.main&&S.jsxs("div",{id:me.main,className:"animate__animated animate__fadeIn pl-flex pl-flex-col pl-gap-5 pl-rounded-[10px] pl-p-4",children:[!C(T.isStaticFormat)&&S.jsx(S.Fragment,{children:S.jsxs("div",{className:"pl-flex pl-cursor-pointer pl-items-center pl-gap-[10px]",onClick:()=>r(me.qualityLevels),children:[S.jsx("img",{src:re.qualitySetting,alt:"qualitySetting",width:16,height:16}),S.jsx("p",{className:"pl-ml-auto pl-text-[12px] pl-font-medium pl-text-black/[0.87]",children:xe("quality")}),S.jsx("img",{src:re.chevronRight,alt:"chevronRight",className:"pl-size-4"})]})}),C(T.hasNoSpeed)&&S.jsxs("div",{className:"pl-flex pl-cursor-pointer pl-items-center pl-justify-between pl-gap-[10px] pl-text-white",onClick:()=>r(me.speed),children:[S.jsx("p",{className:"pl-text-sm pl-font-medium",children:xe("speed")}),S.jsx("img",{src:re.chevronRight,alt:"chevronRight",onClick:()=>{r&&r(me.main)},className:"pl-size-4 pl-rotate-180 pl-cursor-pointer"})]}),C(T.hasSubtitles)&&C(T.isTouchScreenPortrait)&&S.jsxs("div",{className:"pl-flex pl-cursor-pointer pl-items-center pl-gap-[10px]",children:[S.jsx("img",{src:re.subtitleOutlineGray,alt:"subtitle-icon",className:"pl-size-5"}),S.jsx("p",{className:"pl-ml-auto pl-text-[12px] pl-font-medium pl-text-black/[0.87]",children:xe("subtitle")}),S.jsx(ry,{enabled:!!e,setEnabled:dn})]})]}),s===me.qualityLevels&&S.jsx(bu,{setSection:r}),s===me.speed&&S.jsx(ny,{setSection:r}),s===me.subtitles&&S.jsx(ay,{setSection:r})]})})]})},cy=P.memo(ly),Cu=()=>{const{duration:n,currentTime:e}=V(({controller:{duration:t,currentTime:s}})=>({duration:t,currentTime:s}),K);return V(({videoData:{videoElementSizeInfo:t,params:s}})=>({videoElementSizeInfo:t,params:s}),K),S.jsx(S.Fragment,{children:S.jsxs("div",{className:`pl-mr-auto pl-w-full pl-max-w-max pl-text-[12px] pl-font-bold !pl-text-white ${C(T.isFullScreen)?"pl-ml-8":"pl-ml-4"} ${C(T.isTouchScreenPortrait)?"!pl-ml-0":"pl-absolute pl-bottom-full pl-left-0 pl-mb-[33px]"}`,children:[S.jsx("span",{children:zs(n)}),S.jsx("span",{children:" / "}),S.jsx("span",{children:zs(e)})]})})},uy=()=>S.jsx("img",{src:re.unlock,alt:"unlock-icon",onClick:()=>jo("lock"),className:"pl-size-5"}),dy=()=>{const[n,e]=P.useState(!1);return V(({videoData:{selectedSubtitle:t,videoElementSizeInfo:s,params:r}})=>({selectedSubtitle:t,videoElementSizeInfo:s,params:r}),K),S.jsxs("div",{className:"pl-relative pl-flex pl-items-center",children:[S.jsx("img",{alt:"subtitle-icon",src:C(T.isSelectedSubtitle)?re.subtitleFill:re.subtitleOutline,className:"pl-size-5 pl-cursor-pointer",onClick:dn,onDoubleClick:t=>t.stopPropagation(),onMouseOver:()=>!C(T.isTouchScreen)&&e(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&e(!1)}),n&&S.jsx(Tt,{title:xe("subtitle")})]})},fy=n=>(V(({videoData:{videoElementSizeInfo:e,params:t}})=>({videoElementSizeInfo:e,params:t}),K),S.jsxs("svg",{width:20,height:20,viewBox:"0 0 22 22",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:[S.jsx("rect",{x:"3",y:"3",width:"4",height:"4",rx:"1.5"}),S.jsx("rect",{x:"3",y:"9",width:"4",height:"4",rx:"1.5"}),S.jsx("rect",{x:"3",y:"15",width:"4",height:"4",rx:"1.5"}),S.jsx("rect",{x:"8",y:"16",width:"11",height:"2",rx:"1"}),S.jsx("rect",{x:"8",y:"10",width:"11",height:"2",rx:"1"}),S.jsx("rect",{x:"8",y:"4",width:"11",height:"2",rx:"1"})]})),hy=()=>{const[n,e]=P.useState(!1),{markers:t}=V(({videoData:{markers:l,params:c,videoElementSizeInfo:u}})=>({markers:l,params:c,videoElementSizeInfo:u}),K),{markersListPopover:s}=V(({popovers:{markersListPopover:l}})=>({markersListPopover:l}),K),r=P.useRef(null),i=ve();bs(r,()=>i(Ks(!1)));const a=(l,c,u,d,f)=>{yt()&&(yt().style.width=`${Rm(l)}px`),ps(N().currentTime,l),N().currentTime=l,i(Ks(!1)),oe(Wo(c,l,u,d,f))},o=()=>{i(Ks(!s))};return S.jsxs("div",{className:`pl-relative pl-flex pl-items-center pl-p-1 ${C(T.showMarkerListPopover)&&"pl-bg-secondary-50/[0.4] pl-rounded-[4px]"}`,ref:r,children:[S.jsx(fy,{className:"pl-fill-dark-5 pl-cursor-pointer",onClick:o,onMouseOver:()=>!C(T.isTouchScreen)&&e(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&e(!1)}),n&&S.jsx(Tt,{title:"لیست نشانگرها (e)",className:"!pl-bottom-[180%] !pl-right-[-48px]"}),S.jsx(Cs,{classNames:"!pl-p-0 pl-left-0 !pl-bg-white dark:!pl-bg-dark-13 !pl-rounded-[4px] pl-mb-[33px]",status:C(T.showMarkerListPopover),onClose:()=>{i(Ks(!1))},headerTitle:"نشانگرها",isHeader:!0,type:"popover",children:S.jsx("div",{className:"pl-mx-2 pl-mt-2 pl-flex pl-flex-col pl-gap-6",children:S.jsx("div",{className:"pl-flex pl-flex-col pl-gap-2 pl-pb-2",children:t.map(l=>S.jsx("div",{onClick:()=>a(l.time,l.id,l.title,l.description,l.sticker),className:"odd:pl-bg-main/[0.1] hover:pl-bg-main/[0.1] hover:dark:bg-white/[0.25] pl-rounded-[8px] odd:dark:pl-bg-dark-1",children:S.jsxs("div",{className:"pl-item-center pl-relative pl-mx-2 pl-flex pl-cursor-pointer pl-gap-2 pl-rounded-[4px] pl-p-2",children:[l.banner||!l.sticker?S.jsx("img",{src:l.banner?l.banner:"IMAGES.defaultMarkersListItemIcon",width:40,height:40,alt:l.title}):S.jsx("div",{className:"pl-bg-secondary dark:pl-bg-secondary-50 pl-flex pl-h-[40px] pl-w-[40px] pl-items-center pl-rounded-[6px]",children:S.jsx(Gi,{name:l.sticker,className:"pl-mx-auto pl-h-[20px] pl-w-[20px]"})}),S.jsxs("div",{className:"pl-text-gray-800 dark:pl-text-white",children:[S.jsx("p",{className:"pl-mb-1 pl-flex pl-w-[130px] pl-items-center pl-overflow-hidden pl-text-ellipsis pl-whitespace-nowrap pl-text-[14px] pl-font-bold",children:S.jsx("div",{children:l.title})}),S.jsx("p",{className:"pl-w-[200px] pl-overflow-hidden pl-text-ellipsis pl-whitespace-nowrap pl-text-[13px] pl-font-normal",children:l.description})]}),S.jsx("span",{className:"pl-bg-secondary/[0.3] dark:pl-bg-secondary/[0.6] pl-absolute pl-left-9 pl-top-2 pl-rounded-[4px] pl-p-[3px] pl-text-[12px] pl-font-bold pl-text-gray-800 dark:pl-text-white",children:zs(l.time)})]})},l.id))})})})]})},py=()=>{V(({controller:{isFullScreen:e}})=>({isFullScreen:e}),K),V(({videoData:{videoElementSizeInfo:e,params:t}})=>({videoElementSizeInfo:e,params:t}),K);let n="";return C(T.isTouchScreen)?C(T.isFullScreen)&&(n="pl-mx-6"):C(T.isFullScreen)?n="pl-mx-8":n="pl-mx-4",S.jsxs("div",{id:"player-controllbar",className:`pl-flex pl-items-center pl-justify-between ${n}`,children:[S.jsxs("div",{className:"pl-flex pl-items-center pl-gap-4",children:[S.jsx(Zm,{}),C(T.isTouchScreenLandscape)&&S.jsx(uy,{}),C(T.showPictureInPicture)&&S.jsx(Qm,{}),C(T.showSettingIcon)&&S.jsx(cy,{}),C(T.isFullScreen)&&!C(T.isStaticFormat)&&S.jsx(bu,{showQualityLevelsIcon:!0}),C(T.hasSubtitles)&&!C(T.isTouchScreenPortrait)&&S.jsx(dy,{})]}),S.jsxs("div",{className:"pl-flex pl-items-center pl-gap-4",children:[C(T.isTouchScreenPortrait)&&S.jsx(Cu,{}),!C(T.isIOS)&&S.jsx(Jm,{}),C(T.hasMarkers)&&S.jsx(hy,{})]})]})},gy=P.memo(py),my=()=>{const{subtitleText:n}=V(({videoData:{subtitleText:t,selectedSubtitle:s}})=>({subtitleText:t,selectedSubtitle:s}),K);V(({controller:{isFullScreen:t}})=>({isFullScreen:t}),K);const e=()=>{let t="";return C(T.isLock)?t="pl-bottom-3":C(T.isActiveElements)?C(T.isTouchScreenPortrait)?t="pl-bottom-[45px]":C(T.isFullScreen)?t="pl-bottom-[120px]":t="pl-bottom-[85px]":C(T.isActiveElements)||(t="pl-bottom-3"),t};return S.jsx("div",{id:"subtitle-id",style:{direction:"ltr"},className:`pl-absolute pl-w-full pl-px-6 pl-text-center pl-text-[14px] ${C(T.isFullScreen)&&"pl-text-[16px]"} pl-font-normal pl-text-white ${e()}`,children:P0(n).map((t,s)=>S.jsx("p",{className:"pl-mx-auto",style:{textShadow:"0 0 4px #000000"},children:O0(t)},s))})},yy=()=>{V(({controller:{lock:e,isFullScreen:t,isLoading:s,activeElements:r}})=>({lock:e,isFullScreen:t,isLoading:s,activeElements:r}),K),V(({videoData:{subtitles:e,selectedSubtitle:t}})=>({subtitles:e,selectedSubtitle:t}),K);let n="";return C(T.isTouchScreen)?C(T.isFullScreen)?n="pl-gap-6 pl-mb-6":n="pl-gap-3 pl-mb-0":C(T.isFullScreen)?n="pl-gap-6 pl-mb-8":n="pl-gap-4 pl-mb-3",S.jsx("div",{id:"footer",className:"pl-relative",style:{zIndex:_e.footer},children:S.jsxs(S.Fragment,{children:[C(T.showSubtitle)&&S.jsx(my,{}),!C(T.isLock)&&S.jsx(S.Fragment,{children:S.jsxs("div",{className:`animate__animated animate__faster pl-mx-auto pl-flex pl-w-full pl-flex-col pl-px-4 pl-py-3 desktop:pl-px-0 desktop:pl-py-0 ${n} ${C(T.isActiveElements)&&!C(T.isLoading)?"animate__fadeIn pl-pointer-events-auto":"animate__fadeOut pl-pointer-events-none"}`,children:[!C(T.isTouchScreenPortrait)&&S.jsx(Cu,{}),C(T.showProgressbar)&&S.jsx(Xm,{}),S.jsx(gy,{})]})})]})})},Ey=P.lazy(()=>Promise.resolve().then(()=>Oy)),Sy=P.lazy(()=>Promise.resolve().then(()=>By)),Ty=()=>S.jsx(P.Suspense,{fallback:"",children:C(T.isStaticFormat)?S.jsx(Ey,{}):S.jsx(Sy,{})}),xy=()=>{const n=ve();V(({videoData:{params:e}})=>({params:e}),K),P.useEffect(()=>{const e=()=>{document.fullscreenElement?n(is(!0)):(n(is(!1)),zo(),oe(Or("exitFullScreen")))};document.addEventListener&&(document.addEventListener("webkitfullscreenchange",e,!1),document.addEventListener("mozfullscreenchange",e,!1),document.addEventListener("fullscreenchange",e,!1),document.addEventListener("MSFullscreenChange",e,!1))},[])},vy=(n,e)=>{const t=ve(),{activeElements:s}=V(({controller:{activeElements:o}})=>({activeElements:o}),K),r=P.useRef(null),i=P.useRef(n),a=P.useRef(e);P.useEffect(()=>{i.current=n},[n]),P.useEffect(()=>{a.current=e},[e]),P.useEffect(()=>{let o=!1;const l=d=>{const{activeElements:f,isEnded:g}=R.getState().controller;g?t(Se(!0)):d.pointerType==="mouse"&&(clearTimeout(r.current),f?["player-tag","main-content","player-controllbar","video-opacity","playerElements","touchBackward","touchForward"].includes(d.target.id)&&(o=!0):t(Se(!0)),r.current=setTimeout(()=>{const{settingPopover:h,speedPopover:m,qualityLevelsPopover:p}=R.getState().popovers,{play:E}=R.getState().controller;!h&&!m&&!p&&E&&o&&t(Se(!1))},vs))},c=d=>{setTimeout(()=>{const{activeElements:f,isEnded:g,firstPlay:h}=R.getState().controller;if(clearTimeout(r.current),g)return t(Se(!0));Ht()&&!h&&!i.current&&!a.current&&(["player-tag","main-content","video-opacity","touchBackward","touchForward"].includes(d.target.id)||yr(d,"playerElements")?(t(Se(!f)),r.current=setTimeout(()=>{const{settingPopover:m,speedPopover:p,qualityLevelsPopover:E}=R.getState().popovers;!m&&!p&&!E&&t(Se(!1))},vs)):r.current=setTimeout(()=>{const{settingPopover:m,speedPopover:p,qualityLevelsPopover:E}=R.getState().popovers;!m&&!p&&!E&&t(Se(!1))},vs))},200)},u=()=>{clearTimeout(r.current),r.current=setTimeout(()=>{const{activeElements:d,isEnded:f}=R.getState().controller,{settingPopover:g,speedPopover:h,qualityLevelsPopover:m}=R.getState().popovers;f?t(Se(!0)):!g&&!h&&!m&&d&&!f&&t(Se(!d))},vs)};return document.getElementById("video-area").addEventListener("touchstart",c),document.getElementById("video-area").addEventListener("touchmove",u),document.getElementById("video-area").addEventListener("pointermove",l),()=>{const d=document.getElementById("video-area");d&&(d.removeEventListener("touchstart",c),d.removeEventListener("touchmove",u),d.removeEventListener("pointermove",l))}},[s,n,e])},by=()=>{const{firstPlay:n,isFullScreen:e}=V(({controller:{firstPlay:t,isFullScreen:s}})=>({firstPlay:t,isFullScreen:s}),K);P.useEffect(()=>{if(N()){let t;const s=()=>{t=setTimeout(()=>{zo()},Ht()?0:300)};return s(),window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s),clearTimeout(t)}}},[n,e,N()])},Cy=()=>{const{firstPlay:n}=V(({controller:{firstPlay:e}})=>({firstPlay:e}),K);V(({videoData:{details:e}})=>({details:e}),K),P.useEffect(()=>{C(T.setSubtitleFirstPlay)&&dn()},[n])},wy=P.lazy(()=>Promise.resolve().then(()=>Vy)),wu=P.lazy(()=>Promise.resolve().then(()=>Cm)),Lu=()=>{const[n,e]=P.useState(!1),[t,s]=P.useState(!1);return V(({videoData:{details:r,params:i,videoElementSizeInfo:a}})=>({details:r,params:i,videoElementSizeInfo:a}),K),V(({controller:{firstPlay:r,isFullScreen:i,isLoading:a,canPlayVideo:o}})=>({firstPlay:r,isFullScreen:i,isLoading:a,canPlayVideo:o}),K),xy(),by(),vy(n,t),Cy(),S.jsx(S.Fragment,{children:S.jsxs("div",{id:"video-area",style:{zIndex:C(T.isFullScreen)?_e.videoPlayerInFullScreen:"unset"},onClick:r=>C(T.isFirstPlay)&&Fr(r),onDoubleClick:r=>Sh(r),className:`pl-flex pl-h-full pl-max-h-screen pl-items-center pl-bg-black !pl-bg-contain !pl-bg-center !pl-bg-no-repeat desktop:pl-aspect-video ${!C(T.isTouchScreen)&&!C(T.isFullScreen)&&"!pl-rounded-[12px]"} ${C(T.isFullScreen)&&"dvh !pl-fixed !pl-w-screen"} pl-relative pl-w-full ${!C(T.isActiveElements)&&"pl-cursor-none"}`,children:[S.jsx("div",{id:"video-opacity",className:`pl-absolute pl-h-full pl-w-full pl-bg-black pl-transition-all pl-duration-500 desktop:pl-aspect-video ${!C(T.isTouchScreen)&&!C(T.isFullScreen)&&"!pl-rounded-[12px]"} ${C(T.isActiveElements)?"pl-bg-opacity-50":"pl-bg-opacity-0"}`}),S.jsx(P.Suspense,{fallback:"",children:C(T.showTouchVolumeBrightness)&&S.jsx(wy,{})}),C(T.showBackwardForward)&&S.jsx(P.Suspense,{fallback:"",children:S.jsxs("div",{className:"pl-absolute pl-right-0 pl-top-0 pl-flex pl-h-full pl-w-full pl-items-center pl-overflow-hidden",style:{zIndex:t||n?_e.backwardForwardActive:_e.backwardForwardInActive},children:[S.jsx(wu,{type:"touchForward",isRightDoubleTouched:n,setIsRightDoubleTouched:e}),S.jsx(wu,{type:"touchBackward",isLeftDoubleTouched:t,setIsLeftDoubleTouched:s})]})}),S.jsx(Ty,{}),S.jsx("div",{id:"playerElements",className:"pl-absolute pl-right-0 pl-top-0 pl-h-full pl-w-full",children:S.jsxs("div",{className:"pl-flex pl-h-full pl-w-full pl-flex-col pl-justify-between",children:[C(T.showHeader)&&S.jsx(vm,{}),C(T.showMain)&&S.jsx(Im,{}),C(T.showFooter)&&S.jsx(yy,{})]})})]})})},Ly=Object.freeze(Object.defineProperty({__proto__:null,default:Lu},Symbol.toStringTag,{value:"Module"})),Ay=Object.freeze(Object.defineProperty({__proto__:null,default:()=>S.jsx("div",{className:`pl-h-full pl-w-full desktop:pl-aspect-video ${!C(T.isTouchScreen)&&!C(T.isFullScreen)&&"!pl-rounded-[12px]"}`,children:S.jsx(Lu,{})})},Symbol.toStringTag,{value:"Module"})),Dy=()=>{const{params:n}=V(({videoData:{params:e}})=>({params:e}),K);V(({controller:{isEnded:e}})=>({isEnded:e}),K),P.useEffect(()=>{C(T.getDetails)&&qo()},[n.id,n.type])},Iy=()=>{Dy()},Au=()=>{const{params:n}=R.getState().videoData,e=N().currentTime;if(e!==0){const t=N().duration,s={video_id:+n.id,video_type:2,time:e===t?0:Math.floor(N().currentTime)};let r=localStorage.getItem("viewedVideos");if(r){let i=JSON.parse(r);i=i.filter(a=>a.video_id!==s.video_id||a.video_type!==s.video_type),i.length<10||i.shift(),i.push(s),localStorage.setItem("viewedVideos",JSON.stringify(i))}else localStorage.setItem("viewedVideos",JSON.stringify([s]))}},Ry=()=>{const n=R.dispatch,{params:e}=R.getState().videoData;let t=localStorage.getItem("viewedVideos");if(t){const r=JSON.parse(t).find(i=>i.video_id===Number(e.id)&&i.video_type===2);r&&n(S0({time:r.time}))}},ky=P.lazy(()=>Promise.resolve().then(()=>Ly)),Py=P.lazy(()=>Promise.resolve().then(()=>Gy)),_y=Object.freeze(Object.defineProperty({__proto__:null,default:()=>(V(({videoData:{params:n,details:e,isFetchDetails:t,isValidAddress:s}})=>({params:n,details:e,isFetchDetails:t,isValidAddress:s}),K),Iy(),Ry(),S.jsx(S.Fragment,{children:C(T.isFetchDetails)?C(T.isValidAddress)?S.jsx(P.Suspense,{fallback:"",children:S.jsx("div",{className:`pl-max-h-[100dvh] pl-bg-dark-1 ${!C(T.isTouchScreen)&&!C(T.isFullScreen)&&"!pl-rounded-[12px]"}`,children:S.jsx(ky,{})})}):S.jsx(P.Suspense,{fallback:"",children:S.jsx("div",{className:"pl-aspect-video pl-w-full",children:S.jsx(Py,{})})}):S.jsx("div",{className:"pl-flex pl-aspect-video pl-w-full pl-items-center pl-justify-center"})}))},Symbol.toStringTag,{value:"Module"})),Du=()=>{const n=ve(),{params:e}=V(({videoData:{params:t}})=>({params:t}),K);P.useEffect(()=>{C(T.hasCurrentTimeParams)&&(N().currentTime=e.currentTime,n(Vt(e.currentTime)))},[e.currentTime])},Iu=()=>{const{details:n}=V(({videoData:{details:e}})=>({details:e}),K);P.useEffect(()=>{const e=N().getElementsByTagName("track");for(let t=0;t<e.length;t++)e[t].addEventListener("cuechange",s=>{const r=s.target.track;let i;r.activeCues&&(i=r.activeCues[0]),i&&(setTimeout(()=>{const a=document.getElementById("subtitle-id");a&&(a.style.display="block")},300),i.onexit=()=>{const a=document.getElementById("subtitle-id");a&&(a.style.display="none")})})},[n.subtitles])},Oy=Object.freeze(Object.defineProperty({__proto__:null,default:()=>{const n=ve(),{params:e}=V(({videoData:{params:a}})=>({params:a}),K);V(({controller:{firstPlay:a}})=>({firstPlay:a}),K);const t=P.useRef(0),s=P.useRef(0),r=P.useRef(null),i=P.useRef(null);return P.useEffect(()=>{Xa(t),s.current=Date.now()},[]),P.useEffect(()=>{const a=()=>{var l;const o=(l=N())==null?void 0:l.getBoundingClientRect();o&&n(Ba(o))};return C(T.isFirstPlay)&&a(),window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a),clearInterval(i.current)}},[e.id]),Iu(),Du(),S.jsxs("video",{poster:e.banner?e.banner:void 0,preload:"metadata",autoPlay:C(T.hasAutoPlay),id:"player-tag",crossOrigin:"anonymous",className:"pl-h-full pl-w-full pl-flex-1 pl-items-center",onCanPlay:hm,onPause:cm,onPlay:a=>um(a,r),onPlaying:()=>dm(t,s,r),onTimeUpdate:fm,onLoadedData:a=>pm(a,i),onError:jn,playsInline:!0,"aria-label":e.bannerAlt?e.bannerAlt:xe("bannerAlt"),children:[S.jsx("source",{src:e.id}),C(T.hasSubtitlesInParams)&&Ja(e.subtitles).map(a=>S.jsx("track",{id:`player-tracker-${a.lang}`,src:a.url,label:eo(a.lang),kind:"subtitles",srcLang:a.lang},a.id))]})}},Symbol.toStringTag,{value:"Module"})),Fy=()=>{let n=null;const{isEnded:e}=V(({controller:{isEnded:t}})=>({isEnded:t}),K);P.useEffect(()=>(n=setInterval(()=>Au(),Dm),()=>clearInterval(n)),[]),P.useEffect(()=>{C(T.isEnded)&&clearInterval(n)},[e])},My=n=>{const[e,t]=P.useState([]),[s,r]=P.useState(0),{qualityLevels:i}=V(({controller:{qualityLevels:a}})=>({qualityLevels:a}),K);P.useEffect(()=>{if(n){let a=[];switch(e.length){case 0:a=[n];break;case 1:a=[n,...e];break;case 2:a=[n,...e],oe(Go(`${a[0]}P`,`${a[1]}P`,i.indexOf(a[0])-i.indexOf(a[1])));break;default:a=[n,e[0],e[1]],a[1]!==a[2]&&oe(Go(`${a[1]}P`,`${a[2]}P`,i.indexOf(a[1])-i.indexOf(a[2])));break}t(a)}},[n]),P.useEffect(()=>{e.length===3&&e[0]===e[2]?(oe(gh(s,e)),t([]),r(0)):r(new Date().getTime())},[e])},Ny=()=>{P.useEffect(()=>{const n=()=>{Au()};return window.addEventListener("beforeunload",n),()=>window.removeEventListener("beforeunload",n)},[])},By=Object.freeze(Object.defineProperty({__proto__:null,default:()=>{const[n,e]=P.useState(void 0),t=ve(),{params:s,details:r,videoElementSizeInfo:i}=V(({videoData:{params:p,details:E,videoElementSizeInfo:x}})=>({params:p,details:E,videoElementSizeInfo:x}),K),{currentTime:a,duration:o}=V(({controller:{currentTime:p,duration:E,isEnded:x,firstPlay:v}})=>({currentTime:p,duration:E,isEnded:x,firstPlay:v}),K),l=P.useRef(null),c=P.useRef(0),u=P.useRef(0),d=P.useRef(0),f=P.useRef(0),g=P.useRef(0),h=P.useRef(1),m=P.useRef(N()?N().currentTime:0);return Fy(),Ny(),P.useLayoutEffect(()=>{let p=new he(Qg());return Xa(g),d.current=Date.now(),he.isSupported()?(p.attachMedia(N()),p.on(he.Events.MEDIA_ATTACHED,()=>lu(he,p)),p.on(he.Events.FRAG_BUFFERED,()=>uu(p)),p.on(he.Events.FRAG_CHANGED,(E,x)=>du(p,x,e)),p.on(he.Events.FRAG_PARSED,(E,x)=>fu(p,x,e)),p.on(he.Events.ERROR,(E,x)=>ct(hu(x))),N().addEventListener("waiting",E=>pu(E,u)),N().addEventListener("seeking",E=>em(E,u)),N().addEventListener("play",E=>tm(E,l)),N().addEventListener("playing",()=>sm(h,g,d,f,l,c,u,m)),N().addEventListener("pause",gu),N().addEventListener("timeupdate",nm),N().addEventListener("canplay",mu),N().addEventListener("ended",rm),N().addEventListener("error",jn),document.addEventListener("visibilitychange",Eu)):N().canPlayType("application/vnd.apple.mpegurl")&&(N().src=r.stream_link,N().addEventListener("waiting",E=>pu(E,u)),N().addEventListener("play",E=>im(E,l)),N().addEventListener("playing",am),N().addEventListener("canplay",mu),N().addEventListener("timeupdate",om),N().addEventListener("ended",lm),N().addEventListener("pause",gu),au()),()=>{yh(),p.detachMedia(),p.off(he.Events.MEDIA_ATTACHED,()=>lu(he,p)),p.off(he.Events.FRAG_BUFFERED,()=>uu(p)),p.off(he.Events.FRAG_CHANGED,(E,x)=>du(p,x,e)),p.off(he.Events.FRAG_PARSED,(E,x)=>fu(p,x,e)),p.off(he.Events.ERROR,(E,x)=>hu(x)),p.off(he.Events.MANIFEST_PARSED,()=>ou(p)),document.removeEventListener("visibilitychange",Eu)}},[r.stream_link]),P.useEffect(()=>{a<o&&C(T.isEnded)&&t(gr(!1))},[a]),P.useEffect(()=>{C(T.hasPlayStatusParams)&&(s.playStatus?N().play():N().pause())},[s.playStatus]),My(n),Iu(),Du(),S.jsx(S.Fragment,{children:S.jsxs("video",{poster:s.banner?s.banner:r.banner,preload:"metadata",crossOrigin:"anonymous",id:"player-tag",playsInline:!0,className:"pl-h-full pl-flex-1 pl-items-center",style:{width:"100%",height:"100%",maxWidth:i.width?i.width:"100%",maxHeight:i.width?i.width<i.height?i.width*9/16:i.width*16/9:"100%"},autoPlay:C(T.hasAutoPlay),children:[S.jsx("img",{onLoad:()=>f.current=Date.now(),src:s.banner?s.banner:r.banner,alt:s.bannerAlt?s.bannerAlt:C(T.isStaticFormat)?xe("bannerAlt"):r.title,className:"pl-size-full"}),C(T.hasSubtitlesInDetails)&&Ja(r.subtitles).map(p=>S.jsx("track",{id:`player-tracker-${p.lang}`,src:p.url,label:eo(p.lang),kind:"subtitles",srcLang:p.lang},p.id))]})})}},Symbol.toStringTag,{value:"Module"})),Uy=({className:n,onClick:e})=>S.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,onClick:e,children:S.jsxs("g",{opacity:"0.7",children:[S.jsx("path",{d:"M11.6997 10.7997C12.2247 10.2747 13.1247 10.6497 13.1247 11.3914V13.833C13.1247 15.2664 12.6081 16.3414 11.6831 16.858C11.3081 17.0664 10.8914 17.1664 10.4581 17.1664C9.79141 17.1664 9.07474 16.9414 8.34141 16.483L7.80807 16.1497C7.35807 15.8664 7.28307 15.233 7.65807 14.858L11.6997 10.7997Z"}),S.jsx("path",{d:"M18.141 1.85742C17.891 1.60742 17.4827 1.60742 17.2327 1.85742L13.1077 5.98242C13.0577 4.64909 12.5577 3.64909 11.6743 3.15742C10.741 2.64076 9.54935 2.77409 8.33268 3.53242L5.90768 5.04909C5.74102 5.14909 5.54935 5.20742 5.35768 5.20742H4.58268H4.16602C2.14935 5.20742 1.04102 6.31575 1.04102 8.33242V11.6658C1.04102 13.6824 2.14935 14.7908 4.16602 14.7908H4.29935L1.84935 17.2408C1.59935 17.4908 1.59935 17.8991 1.84935 18.1491C1.98268 18.2658 2.14102 18.3324 2.30768 18.3324C2.47435 18.3324 2.63268 18.2658 2.75768 18.1408L18.141 2.75742C18.3994 2.50742 18.3994 2.10742 18.141 1.85742Z"})]})}),$y=({className:n,onClick:e})=>S.jsx("svg",{width:"13",height:"16",viewBox:"0 0 13 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,onClick:e,children:S.jsx("path",{d:"M10.6827 1.14944C9.74935 0.632778 8.55768 0.766111 7.34102 1.52444L4.90768 3.04944C4.74102 3.14944 4.54935 3.20778 4.35768 3.20778H3.58268H3.16602C1.14935 3.20778 0.0410156 4.31611 0.0410156 6.33278V9.66611C0.0410156 11.6828 1.14935 12.7911 3.16602 12.7911H3.58268H4.35768C4.54935 12.7911 4.74102 12.8494 4.90768 12.9494L7.34102 14.4744C8.07435 14.9328 8.79102 15.1578 9.45768 15.1578C9.89102 15.1578 10.3077 15.0578 10.6827 14.8494C11.6077 14.3328 12.1243 13.2578 12.1243 11.8244V4.17444C12.1243 2.74111 11.6077 1.66611 10.6827 1.14944Z"})}),Vy=Object.freeze(Object.defineProperty({__proto__:null,default:()=>{const[n,e]=P.useState(""),t=ve(),{settings:s}=V(({user:{settings:l}})=>({settings:l}),K),r=P.useRef(s.brightness),i=P.useRef(s.volume),a=P.useRef(n);P.useEffect(()=>{a.current=n},[n]),P.useEffect(()=>{let l=0;const c=f=>{C(T.hidePopovers)&&!yr(f,"progress-area")&&(l=f.touches[0].clientY)},u=f=>{C(T.hidePopovers)&&!yr(f,"progress-area")&&(f.stopPropagation(),f.touches[0].clientX>window.innerWidth/2?o(f,"volume",l,window.innerHeight):f.touches[0].clientX<window.innerWidth/2&&o(f,"brightness",l,window.innerHeight))},d=()=>{const{settings:f}=R.getState().user;a.current==="brightness"&&r.current!==f.brightness?(oe(dh(r.current,f.brightness)),r.current=f.brightness):a.current==="volume"&&i.current!==f.volume&&(oe(ln(i.current,f.volume)),i.current=f.volume),setTimeout(()=>e(""),500)};return document.addEventListener("touchstart",f=>c(f)),document.addEventListener("touchmove",f=>u(f)),document.addEventListener("touchend",()=>d()),()=>{document.removeEventListener("touchstart",f=>c(f)),document.removeEventListener("touchmove",f=>u(f)),document.removeEventListener("touchend",()=>d())}},[]),P.useEffect(()=>{s.volume===0&&!n&&(i.current=0)},[s.volume]);const o=(l,c,u,d)=>{const{settings:f}=R.getState().user,{activePointerProgressBar:g}=R.getState().controller;try{g||t(Se(!1)),l.stopPropagation(),e(c);const{height:h}=document.getElementsByClassName("pl-bar")[0].getBoundingClientRect();if(c==="volume"){const m=f.volume+(u-l.touches[0].clientY)/40*h/d;let p;m>100?p=100:m<0?p=0:p=Math.ceil(Math.abs(m)),t(ot({...f,volume:p})),N().volume=p/100}else if(c==="brightness"){const m=f.brightness+(u-l.touches[0].clientY)/40*h/d;m>100?t(ot({...f,brightness:100})):m<0?t(ot({...f,brightness:0})):t(ot({...f,brightness:Math.ceil(Math.abs(m))}))}}catch{return!1}};return S.jsxs("div",{id:"volume-brightness",children:[S.jsx("div",{className:"pl-fixed pl-right-0 pl-top-0 pl-h-screen pl-w-screen pl-bg-black",style:{opacity:s.brightness<10?.9:1-s.brightness/100}}),S.jsxs("div",{className:"pl-absolute pl-right-0 pl-top-0 pl-flex pl-h-full pl-w-full pl-items-center pl-justify-between",children:[S.jsx("div",{className:"pl-flex pl-h-full pl-flex-1 pl-items-center pl-pr-6",children:S.jsx("div",{id:"volume-progressbar",className:`pl-bar pl-relative pl-h-[200px] pl-w-6 ${n==="volume"&&"pl-bg-gray-300"} pl-flex pl-max-h-[80vh] pl-items-end pl-justify-end pl-overflow-hidden pl-rounded-[50px]`,children:n==="volume"&&S.jsxs(S.Fragment,{children:[S.jsx("div",{className:"pl-absolute pl-w-full pl-rounded-b-[50px] pl-bg-secondary-600",style:{height:`${s.volume}%`}}),S.jsxs("div",{className:"pl-mb-[7px] pl-ml-0.5 pl-flex pl-items-center pl-gap-1",children:[S.jsxs("div",{className:"pl-relative pl-flex pl-items-center",children:[s.volume>0&&S.jsx("div",{className:"pl-absolute pl-right-[2px] pl-flex pl-h-2 pl-w-2 pl-items-center pl-justify-center pl-rounded-full pl-border-2 pl-border-r-2 pl-border-transparent pl-border-r-z-yellow-light"}),s.volume>33&&S.jsx("div",{className:"pl-absolute pl-right-[-1px] pl-flex pl-h-3 pl-w-3 pl-items-center pl-justify-center pl-rounded-full pl-border-2 pl-border-r-2 pl-border-transparent pl-border-r-z-yellow-light"}),s.volume>66&&S.jsx("div",{className:"pl-absolute pl-right-[-4px] pl-flex pl-h-4 pl-w-4 pl-items-center pl-justify-center pl-rounded-full pl-border-2 pl-border-r-2 pl-border-transparent pl-border-r-z-yellow-light"})]}),s.volume===0?S.jsx(Uy,{className:"pl-z-[1] pl-h-[13px] pl-w-[13px] pl-fill-dark-7"}):S.jsx($y,{className:"pl-z-[1] pl-h-[13px] pl-w-[13px] pl-fill-dark-7"})]})]})})}),n&&S.jsx("div",{className:"pl-flex pl-h-[54px] pl-w-[54px] pl-items-center pl-justify-center pl-rounded-full pl-bg-secondary-700/[0.8] pl-text-[32px] pl-font-normal pl-text-white",children:n==="volume"?s.volume:s.brightness}),S.jsx("div",{className:"pl-flex pl-h-full pl-flex-1 pl-items-center pl-justify-end pl-pl-6",children:S.jsx("div",{id:"brightness-progressbar",className:`pl-bar pl-relative pl-h-[200px] pl-w-6 ${n==="brightness"&&"pl-bg-gray-300"} pl-flex pl-max-h-[80vh] pl-items-end pl-justify-end pl-overflow-hidden pl-rounded-[50px]`,children:n==="brightness"&&S.jsxs(S.Fragment,{children:[S.jsx("div",{className:"pl-absolute pl-w-full pl-rounded-b-[50px] pl-bg-primary-600",style:{height:`${s.brightness}%`}}),S.jsx("div",{className:"pl-mb-[7px] pl-ml-0.5 pl-flex pl-items-center pl-gap-1",style:{opacity:s.brightness/100},children:S.jsx("img",{alt:"",src:re.sun,className:"pl-size-5 pl-flex-1"})})]})})})]})]})}},Symbol.toStringTag,{value:"Module"})),Gy=Object.freeze(Object.defineProperty({__proto__:null,default:()=>S.jsxs("div",{className:"pl-flex pl-h-full pl-w-full pl-flex-col pl-items-center pl-justify-center pl-rounded-2xl",children:[S.jsx("div",{className:"pl-flex pl-justify-center",children:S.jsx("img",{src:re.notFound,alt:"notFound",width:120,height:70})}),S.jsx("h1",{className:"pl-mb-2 pl-mt-4 pl-text-xs pl-font-medium pl-text-black/[0.87]",children:xe("notFoundVideo")}),S.jsx("p",{className:"pl-text-xs pl-font-medium pl-text-black/[0.50]",children:xe("watchSimilarVideo")})]})},Symbol.toStringTag,{value:"Module"}));Ae.FeatureExcept=Yn,Ae.MiniPlayerLibrary=Sm,Ae.VideoPlayerLibrary=Dh,Object.defineProperty(Ae,Symbol.toStringTag,{value:"Module"})});
64
+ } (data length: ${t&&t.byteLength})`),r.update(t)}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,s)=>{const r=pn(this.config),i=e.map(Hr).filter(a=>!!a&&r.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(i).then(({keySystem:a})=>{const o=Wr(a);o?t(o):s(new Error(`Unable to find format for key-system "${a}"`))}).catch(s)})}loadKey(e){const t=e.keyInfo.decryptdata,s=this.getKeyIdString(t),r=`(keyId: ${s} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${r}`);let i=this.keyIdToKeySessionPromise[s];return i||(i=this.keyIdToKeySessionPromise[s]=this.getKeySystemForKeyPromise(t).then(({keySystem:a,mediaKeys:o})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${r}`),this.attemptSetMediaKeys(a,o).then(()=>{this.throwIfDestroyed();const l=this.createMediaKeySessionContext({keySystem:a,mediaKeys:o,decryptdata:t});return this.generateRequestWithPreferredKeySession(l,"cenc",t.pssh,"playlist-key")}))),i.catch(a=>this.handleError(a))),i}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof We?this.hls.trigger(y.ERROR,e.data):this.hls.trigger(y.ERROR,{type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){const t=this.getKeyIdString(e),s=this.keyIdToKeySessionPromise[t];if(!s){const r=Hr(e.keyFormat),i=r?[r]:pn(this.config);return this.attemptKeySystemAccess(i)}return s}getKeySystemSelectionPromise(e){if(e.length||(e=pn(this.config)),e.length===0)throw new We({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){const s=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const r=Promise.all(s).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(r),r.then(()=>{this.log(`Media-keys set for "${e}"`),s.push(r),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(i=>s.indexOf(i)===-1)})}generateRequestWithPreferredKeySession(e,t,s,r){var i,a;const o=(i=this.config.drmSystems)==null||(a=i[e.keySystem])==null?void 0:a.generateRequest;if(o)try{const h=o.call(this.hls,t,s,e);if(!h)throw new Error("Invalid response from configured generateRequest filter");t=h.initDataType,s=e.decryptdata.pssh=h.initData?new Uint8Array(h.initData):null}catch(h){var l;if(this.warn(h.message),(l=this.hls)!=null&&l.config.debug)throw h}if(s===null)return this.log(`Skipping key-session request for "${r}" (no initData)`),Promise.resolve(e);const c=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${r}": ${c} (init data type: ${t} length: ${s?s.byteLength:null})`);const u=new xi,d=e._onmessage=h=>{const m=e.mediaKeysSession;if(!m){u.emit("error",new Error("invalid state"));return}const{messageType:p,message:E}=h;this.log(`"${p}" message event for session "${m.sessionId}" message size: ${E.byteLength}`),p==="license-request"||p==="license-renewal"?this.renewLicense(e,E).catch(x=>{this.handleError(x),u.emit("error",x)}):p==="license-release"?e.keySystem===ae.FAIRPLAY&&(this.updateKeySession(e,Gr("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${p}"`)},f=e._onkeystatuseschange=h=>{if(!e.mediaKeysSession){u.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);const p=e.keyStatus;u.emit("keyStatus",p),p==="expired"&&(this.warn(`${e.keySystem} expired for key ${c}`),this.renewKeySession(e))};e.mediaKeysSession.addEventListener("message",d),e.mediaKeysSession.addEventListener("keystatuseschange",f);const g=new Promise((h,m)=>{u.on("error",m),u.on("keyStatus",p=>{p.startsWith("usable")?h():p==="output-restricted"?m(new We({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):p==="internal-error"?m(new We({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${p}"`)):p==="expired"?m(new Error("key expired while generating request")):this.warn(`unhandled key status change "${p}"`)})});return e.mediaKeysSession.generateRequest(t,s).then(()=>{var h;this.log(`Request generated for key-session "${(h=e.mediaKeysSession)==null?void 0:h.sessionId}" keyId: ${c}`)}).catch(h=>{throw new We({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_NO_SESSION,error:h,fatal:!1},`Error generating key-session request: ${h}`)}).then(()=>g).catch(h=>{throw u.removeAllListeners(),this.removeSession(e),h}).then(()=>(u.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,s)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${et.hexDump("buffer"in s?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):new Uint8Array(s))} session keyId: ${et.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){const t=this.config,s=t.loader,r=new s(t),i=this.getServerCertificateUrl(e);return i?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,o)=>{const l={responseType:"arraybuffer",url:i},c=t.certLoadPolicy.default,u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(f,g,h,m)=>{a(f.data)},onError:(f,g,h,m)=>{o(new We({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:h,response:be({url:l.url,data:void 0},f)},`"${e}" certificate request failed (${i}). Status: ${f.code} (${f.text})`))},onTimeout:(f,g,h)=>{o(new We({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:h,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${i})`))},onAbort:(f,g,h)=>{o(new Error("aborted"))}};r.load(l,u,d)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,s){return new Promise((r,i)=>{e.setServerCertificate(s).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${s==null?void 0:s.byteLength}) on "${t}"`),r(e)}).catch(a=>{i(new We({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(s=>this.updateKeySession(e,new Uint8Array(s)).catch(r=>{throw new We({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:r,fatal:!0},r.message)}))}unpackPlayReadyKeyMessage(e,t){const s=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!s.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const r=new DOMParser().parseFromString(s,"application/xml"),i=r.querySelectorAll("HttpHeader");if(i.length>0){let u;for(let d=0,f=i.length;d<f;d++){var a,o;u=i[d];const g=(a=u.querySelector("name"))==null?void 0:a.textContent,h=(o=u.querySelector("value"))==null?void 0:o.textContent;g&&h&&e.setRequestHeader(g,h)}}const l=r.querySelector("Challenge"),c=l==null?void 0:l.textContent;if(!c)throw new Error("Cannot find <Challenge> in key message");return Gr(atob(c))}setupLicenseXHR(e,t,s,r){const i=this.config.licenseXhrSetup;return i?Promise.resolve().then(()=>{if(!s.decryptdata)throw new Error("Key removed");return i.call(this.hls,e,t,s,r)}).catch(a=>{if(!s.decryptdata)throw a;return e.open("POST",t,!0),i.call(this.hls,e,t,s,r)}).then(a=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:a||r})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:r}))}requestLicense(e,t){const s=this.config.keyLoadPolicy.default;return new Promise((r,i)=>{const a=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${a}`);const o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return i(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let l=o.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);const c=this.config.licenseResponseCallback;if(c)try{l=c.call(this.hls,o,a,e)}catch(u){this.error(u)}r(l)}else{const l=s.errorRetry,c=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>c||o.status>=400&&o.status<500)i(new We({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{const u=c-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${u} attempts left`),this.requestLicense(e,t).then(r,i)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:l,licenseChallenge:c})=>{e.keySystem==ae.PLAYREADY&&(c=this.unpackPlayReadyKeyMessage(l,c)),l.send(c)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const s=t.media;this.media=s,s.removeEventListener("encrypted",this.onMediaEncrypted),s.removeEventListener("waitingforkey",this.onWaitingForKey),s.addEventListener("encrypted",this.onMediaEncrypted),s.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Es.clearKeyUriToKeyIdMap();const s=t.length;Jt.CDMCleanupPromise=Promise.all(t.map(r=>this.removeSession(r)).concat(e==null?void 0:e.setMediaKeys(null).catch(r=>{this.log(`Could not clear media keys: ${r}`)}))).then(()=>{s&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(r=>{this.log(`Could not close sessions and clear media keys: ${r}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){const s=t.reduce((r,i)=>(r.indexOf(i.keyFormat)===-1&&r.push(i.keyFormat),r),[]);this.log(`Selecting key-system from session-keys ${s.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(s)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:s}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),s&&s.readyState!==XMLHttpRequest.DONE&&s.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const r=this.mediaKeySessions.indexOf(e);return r>-1&&this.mediaKeySessions.splice(r,1),t.remove().catch(i=>{this.log(`Could not remove session: ${i}`)}).then(()=>t.close()).catch(i=>{this.log(`Could not close session: ${i}`)})}}}Jt.CDMCleanupPromise=void 0;class We extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}var Pe;(function(n){n.MANIFEST="m",n.AUDIO="a",n.VIDEO="v",n.MUXED="av",n.INIT="i",n.CAPTION="c",n.TIMED_TEXT="tt",n.KEY="k",n.OTHER="o"})(Pe||(Pe={}));var Oi;(function(n){n.DASH="d",n.HLS="h",n.SMOOTH="s",n.OTHER="o"})(Oi||(Oi={}));var Bt;(function(n){n.OBJECT="CMCD-Object",n.REQUEST="CMCD-Request",n.SESSION="CMCD-Session",n.STATUS="CMCD-Status"})(Bt||(Bt={}));const H1={[Bt.OBJECT]:["br","d","ot","tb"],[Bt.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[Bt.SESSION]:["cid","pr","sf","sid","st","v"],[Bt.STATUS]:["bs","rtp"]};class es{constructor(e,t){this.value=void 0,this.params=void 0,Array.isArray(e)&&(e=e.map(s=>s instanceof es?s:new es(s))),this.value=e,this.params=t}}class Hc{constructor(e){this.description=void 0,this.description=e}}const K1="Dict";function W1(n){return Array.isArray(n)?JSON.stringify(n):n instanceof Map?"Map{}":n instanceof Set?"Set{}":typeof n=="object"?JSON.stringify(n):String(n)}function j1(n,e,t,s){return new Error(`failed to ${n} "${W1(e)}" as ${t}`,{cause:s})}const Kc="Bare Item",z1="Boolean",q1="Byte Sequence",Y1="Decimal",X1="Integer";function Z1(n){return n<-999999999999999||999999999999999<n}const Q1=/[\x00-\x1f\x7f]+/,J1="Token",eg="Key";function it(n,e,t){return j1("serialize",n,e,t)}function tg(n){if(typeof n!="boolean")throw it(n,z1);return n?"?1":"?0"}function sg(n){return btoa(String.fromCharCode(...n))}function ng(n){if(ArrayBuffer.isView(n)===!1)throw it(n,q1);return`:${sg(n)}:`}function Wc(n){if(Z1(n))throw it(n,X1);return n.toString()}function rg(n){return`@${Wc(n.getTime()/1e3)}`}function jc(n,e){if(n<0)return-jc(-n,e);const t=Math.pow(10,e);if(Math.abs(n*t%1-.5)<Number.EPSILON){const r=Math.floor(n*t);return(r%2===0?r:r+1)/t}else return Math.round(n*t)/t}function ig(n){const e=jc(n,3);if(Math.floor(Math.abs(e)).toString().length>12)throw it(n,Y1);const t=e.toString();return t.includes(".")?t:`${t}.0`}const ag="String";function og(n){if(Q1.test(n))throw it(n,ag);return`"${n.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function lg(n){return n.description||n.toString().slice(7,-1)}function zc(n){const e=lg(n);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw it(e,J1);return e}function Fi(n){switch(typeof n){case"number":if(!H(n))throw it(n,Kc);return Number.isInteger(n)?Wc(n):ig(n);case"string":return og(n);case"symbol":return zc(n);case"boolean":return tg(n);case"object":if(n instanceof Date)return rg(n);if(n instanceof Uint8Array)return ng(n);if(n instanceof Hc)return zc(n);default:throw it(n,Kc)}}function Mi(n){if(/^[a-z*][a-z0-9\-_.*]*$/.test(n)===!1)throw it(n,eg);return n}function Ni(n){return n==null?"":Object.entries(n).map(([e,t])=>t===!0?`;${Mi(e)}`:`;${Mi(e)}=${Fi(t)}`).join("")}function qc(n){return n instanceof es?`${Fi(n.value)}${Ni(n.params)}`:Fi(n)}function cg(n){return`(${n.value.map(qc).join(" ")})${Ni(n.params)}`}function ug(n,e={whitespace:!0}){if(typeof n!="object")throw it(n,K1);const t=n instanceof Map?n.entries():Object.entries(n),s=e!=null&&e.whitespace?" ":"";return Array.from(t).map(([r,i])=>{i instanceof es||(i=new es(i));let a=Mi(r);return i.value===!0?a+=Ni(i.params):(a+="=",Array.isArray(i.value)?a+=cg(i):a+=qc(i)),a}).join(`,${s}`)}function dg(n,e){return ug(n,e)}const fg=n=>n==="ot"||n==="sf"||n==="st",hg=n=>typeof n=="number"?H(n):n!=null&&n!==""&&n!==!1;function pg(n,e){const t=new URL(n),s=new URL(e);if(t.origin!==s.origin)return n;const r=t.pathname.split("/").slice(1),i=s.pathname.split("/").slice(1,-1);for(;r[0]===i[0];)r.shift(),i.shift();for(;i.length;)i.shift(),r.unshift("..");return r.join("/")}function gg(){try{return crypto.randomUUID()}catch{try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{const i=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(r=="x"?i:i&3|8).toString(16)})}}}const Hn=n=>Math.round(n),mg=(n,e)=>(e!=null&&e.baseUrl&&(n=pg(n,e.baseUrl)),encodeURIComponent(n)),Kn=n=>Hn(n/100)*100,yg={br:Hn,d:Hn,bl:Kn,dl:Kn,mtp:Kn,nor:mg,rtp:Kn,tb:Hn};function Eg(n,e){const t={};if(n==null||typeof n!="object")return t;const s=Object.keys(n).sort(),r=ye({},yg,e==null?void 0:e.formatters),i=e==null?void 0:e.filter;return s.forEach(a=>{if(i!=null&&i(a))return;let o=n[a];const l=r[a];l&&(o=l(o,e)),!(a==="v"&&o===1)&&(a=="pr"&&o===1||hg(o)&&(fg(a)&&typeof o=="string"&&(o=new Hc(o)),t[a]=o))}),t}function Yc(n,e={}){return n?dg(Eg(n,e),ye({whitespace:!1},e)):""}function Sg(n,e={}){if(!n)return{};const t=Object.entries(n),s=Object.entries(H1).concat(Object.entries((e==null?void 0:e.customHeaderMap)||{})),r=t.reduce((i,a)=>{var o,l;const[c,u]=a,d=((o=s.find(f=>f[1].includes(c)))==null?void 0:o[0])||Bt.REQUEST;return(l=i[d])!=null||(i[d]={}),i[d][c]=u,i},{});return Object.entries(r).reduce((i,[a,o])=>(i[a]=Yc(o,e),i),{})}function Tg(n,e,t){return ye(n,Sg(e,t))}const xg="CMCD";function vg(n,e={}){if(!n)return"";const t=Yc(n,e);return`${xg}=${encodeURIComponent(t)}`}const Xc=/CMCD=[^&#]+/;function bg(n,e,t){const s=vg(e,t);if(!s)return n;if(Xc.test(n))return n.replace(Xc,s);const r=n.includes("?")?"&":"?";return`${n}${r}${s}`}class Cg{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=r=>{try{this.apply(r,{ot:Pe.MANIFEST,su:!this.initialized})}catch(i){L.warn("Could not generate manifest CMCD data.",i)}},this.applyFragmentData=r=>{try{const i=r.frag,a=this.hls.levels[i.level],o=this.getObjectType(i),l={d:i.duration*1e3,ot:o};(o===Pe.VIDEO||o===Pe.AUDIO||o==Pe.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(r,l)}catch(i){L.warn("Could not generate segment CMCD data.",i)}},this.hls=e;const t=this.config=e.config,{cmcd:s}=t;s!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=s.sessionId||gg(),this.cid=s.contentId,this.useHeaders=s.useHeaders===!0,this.includeKeys=s.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHED,this.onMediaDetached,this),e.on(y.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHED,this.onMediaDetached,this),e.off(y.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var s,r;this.audioBuffer=(s=t.tracks.audio)==null?void 0:s.buffer,this.videoBuffer=(r=t.tracks.video)==null?void 0:r.buffer}createData(){var e;return{v:1,sf:Oi.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){ye(t,this.createData());const s=t.ot===Pe.INIT||t.ot===Pe.VIDEO||t.ot===Pe.MUXED;this.starved&&s&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);const{includeKeys:r}=this;r&&(t=Object.keys(t).reduce((i,a)=>(r.includes(a)&&(i[a]=t[a]),i),{})),this.useHeaders?(e.headers||(e.headers={}),Tg(e.headers,t)):e.url=bg(e.url,t)}getObjectType(e){const{type:t}=e;if(t==="subtitle")return Pe.TIMED_TEXT;if(e.sn==="initSegment")return Pe.INIT;if(t==="audio")return Pe.AUDIO;if(t==="main")return this.hls.audioTracks.length?Pe.VIDEO:Pe.MUXED}getTopBandwidth(e){let t=0,s;const r=this.hls;if(e===Pe.AUDIO)s=r.audioTracks;else{const i=r.maxAutoLevel,a=i>-1?i+1:r.levels.length;s=r.levels.slice(0,a)}for(const i of s)i.bitrate>t&&(t=i.bitrate);return t>0?t:NaN}getBufferLength(e){const t=this.hls.media,s=e===Pe.AUDIO?this.audioBuffer:this.videoBuffer;return!s||!t?NaN:de.bufferInfo(s,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,s=e||this.config.loader;return class{constructor(i){this.loader=void 0,this.loader=new s(i)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(i,a,o){t(i),this.loader.load(i,a,o)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,s=e||this.config.loader;return class{constructor(i){this.loader=void 0,this.loader=new s(i)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(i,a,o){t(i),this.loader.load(i,a,o)}}}}const wg=3e5;class Lg{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=L.log.bind(L,"[content-steering]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.ERROR,this.onError,this))}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter(s=>s!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:s}=t;s!==null&&(this.pathwayId=s.pathwayId,this.uri=s.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:s}=t;if((s==null?void 0:s.action)===Ie.SendAlternateToPenaltyBox&&s.flags===Ye.MoveAllAlternatesMatchingHost){const r=this.levels;let i=this.pathwayPriority,a=this.pathwayId;if(t.context){const{groupId:o,pathwayId:l,type:c}=t.context;o&&r?a=this.getPathwayForGroupId(o,c,a):l&&(a=l)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!i&&r&&(i=r.reduce((o,l)=>(o.indexOf(l.pathwayId)===-1&&o.push(l.pathwayId),o),[])),i&&i.length>1&&(this.updatePathwayPriority(i),s.resolved=this.pathwayId!==a),s.resolved||L.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${r&&r.length} priorities: ${JSON.stringify(i)} penalized: ${JSON.stringify(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){const s=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${s}"`),t=this.getLevelsForPathway(s),this.pathwayId=s}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t;const s=this.penalizedPathways,r=performance.now();Object.keys(s).forEach(i=>{r-s[i]>wg&&delete s[i]});for(let i=0;i<e.length;i++){const a=e[i];if(a in s)continue;if(a===this.pathwayId)return;const o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,Vl(t),this.hls.trigger(y.LEVELS_UPDATED,{levels:t});const c=this.hls.levels[o];l&&c&&this.levels&&(c.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&c.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${c.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,s){const r=this.getLevelsForPathway(s).concat(this.levels||[]);for(let i=0;i<r.length;i++)if(t===se.AUDIO_TRACK&&r[i].hasAudioGroup(e)||t===se.SUBTITLE_TRACK&&r[i].hasSubtitleGroup(e))return r[i].pathwayId;return s}clonePathways(e){const t=this.levels;if(!t)return;const s={},r={};e.forEach(i=>{const{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=i;if(t.some(u=>u.pathwayId===a))return;const c=this.getLevelsForPathway(o).map(u=>{const d=new pe(u.attrs);d["PATHWAY-ID"]=a;const f=d.AUDIO&&`${d.AUDIO}_clone_${a}`,g=d.SUBTITLES&&`${d.SUBTITLES}_clone_${a}`;f&&(s[d.AUDIO]=f,d.AUDIO=f),g&&(r[d.SUBTITLES]=g,d.SUBTITLES=g);const h=Qc(u.uri,d["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),m=new qt({attrs:d,audioCodec:u.audioCodec,bitrate:u.bitrate,height:u.height,name:u.name,url:h,videoCodec:u.videoCodec,width:u.width});if(u.audioGroups)for(let p=1;p<u.audioGroups.length;p++)m.addGroupId("audio",`${u.audioGroups[p]}_clone_${a}`);if(u.subtitleGroups)for(let p=1;p<u.subtitleGroups.length;p++)m.addGroupId("text",`${u.subtitleGroups[p]}_clone_${a}`);return m});t.push(...c),Zc(this.audioTracks,s,l,a),Zc(this.subtitleTracks,r,l,a)})}loadSteeringManifest(e){const t=this.hls.config,s=t.loader;this.loader&&this.loader.destroy(),this.loader=new s(t);let r;try{r=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(r.protocol!=="data:"){const u=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;r.searchParams.set("_HLS_pathway",this.pathwayId),r.searchParams.set("_HLS_throughput",""+u)}const i={responseType:"json",url:r.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},c={onSuccess:(u,d,f,g)=>{this.log(`Loaded steering manifest: "${r}"`);const h=u.data;if(h.VERSION!==1){this.log(`Steering VERSION ${h.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=h.TTL;const{"RELOAD-URI":m,"PATHWAY-CLONES":p,"PATHWAY-PRIORITY":E}=h;if(m)try{this.uri=new self.URL(m,r).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${m}`);return}this.scheduleRefresh(this.uri||f.url),p&&this.clonePathways(p);const x={steeringManifest:h,url:r.toString()};this.hls.trigger(y.STEERING_MANIFEST_LOADED,x),E&&this.updatePathwayPriority(E)},onError:(u,d,f,g)=>{if(this.log(`Error loading steering manifest: ${u.code} ${u.text} (${d.url})`),this.stopLoad(),u.code===410){this.enabled=!1,this.log(`Steering manifest ${d.url} no longer available`);return}let h=this.timeToLoad*1e3;if(u.code===429){const m=this.loader;if(typeof(m==null?void 0:m.getResponseHeader)=="function"){const p=m.getResponseHeader("Retry-After");p&&(h=parseFloat(p)*1e3)}this.log(`Steering manifest ${d.url} rate limited`);return}this.scheduleRefresh(this.uri||d.url,h)},onTimeout:(u,d,f)=>{this.log(`Timeout loading steering manifest (${d.url})`),this.scheduleRefresh(this.uri||d.url)}};this.log(`Requesting steering manifest: ${r}`),this.loader.load(i,l,c)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var s;const r=(s=this.hls)==null?void 0:s.media;if(r&&!r.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}}function Zc(n,e,t,s){n&&Object.keys(e).forEach(r=>{const i=n.filter(a=>a.groupId===r).map(a=>{const o=ye({},a);return o.details=void 0,o.attrs=new pe(o.attrs),o.url=o.attrs.URI=Qc(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[r],o.attrs["PATHWAY-ID"]=s,o});n.push(...i)})}function Qc(n,e,t,s){const{HOST:r,PARAMS:i,[t]:a}=s;let o;e&&(o=a==null?void 0:a[e],o&&(n=o));const l=new self.URL(n);return r&&!o&&(l.host=r),i&&Object.keys(i).sort().forEach(c=>{c&&l.searchParams.set(c,i[c])}),l.href}const Ag=/^age:\s*[\d.]+\s*$/im;class Jc{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 fn,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,t,s){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=s,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const s=this.loader=new self.XMLHttpRequest,r=this.stats;r.loading.first=0,r.loaded=0,r.aborted=!1;const i=this.xhrSetup;i?Promise.resolve().then(()=>{if(!(this.loader!==s||this.stats.aborted))return i(s,t.url)}).catch(a=>{if(!(this.loader!==s||this.stats.aborted))return s.open("GET",t.url,!0),i(s,t.url)}).then(()=>{this.loader!==s||this.stats.aborted||this.openAndSendXhr(s,t,e)}).catch(a=>{this.callbacks.onError({code:s.status,text:a.message},t,s,r)}):this.openAndSendXhr(s,t,e)}openAndSendXhr(e,t,s){e.readyState||e.open("GET",t.url,!0);const r=t.headers,{maxTimeToFirstByteMs:i,maxLoadTimeMs:a}=s.loadPolicy;if(r)for(const o in r)e.setRequestHeader(o,r[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),s.timeout=i&&H(i)?i:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:s}=this;if(!e||!t)return;const r=t.readyState,i=this.config;if(!s.aborted&&r>=2&&(s.loading.first===0&&(s.loading.first=Math.max(self.performance.now(),s.loading.start),i.timeout!==i.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),i.timeout=i.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.loadPolicy.maxLoadTimeMs-(s.loading.first-s.loading.start)))),r===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const a=t.status,o=t.responseType==="text"?t.responseText:null;if(a>=200&&a<300){const d=o??t.response;if(d!=null){s.loading.end=Math.max(self.performance.now(),s.loading.first);const f=t.responseType==="arraybuffer"?d.byteLength:d.length;if(s.loaded=s.total=f,s.bwEstimate=s.total*8e3/(s.loading.end-s.loading.first),!this.callbacks)return;const g=this.callbacks.onProgress;if(g&&g(s,e,d,t),!this.callbacks)return;const h={url:t.responseURL,data:d,code:a};this.callbacks.onSuccess(h,s,e,t);return}}const l=i.loadPolicy.errorRetry,c=s.retry,u={url:e.url,data:void 0,code:a};An(l,c,!1,u)?this.retry(l):(L.error(`${a} while loading ${e.url}`),this.callbacks.onError({code:a,text:t.statusText},e,t,s))}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(An(e,t,!0))this.retry(e);else{var s;L.warn(`timeout while loading ${(s=this.context)==null?void 0:s.url}`);const r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:s}=this;this.retryDelay=oi(e,s.retry),s.retry++,L.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t==null?void 0:t.url}, retrying ${s.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&Ag.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}function Dg(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const Ig=/(\d+)-(\d+)\/(\d+)/;class eu{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||_g,this.controller=new self.AbortController,this.stats=new fn}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,s){const r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now();const i=Rg(e,this.controller.signal),a=s.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:c,maxLoadTimeMs:u}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=s,this.request=this.fetchSetup(e,i),self.clearTimeout(this.requestTimeout),t.timeout=c&&H(c)?c:u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),s.onTimeout(r,e,this.response)},t.timeout),self.fetch(this.request).then(d=>{this.response=this.loader=d;const f=Math.max(self.performance.now(),r.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),s.onTimeout(r,e,this.response)},u-(f-r.loading.start)),!d.ok){const{status:g,statusText:h}=d;throw new Og(h||"fetch, bad network response",g,d)}return r.loading.first=f,r.total=Pg(d.headers)||r.total,a&&H(t.highWaterMark)?this.loadProgressively(d,r,e,t.highWaterMark,a):o?d.arrayBuffer():e.responseType==="json"?d.json():d.text()}).then(d=>{const f=this.response;if(!f)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first);const g=d[l];g&&(r.loaded=r.total=g);const h={url:f.url,data:d,code:f.status};a&&!H(t.highWaterMark)&&a(r,e,d,f),s.onSuccess(h,r,e,f)}).catch(d=>{if(self.clearTimeout(this.requestTimeout),r.aborted)return;const f=d&&d.code||0,g=d?d.message:null;s.onError({code:f,text:g},e,d?d.details:null,r)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,s,r=0,i){const a=new Jl,o=e.body.getReader(),l=()=>o.read().then(c=>{if(c.done)return a.dataLength&&i(t,s,a.flush(),e),Promise.resolve(new ArrayBuffer(0));const u=c.value,d=u.length;return t.loaded+=d,d<r||a.dataLength?(a.push(u),a.dataLength>=r&&i(t,s,a.flush(),e)):i(t,s,u,e),l()}).catch(()=>Promise.reject());return l()}}function Rg(n,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(ye({},n.headers))};return n.rangeEnd&&t.headers.set("Range","bytes="+n.rangeStart+"-"+String(n.rangeEnd-1)),t}function kg(n){const e=Ig.exec(n);if(e)return parseInt(e[2])-parseInt(e[1])+1}function Pg(n){const e=n.get("Content-Range");if(e){const s=kg(e);if(H(s))return s}const t=n.get("Content-Length");if(t)return parseInt(t)}function _g(n,e){return new self.Request(n.url,e)}class Og extends Error{constructor(e,t,s){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=s}}const Fg=/\s/,Mg={newCue(n,e,t,s){const r=[];let i,a,o,l,c;const u=self.VTTCue||self.TextTrackCue;for(let f=0;f<s.rows.length;f++)if(i=s.rows[f],o=!0,l=0,c="",!i.isEmpty()){var d;for(let m=0;m<i.chars.length;m++)Fg.test(i.chars[m].uchar)&&o?l++:(c+=i.chars[m].uchar,o=!1);i.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;const g=_c(c.trim()),h=Di(e,t,g);n!=null&&(d=n.cues)!=null&&d.getCueById(h)||(a=new u(e,t,g),a.id=h,a.line=f+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),r.push(a))}return n&&r.length&&(r.sort((f,g)=>f.line==="auto"||g.line==="auto"?0:f.line>8&&g.line>8?g.line-f.line:f.line-g.line),r.forEach(f=>Pl(n,f))),r}},Ng={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},tu=be(be({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Jc,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:up,bufferController:p1,capLevelController:_i,errorController:Q2,fpsController:G1,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:tl,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,certLoadPolicy:{default:Ng},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},Bg()),{},{subtitleStreamController:u1,subtitleTrackController:f1,timelineController:$1,audioStreamController:l1,audioTrackController:c1,emeController:Jt,cmcdController:Cg,contentSteeringController:Lg});function Bg(){return{cueHandler:Mg,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 Ug(n,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const t=Bi(n),s=["manifest","level","frag"],r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return s.forEach(i=>{const a=`${i==="level"?"playlist":i}LoadPolicy`,o=e[a]===void 0,l=[];r.forEach(c=>{const u=`${i}Loading${c}`,d=e[u];if(d!==void 0&&o){l.push(u);const f=t[a].default;switch(e[a]={default:f},c){case"TimeOut":f.maxLoadTimeMs=d,f.maxTimeToFirstByteMs=d;break;case"MaxRetry":f.errorRetry.maxNumRetry=d,f.timeoutRetry.maxNumRetry=d;break;case"RetryDelay":f.errorRetry.retryDelayMs=d,f.timeoutRetry.retryDelayMs=d;break;case"MaxRetryTimeout":f.errorRetry.maxRetryDelayMs=d,f.timeoutRetry.maxRetryDelayMs=d;break}}}),l.length&&L.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(e[a])}`)}),be(be({},t),e)}function Bi(n){return n&&typeof n=="object"?Array.isArray(n)?n.map(Bi):Object.keys(n).reduce((e,t)=>(e[t]=Bi(n[t]),e),{}):n}function $g(n){const e=n.loader;e!==eu&&e!==Jc?(L.log("[config]: Custom loader detected, cannot enable progressive streaming"),n.progressive=!1):Dg()&&(n.loader=eu,n.progressive=!0,n.enableSoftwareAES=!0,L.log("[config]: Progressive streaming enabled, using FetchLoader"))}let Ui;class Vg extends ci{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this),e.on(y.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this),e.off(y.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const s=this.hls.config.preferManagedMediaSource,r=[],i={},a={};let o=!1,l=!1,c=!1;t.levels.forEach(u=>{var d,f;const g=u.attrs;let{audioCodec:h,videoCodec:m}=u;((d=h)==null?void 0:d.indexOf("mp4a.40.34"))!==-1&&(Ui||(Ui=/chrome|firefox/i.test(navigator.userAgent)),Ui&&(u.audioCodec=h=void 0)),h&&(u.audioCodec=h=xn(h,s)),((f=m)==null?void 0:f.indexOf("avc1"))===0&&(m=u.videoCodec=A2(m));const{width:p,height:E,unknownCodecs:x}=u;if(o||(o=!!(p&&E)),l||(l=!!m),c||(c=!!h),x!=null&&x.length||h&&!Qr(h,"audio",s)||m&&!Qr(m,"video",s))return;const{CODECS:v,"FRAME-RATE":w,"HDCP-LEVEL":b,"PATHWAY-ID":I,RESOLUTION:A,"VIDEO-RANGE":F}=g,O=`${`${I||"."}-`}${u.bitrate}-${A}-${w}-${v}-${F}-${b}`;if(i[O])if(i[O].uri!==u.url&&!u.attrs["PATHWAY-ID"]){const B=a[O]+=1;u.attrs["PATHWAY-ID"]=new Array(B+1).join(".");const Y=new qt(u);i[O]=Y,r.push(Y)}else i[O].addGroupId("audio",g.AUDIO),i[O].addGroupId("text",g.SUBTITLES);else{const B=new qt(u);i[O]=B,a[O]=1,r.push(B)}}),this.filterAndSortMediaOptions(r,t,o,l,c)}filterAndSortMediaOptions(e,t,s,r,i){let a=[],o=[],l=e;if((s||r)&&i&&(l=l.filter(({videoCodec:h,videoRange:m,width:p,height:E})=>(!!h||!!(p&&E))&&$2(m))),l.length===0){Promise.resolve().then(()=>{if(this.hls){t.levels.length&&this.warn(`One or more CODECS in variant not supported: ${JSON.stringify(t.levels[0].attrs)}`);const h=new Error("no level with compatible codecs found in manifest");this.hls.trigger(y.ERROR,{type:Z.MEDIA_ERROR,details:k.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:h,reason:h.message})}});return}if(t.audioTracks){const{preferManagedMediaSource:h}=this.hls.config;a=t.audioTracks.filter(m=>!m.audioCodec||Qr(m.audioCodec,"audio",h)),su(a)}t.subtitles&&(o=t.subtitles,su(o));const c=l.slice(0);l.sort((h,m)=>{if(h.attrs["HDCP-LEVEL"]!==m.attrs["HDCP-LEVEL"])return(h.attrs["HDCP-LEVEL"]||"")>(m.attrs["HDCP-LEVEL"]||"")?1:-1;if(s&&h.height!==m.height)return h.height-m.height;if(h.frameRate!==m.frameRate)return h.frameRate-m.frameRate;if(h.videoRange!==m.videoRange)return Cn.indexOf(h.videoRange)-Cn.indexOf(m.videoRange);if(h.videoCodec!==m.videoCodec){const p=Sl(h.videoCodec),E=Sl(m.videoCodec);if(p!==E)return E-p}if(h.uri===m.uri&&h.codecSet!==m.codecSet){const p=Tn(h.codecSet),E=Tn(m.codecSet);if(p!==E)return E-p}return h.averageBitrate!==m.averageBitrate?h.averageBitrate-m.averageBitrate:0});let u=c[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==c.length)){for(let h=0;h<c.length;h++)if(c[h].pathwayId===l[0].pathwayId){u=c[h];break}}this._levels=l;for(let h=0;h<l.length;h++)if(l[h]===u){var d;this._firstLevel=h;const m=u.bitrate,p=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${m}`),((d=this.hls.userConfig)==null?void 0:d.abrEwmaDefaultEstimate)===void 0){const E=Math.min(m,this.hls.config.abrEwmaDefaultEstimateMax);E>p&&p===tu.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=E)}break}const f=i&&!r,g={levels:l,audioTracks:a,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:i,video:r,altAudio:!f&&a.some(h=>!!h.url)};this.hls.trigger(y.MANIFEST_PARSED,g),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){const u=new Error("invalid level idx"),d=e<0;if(this.hls.trigger(y.ERROR,{type:Z.OTHER_ERROR,details:k.LEVEL_SWITCH_ERROR,level:e,fatal:d,error:u,reason:u.message}),d)return;e=Math.min(e,t.length-1)}const s=this.currentLevelIndex,r=this.currentLevel,i=r?r.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,s===e&&a.details&&r&&i===o)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${o?" with Pathway "+o:""} from level ${s}${i?" with Pathway "+i:""}`);const l={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(y.LEVEL_SWITCHING,l);const c=a.details;if(!c||c.live){const u=this.switchParams(a.uri,r==null?void 0:r.details,c);this.loadPlaylist(u)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){const e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){t.fatal||!t.context||t.context.type===se.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===q.MAIN){const s=t.elementaryStreams;if(!Object.keys(s).some(i=>!!s[i]))return;const r=this._levels[t.level];r!=null&&r.loadError&&(this.log(`Resetting level error count of ${r.loadError} on frag buffered`),r.loadError=0)}}onLevelLoaded(e,t){var s;const{level:r,details:i}=t,a=this._levels[r];if(!a){var o;this.warn(`Invalid level index ${r}`),(o=t.deliveryDirectives)!=null&&o.skip&&(i.deltaUpdateFailed=!0);return}r===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0),this.playlistLoaded(r,t,a.details)):(s=t.deliveryDirectives)!=null&&s.skip&&(i.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist();const t=this.currentLevelIndex,s=this.currentLevel;if(s&&this.shouldLoadPlaylist(s)){let r=s.uri;if(e)try{r=e.addDirectives(r)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}const i=s.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${i?" Pathway "+i:""} ${r}`),this.clearTimer(),this.hls.trigger(y.LEVEL_LOADING,{url:r,level:t,pathwayId:s.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;const s=this._levels.filter((r,i)=>i!==e?!0:(this.steering&&this.steering.removeLevel(r),r===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,r.details&&r.details.fragments.forEach(a=>a.level=-1)),!1));Vl(s),this._levels=s,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(y.LEVELS_UPDATED,{levels:s})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:s}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(y.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:s}))}}function su(n){const e={};n.forEach(t=>{const s=t.groupId||"";t.id=e[s]=e[s]||0,e[s]++})}class Gg{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const s in this.keyUriToKeyInfo){const r=this.keyUriToKeyInfo[s].loader;if(r){var t;if(e&&e!==((t=r.context)==null?void 0:t.frag.type))return;r.abort()}}}detach(){for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=k.KEY_LOAD_ERROR,s,r,i){return new dt({type:Z.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:i,error:s,networkDetails:r})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){const{sn:s,cc:r}=e;for(let i=0;i<t.length;i++){const a=t[i];if(r<=a.cc&&(s==="initSegment"||a.sn==="initSegment"||s<a.sn)){this.emeController.selectKeySystemFormat(a).then(o=>{a.setKeyFormat(o)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var s,r;t&&e.setKeyFormat(t);const i=e.decryptdata;if(!i){const c=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,k.KEY_LOAD_ERROR,c))}const a=i.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,k.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if((s=o)!=null&&s.decryptdata.key)return i.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if((r=o)!=null&&r.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(c=>(i.key=c.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[a]={decryptdata:i,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},i.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return i.keyFormat==="identity"?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,k.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${i.method}"`)))}}loadKeyEME(e,t){const s={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const r=this.emeController.loadKey(s);if(r)return(e.keyLoadPromise=r.then(i=>(e.mediaKeySessionContext=i,s))).catch(i=>{throw e.keyLoadPromise=null,i})}return Promise.resolve(s)}loadKeyHTTP(e,t){const s=this.config,r=s.loader,i=new r(s);return t.keyLoader=e.loader=i,e.keyLoadPromise=new Promise((a,o)=>{const l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},c=s.keyLoadPolicy.default,u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(f,g,h,m)=>{const{frag:p,keyInfo:E,url:x}=h;if(!p.decryptdata||E!==this.keyUriToKeyInfo[x])return o(this.createKeyLoadError(p,k.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),m));E.decryptdata.key=p.decryptdata.key=new Uint8Array(f.data),p.keyLoader=null,E.loader=null,a({frag:p,keyInfo:E})},onError:(f,g,h,m)=>{this.resetLoader(g),o(this.createKeyLoadError(t,k.KEY_LOAD_ERROR,new Error(`HTTP Error ${f.code} loading key ${f.text}`),h,be({url:l.url,data:void 0},f)))},onTimeout:(f,g,h)=>{this.resetLoader(g),o(this.createKeyLoadError(t,k.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),h))},onAbort:(f,g,h)=>{this.resetLoader(g),o(this.createKeyLoadError(t,k.INTERNAL_ABORTED,new Error("key loading aborted"),h))}};i.load(l,u,d)})}resetLoader(e){const{frag:t,keyInfo:s,url:r}=e,i=s.loader;t.keyLoader===i&&(t.keyLoader=null,s.loader=null),delete this.keyUriToKeyInfo[r],i&&i.destroy()}}function nu(){return self.SourceBuffer||self.WebKitSourceBuffer}function ru(){if(!Ot())return!1;const e=nu();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function Hg(){if(!ru())return!1;const n=Ot();return typeof(n==null?void 0:n.isTypeSupported)=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>n.isTypeSupported(Ss(e,"video")))||["mp4a.40.2","fLaC"].some(e=>n.isTypeSupported(Ss(e,"audio"))))}function Kg(){var n;const e=nu();return typeof(e==null||(n=e.prototype)==null?void 0:n.changeType)=="function"}const Wg=250,Wn=2,jg=.1,zg=.05;class qg{constructor(e,t,s,r){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=s,this.hls=r}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){const{config:s,media:r,stalled:i}=this;if(r===null)return;const{currentTime:a,seeking:o}=r,l=this.seeking&&!o,c=!this.seeking&&o;if(this.seeking=o,a!==e){if(this.moved=!0,o||(this.nudgeRetry=0),i!==null){if(this.stallReported){const p=self.performance.now()-i;L.warn(`playback not stuck anymore @${a}, after ${Math.round(p)}ms`),this.stallReported=!1}this.stalled=null}return}if(c||l){this.stalled=null;return}if(r.paused&&!o||r.ended||r.playbackRate===0||!de.getBuffered(r).length){this.nudgeRetry=0;return}const u=de.bufferInfo(r,a,0),d=u.nextStart||0;if(o){const p=u.len>Wn,E=!d||t&&t.start<=a||d-a>Wn&&!this.fragmentTracker.getPartialFragment(a);if(p||E)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var f;if(!(u.len>0)&&!d)return;const E=Math.max(d,u.start||0)-a,x=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,w=(x==null||(f=x.details)==null?void 0:f.live)?x.details.targetduration*2:Wn,b=this.fragmentTracker.getPartialFragment(a);if(E>0&&(E<=w||b)){r.paused||this._trySkipBufferHole(b);return}}const g=self.performance.now();if(i===null){this.stalled=g;return}const h=g-i;if(!o&&h>=Wg&&(this._reportStall(u),!this.media))return;const m=de.bufferInfo(r,a,s.maxBufferHole);this._tryFixBufferStall(m,h)}_tryFixBufferStall(e,t){const{config:s,fragmentTracker:r,media:i}=this;if(i===null)return;const a=i.currentTime,o=r.getPartialFragment(a);o&&(this._trySkipBufferHole(o)||!this.media)||(e.len>s.maxBufferHole||e.nextStart&&e.nextStart-a<s.maxBufferHole)&&t>s.highBufferWatchdogPeriod*1e3&&(L.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){const{hls:t,media:s,stallReported:r}=this;if(!r&&s){this.stallReported=!0;const i=new Error(`Playback stalling at @${s.currentTime} due to low buffer (${JSON.stringify(e)})`);L.warn(i.message),t.trigger(y.ERROR,{type:Z.MEDIA_ERROR,details:k.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len})}}_trySkipBufferHole(e){const{config:t,hls:s,media:r}=this;if(r===null)return 0;const i=r.currentTime,a=de.bufferInfo(r,i,0),o=i<a.start?a.start:a.nextStart;if(o){const l=a.len<=t.maxBufferHole,c=a.len>0&&a.len<1&&r.readyState<3,u=o-i;if(u>0&&(l||c)){if(u>t.maxBufferHole){const{fragmentTracker:f}=this;let g=!1;if(i===0){const h=f.getAppendedFrag(0,q.MAIN);h&&o<h.end&&(g=!0)}if(!g){const h=e||f.getAppendedFrag(i,q.MAIN);if(h){let m=!1,p=h.end;for(;p<o;){const E=f.getPartialFragment(p);if(E)p+=E.duration;else{m=!0;break}}if(m)return 0}}}const d=Math.max(o+zg,i+jg);if(L.warn(`skipping hole, adjusting currentTime from ${i} to ${d}`),this.moved=!0,this.stalled=null,r.currentTime=d,e&&!e.gap){const f=new Error(`fragment loaded with buffer holes, seeking from ${i} to ${d}`);s.trigger(y.ERROR,{type:Z.MEDIA_ERROR,details:k.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:f,reason:f.message,frag:e})}return d}}return 0}_tryNudgeBuffer(){const{config:e,hls:t,media:s,nudgeRetry:r}=this;if(s===null)return;const i=s.currentTime;if(this.nudgeRetry++,r<e.nudgeMaxRetry){const a=i+(r+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${i} to ${a}`);L.warn(o.message),s.currentTime=a,t.trigger(y.ERROR,{type:Z.MEDIA_ERROR,details:k.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{const a=new Error(`Playhead still not moving while enough data buffered @${i} after ${e.nudgeMaxRetry} nudges`);L.error(a.message),t.trigger(y.ERROR,{type:Z.MEDIA_ERROR,details:k.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}}const Yg=100;class Xg extends fi{constructor(e,t,s){super(e,t,s,"[stream-controller]",q.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(y.ERROR,this.onError,this),e.on(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(y.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(y.BUFFER_CREATED,this.onBufferCreated,this),e.on(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(y.ERROR,this.onError,this),e.off(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(y.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(y.BUFFER_CREATED,this.onBufferCreated,this),e.off(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying()}startLoad(e){if(this.levels){const{lastCurrentTime:t,hls:s}=this;if(this.stopLoad(),this.setInterval(Yg),this.level=-1,!this.startFragRequested){let r=s.startLevel;r===-1&&(s.config.testBandwidth&&this.levels.length>1?(r=0,this.bitrateTest=!0):r=s.firstAutoLevel),s.nextLoadLevel=r,this.level=s.loadLevel,this.loadedmetadata=!1}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=M.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=M.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case M.WAITING_LEVEL:{const{levels:t,level:s}=this,r=t==null?void 0:t[s],i=r==null?void 0:r.details;if(i&&(!i.live||this.levelLastLoaded===r)){if(this.waitForCdnTuneIn(i))break;this.state=M.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=M.IDLE;break}break}case M.FRAG_LOADING_WAITING_RETRY:{var e;const t=self.performance.now(),s=this.retryDate;if(!s||t>=s||(e=this.media)!=null&&e.seeking){const{levels:r,level:i}=this,a=r==null?void 0:r[i];this.resetStartWhenNotLoaded(a||null),this.state=M.IDLE}}break}this.state===M.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:s,media:r}=this;if(t===null||!r&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;const i=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(s!=null&&s[i]))return;const a=s[i],o=this.getMainFwdBufferInfo();if(o===null)return;const l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){const m={};this.altAudio&&(m.type="video"),this.hls.trigger(y.BUFFER_EOS,m),this.state=M.ENDED;return}if(!this.buffering)return;e.loadLevel!==i&&e.manualLevel===-1&&this.log(`Adapting to level ${i} from level ${this.level}`),this.level=e.nextLoadLevel=i;const c=a.details;if(!c||this.state===M.WAITING_LEVEL||c.live&&this.levelLastLoaded!==a){this.level=i,this.state=M.WAITING_LEVEL;return}const u=o.len,d=this.getMaxBufferLength(a.maxBitrate);if(u>=d)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);const f=this.backtrackFragment?this.backtrackFragment.start:o.end;let g=this.getNextFragment(f,c);if(this.couldBacktrack&&!this.fragPrevious&&g&&g.sn!=="initSegment"&&this.fragmentTracker.getState(g)!==Ce.OK){var h;const p=((h=this.backtrackFragment)!=null?h:g).sn-c.startSN,E=c.fragments[p-1];E&&g.cc===E.cc&&(g=E,this.fragmentTracker.removeFragment(E))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(g&&this.isLoopLoading(g,f)){if(!g.gap){const p=this.audioOnly&&!this.altAudio?le.AUDIO:le.VIDEO,E=(p===le.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;E&&this.afterBufferFlushed(E,p,q.MAIN)}g=this.getNextFragmentLoopLoading(g,c,o,q.MAIN,d)}g&&(g.initSegment&&!g.initSegment.data&&!this.bitrateTest&&(g=g.initSegment),this.loadFragment(g,a,f))}loadFragment(e,t,s){const r=this.fragmentTracker.getState(e);this.fragCurrent=e,r===Ce.NOT_LOADED||r===Ce.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,s)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,q.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(t!=null&&t.readyState){let s;const r=this.getAppendedFrag(t.currentTime);r&&r.start>1&&this.flushMainBuffer(0,r.start-1);const i=this.getLevelDetails();if(i!=null&&i.live){const o=this.getMainFwdBufferInfo();if(!o||o.len<i.targetduration*2)return}if(!t.paused&&e){const o=this.hls.nextLoadLevel,l=e[o],c=this.fragLastKbps;c&&this.fragCurrent?s=this.fragCurrent.duration*l.maxBitrate/(1e3*c)+1:s=0}else s=0;const a=this.getBufferedFrag(t.currentTime+s);if(a){const o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();const l=o.maxStartPTS?o.maxStartPTS:o.start,c=o.duration,u=Math.max(a.end,l+Math.min(Math.max(c-this.config.maxFragLookUpTolerance,c*(this.couldBacktrack?.5:.125)),c*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(u,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case M.KEY_LOADING:case M.FRAG_LOADING:case M.FRAG_LOADING_WAITING_RETRY:case M.PARSING:case M.PARSED:this.state=M.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const s=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),s.addEventListener("playing",this.onvplaying),s.addEventListener("seeked",this.onvseeked),this.gapController=new qg(this.config,s,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const e=this.media,t=e?e.currentTime:null;H(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);const s=this.getMainFwdBufferInfo();if(s===null||s.len===0){this.warn(`Main forward buffer length on "seeked" event ${s?s.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(y.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1}onManifestParsed(e,t){let s=!1,r=!1;t.levels.forEach(i=>{const a=i.audioCodec;a&&(s=s||a.indexOf("mp4a.40.2")!==-1,r=r||a.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=s&&r&&!Kg(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:s}=this;if(!s||this.state!==M.IDLE)return;const r=s[t.level];(!r.details||r.details.live&&this.levelLastLoaded!==r||this.waitForCdnTuneIn(r.details))&&(this.state=M.WAITING_LEVEL)}onLevelLoaded(e,t){var s;const{levels:r}=this,i=t.level,a=t.details,o=a.totalduration;if(!r){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:${o}`);const l=r[i],c=this.fragCurrent;c&&(this.state===M.FRAG_LOADING||this.state===M.FRAG_LOADING_WAITING_RETRY)&&c.level!==t.level&&c.loader&&this.abortCurrentFrag();let u=0;if(a.live||(s=l.details)!=null&&s.live){var d;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;u=this.alignPlaylists(a,l.details,(d=this.levelLastLoaded)==null?void 0:d.details)}if(l.details=a,this.levelLastLoaded=l,this.hls.trigger(y.LEVEL_UPDATED,{details:a,level:i}),this.state===M.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=M.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,u),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:s,part:r,payload:i}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${s.sn} of level ${s.level} will not be buffered`);return}const o=a[s.level],l=o.details;if(!l){this.warn(`Dropping fragment ${s.sn} of level ${s.level} after level details were reset`),this.fragmentTracker.removeFragment(s);return}const c=o.videoCodec,u=l.PTSKnown||!l.live,d=(t=s.initSegment)==null?void 0:t.data,f=this._getAudioCodec(o),g=this.transmuxer=this.transmuxer||new xc(this.hls,q.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),h=r?r.index:-1,m=h!==-1,p=new ui(s.level,s.sn,s.stats.chunkCount,i.byteLength,h,m),E=this.initPTS[s.cc];g.push(i,d,f,c,s,r,l.totalduration,u,p,E)}onAudioTrackSwitching(e,t){const s=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const i=this.hls;s&&(i.trigger(y.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),i.trigger(y.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const s=t.id,r=!!this.hls.audioTracks[s].url;if(r){const i=this.videoBuffer;i&&this.mediaBuffer!==i&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=r,this.tick()}onBufferCreated(e,t){const s=t.tracks;let r,i,a=!1;for(const o in s){const l=s[o];if(l.id==="main"){if(i=o,r=l,o==="video"){const c=s[o];c&&(this.videoBuffer=c.buffer)}}else a=!0}a&&r?(this.log(`Alternate track found, use ${i}.buffered to schedule main fragment loading`),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:s,part:r}=t;if(s&&s.type!==q.MAIN)return;if(this.fragContextChanged(s)){this.warn(`Fragment ${s.sn}${r?" p: "+r.index:""} of level ${s.level} finished buffering, but was aborted. state: ${this.state}`),this.state===M.PARSED&&(this.state=M.IDLE);return}const i=r?r.stats:s.stats;this.fragLastKbps=Math.round(8*i.total/(i.buffering.end-i.loading.first)),s.sn!=="initSegment"&&(this.fragPrevious=s),this.fragBufferedComplete(s,r)}onError(e,t){var s;if(t.fatal){this.state=M.ERROR;return}switch(t.details){case k.FRAG_GAP:case k.FRAG_PARSING_ERROR:case k.FRAG_DECRYPT_ERROR:case k.FRAG_LOAD_ERROR:case k.FRAG_LOAD_TIMEOUT:case k.KEY_LOAD_ERROR:case k.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(q.MAIN,t);break;case k.LEVEL_LOAD_ERROR:case k.LEVEL_LOAD_TIMEOUT:case k.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===M.WAITING_LEVEL&&((s=t.context)==null?void 0:s.type)===se.LEVEL&&(this.state=M.IDLE);break;case k.BUFFER_APPEND_ERROR:case k.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;if(t.details===k.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case k.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){const{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!de.getBuffered(e).length){const s=this.state!==M.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,s)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=M.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==le.AUDIO||this.audioOnly&&!this.altAudio){const s=(t===le.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(s,t,q.MAIN),this.tick()}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let s=this.startPosition;if(s>=0&&t<s){if(e.seeking){this.log(`could not seek to ${s}, already seeking at ${t}`);return}const r=de.getBuffered(e),a=(r.length?r.start(0):0)-s;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${a} to match buffer start`),s+=a,this.startPosition=s),this.log(`seek to target start position ${s} from current time ${t}`),e.currentTime=s}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(s=>{const{hls:r}=this;if(!s||this.fragContextChanged(e))return;t.fragmentError=0,this.state=M.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const i=e.stats;i.parsing.start=i.parsing.end=i.buffering.start=i.buffering.end=self.performance.now(),r.trigger(y.FRAG_LOADED,s),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;const s="main",{hls:r}=this,{remuxResult:i,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}const{frag:l,part:c,level:u}=o,{video:d,text:f,id3:g,initSegment:h}=i,{details:m}=u,p=this.altAudio?void 0:i.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=M.PARSING,h){if(h!=null&&h.tracks){const v=l.initSegment||l;this._bufferInitSegment(u,h.tracks,v,a),r.trigger(y.FRAG_PARSING_INIT_SEGMENT,{frag:v,id:s,tracks:h.tracks})}const E=h.initPTS,x=h.timescale;H(E)&&(this.initPTS[l.cc]={baseTime:E,timescale:x},r.trigger(y.INIT_PTS_FOUND,{frag:l,id:s,initPTS:E,timescale:x}))}if(d&&m&&l.sn!=="initSegment"){const E=m.fragments[l.sn-1-m.startSN],x=l.sn===m.startSN,v=!E||l.cc>E.cc;if(i.independent!==!1){const{startPTS:w,endPTS:b,startDTS:I,endDTS:A}=d;if(c)c.elementaryStreams[d.type]={startPTS:w,endPTS:b,startDTS:I,endDTS:A};else if(d.firstKeyFrame&&d.independent&&a.id===1&&!v&&(this.couldBacktrack=!0),d.dropped&&d.independent){const F=this.getMainFwdBufferInfo(),U=(F?F.end:this.getLoadPosition())+this.config.maxBufferHole,O=d.firstKeyFramePTS?d.firstKeyFramePTS:w;if(!x&&U<O-this.config.maxBufferHole&&!v){this.backtrack(l);return}else v&&(l.gap=!0);l.setElementaryStreamInfo(d.type,l.start,b,l.start,A,!0)}else x&&w>Wn&&(l.gap=!0);l.setElementaryStreamInfo(d.type,w,b,I,A),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(d,l,c,a,x||v)}else if(x||v)l.gap=!0;else{this.backtrack(l);return}}if(p){const{startPTS:E,endPTS:x,startDTS:v,endDTS:w}=p;c&&(c.elementaryStreams[le.AUDIO]={startPTS:E,endPTS:x,startDTS:v,endDTS:w}),l.setElementaryStreamInfo(le.AUDIO,E,x,v,w),this.bufferFragmentData(p,l,c,a)}if(m&&g!=null&&(t=g.samples)!=null&&t.length){const E={id:s,frag:l,details:m,samples:g.samples};r.trigger(y.FRAG_PARSING_METADATA,E)}if(m&&f){const E={id:s,frag:l,details:m,samples:f.samples};r.trigger(y.FRAG_PARSING_USERDATA,E)}}_bufferInitSegment(e,t,s,r){if(this.state!==M.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;const{audio:i,video:a,audiovideo:o}=t;if(i){let l=e.audioCodec;const c=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5");const u=i.metadata;u&&"channelCount"in u&&(u.channelCount||1)!==1&&c.indexOf("firefox")===-1&&(l="mp4a.40.5")}l&&l.indexOf("mp4a.40.5")!==-1&&c.indexOf("android")!==-1&&i.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),i.levelCodec=l,i.id="main",this.log(`Init audio buffer, container:${i.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${i.codec}]`)}a&&(a.levelCodec=e.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),this.hls.trigger(y.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{const u=t[l].initSegment;u!=null&&u.byteLength&&this.hls.trigger(y.BUFFER_APPENDING,{type:l,data:u,frag:s,part:null,chunkMeta:r,parent:s.type})}),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,q.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=M.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const s=e.currentTime;if(de.isBuffered(e,s)?t=this.getAppendedFrag(s):de.isBuffered(e,s+.1)&&(t=this.getAppendedFrag(s+.1)),t){this.backtrackFragment=null;const r=this.fragPlaying,i=t.level;(!r||t.sn!==r.sn||r.level!==i)&&(this.fragPlaying=t,this.hls.trigger(y.FRAG_CHANGED,{frag:t}),(!r||r.level!==i)&&this.hls.trigger(y.LEVEL_SWITCHED,{level:i}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){const e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){const e=this.media;if(e){const t=e.currentTime,s=this.currentFrag;if(s&&H(t)&&H(s.programDateTime)){const r=s.programDateTime+(t-s.start)*1e3;return new Date(r)}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class he{static get version(){return"1.5.20"}static isMSESupported(){return ru()}static isSupported(){return Hg()}static getMediaSource(){return Ot()}static get Events(){return y}static get ErrorTypes(){return Z}static get ErrorDetails(){return k}static get DefaultConfig(){return he.defaultConfig?he.defaultConfig:tu}static set DefaultConfig(e){he.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new xi,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,Bh(e.debug||!1,"Hls instance");const t=this.config=Ug(he.DefaultConfig,e);this.userConfig=e,t.progressive&&$g(t);const{abrController:s,bufferController:r,capLevelController:i,errorController:a,fpsController:o}=t,l=new a(this),c=this.abrController=new s(this),u=this.bufferController=new r(this),d=this.capLevelController=new i(this),f=new o(this),g=new P2(this),h=new N2(this),m=t.contentSteeringController,p=m?new m(this):null,E=this.levelController=new Vg(this,p),x=new fp(this),v=new Gg(this.config),w=this.streamController=new Xg(this,x,v);d.setStreamController(w),f.setStreamController(w);const b=[g,E,w];p&&b.splice(1,0,p),this.networkControllers=b;const I=[c,u,d,f,h,x];this.audioTrackController=this.createController(t.audioTrackController,b);const A=t.audioStreamController;A&&b.push(new A(this,x,v)),this.subtitleTrackController=this.createController(t.subtitleTrackController,b);const F=t.subtitleStreamController;F&&b.push(new F(this,x,v)),this.createController(t.timelineController,I),v.emeController=this.emeController=this.createController(t.emeController,I),this.cmcdController=this.createController(t.cmcdController,I),this.latencyController=this.createController(B2,I),this.coreComponents=I,b.push(l);const U=l.onErrorOut;typeof U=="function"&&this.on(y.ERROR,U,l)}createController(e,t){if(e){const s=new e(this);return t&&t.push(s),s}return null}on(e,t,s=this){this._emitter.on(e,t,s)}once(e,t,s=this){this._emitter.once(e,t,s)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,s=this,r){this._emitter.off(e,t,s,r)}listeners(e){return this._emitter.listeners(e)}emit(e,t,s){return this._emitter.emit(e,t,s)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(s){if(L.error("An internal error happened while handling event "+e+'. Error message: "'+s.message+'". Here is a stacktrace:',s),!this.triggeringException){this.triggeringException=!0;const r=e===y.ERROR;this.trigger(y.ERROR,{type:Z.OTHER_ERROR,details:k.INTERNAL_EXCEPTION,fatal:r,event:e,error:s}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){L.log("destroy"),this.trigger(y.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){L.log("attachMedia"),this._media=e,this.trigger(y.MEDIA_ATTACHING,{media:e})}detachMedia(){L.log("detachMedia"),this.trigger(y.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();const t=this.media,s=this.url,r=this.url=Br.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,L.log(`loadSource:${r}`),t&&s&&(s!==r||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(y.MANIFEST_LOADING,{url:e})}startLoad(e=-1){L.log(`startLoad(${e})`),this.started=!0,this.resumeBuffering();for(let t=0;t<this.networkControllers.length&&(this.networkControllers[t].startLoad(e),!(!this.started||!this.networkControllers));t++);}stopLoad(){L.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!(this.started||!this.networkControllers));e++);}resumeBuffering(){L.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()})}pauseBuffering(){L.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()})}swapAudioCodec(){L.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){L.log("recoverMediaError");const e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e){this.levelController.removeLevel(e)}get levels(){const e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){L.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){L.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){L.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){L.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){L.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(L.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){U2(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const s=e.length;for(let r=0;r<s;r++)if(e[r].maxBitrate>=t)return r;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:s}=this;let r;if(t===-1&&e!=null&&e.length?r=e.length-1:r=t,s)for(let i=r;i--;){const a=e[i].attrs["HDCP-LEVEL"];if(a&&a<=s)return i}return r}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}setAudioOption(e){var t;return(t=this.audioTrackController)==null?void 0:t.setAudioOption(e)}setSubtitleOption(e){var t;return(t=this.subtitleTrackController)==null||t.setSubtitleOption(e),null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}he.defaultConfig=void 0;const jn=n=>{n.preventDefault();let e=(N()||Ge()).error;if(e)switch(e.code){case e.MEDIA_ERR_ABORTED:ct({type:"videoTagError",message:"You aborted the video playback."});break;case e.MEDIA_ERR_NETWORK:ct({type:"videoTagError",message:"A network error caused the video download to fail part-way."});break;case e.MEDIA_ERR_DECODE:ct({type:"videoTagError",message:"The video playback was aborted due to a corruption problem or because the video used features your browser did not support."});break;case e.MEDIA_ERR_SRC_NOT_SUPPORTED:ct({type:"videoTagError",message:"The video could not be loaded, either because the server or network failed or because the format is not supported."});break;default:ct({type:"videoTagError",message:"An unknown error occurred."});break}else ct({type:"videoTagError",message:"An error occurred, but the error object is not available."})},iu=()=>{const n=R.dispatch,{params:e}=R.getState().videoData,t=s=>{s.requestFullScreen?s.requestFullScreen():s.mozRequestFullScreen?s.mozRequestFullScreen():s.webkitRequestFullScreen&&s.webkitRequestFullScreen()};n(Ws()),t(document.documentElement),n(is(e.fullscreen==="true"))},au=()=>{let n=".ts",e=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(){arguments[1].endsWith(n)&&(arguments[1]=arguments[1]+"?uuid="+lt()),e.apply(this,arguments)}},Zg=(n,e)=>{const t=R.dispatch;e.current=setInterval(()=>{const r=n.target.buffered.end(0)/N().duration*100;t(_a(r))},500)},Qg=()=>{const n=za("mainPlayer");return{xhrSetup:(e,t)=>{t.split("m3u8")[1]||(t=`${t}${n}`),e.open("GET",t,!0)},startLevel:-1,debug:!1,enableWorker:!0,abrBandWidthUpFactor:.7,abrBandWidthFactor:.95,backBufferLength:1/0,maxBufferLength:30,maxMaxBufferLength:60,manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:10,retryDelayMs:5e3,maxRetryDelayMs:1e4},errorRetry:{maxNumRetry:10,retryDelayMs:5e3,maxRetryDelayMs:1e4}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:10,retryDelayMs:5e3,maxRetryDelayMs:1e4},errorRetry:{maxNumRetry:10,retryDelayMs:5e3,maxRetryDelayMs:1e4}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:10,retryDelayMs:5e3,maxRetryDelayMs:1e4},errorRetry:{maxNumRetry:10,retryDelayMs:5e3,maxRetryDelayMs:1e4}}}}},Jg=()=>{const n=za("miniPlayer");return{xhrSetup:(e,t)=>{t=`${t}${n}`,e.open("GET",t,!0)},startLevel:1,debug:!1,maxMaxBufferLength:60,playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1e3,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1e3,retryDelayMs:1e3,maxRetryDelayMs:1e3}}}}},ou=n=>{const e=R.dispatch;let t=[],s=[];n.levels.map(r=>{t.push(r.attrs.RESOLUTION.split("x")[1].trim()),s.push(r.attrs.RESOLUTION)}),n.autoLevelCapping=Za(s,window.innerWidth,window.innerHeight),e(l0(t)),["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","msfullscreenchange"].forEach(r=>document.addEventListener(r,()=>{C(T.isAutoQuality)&&(n.autoLevelCapping=Za(s,window.innerWidth,window.innerHeight),n.nextLevel=-1)},!1))},lu=(n,e)=>{const{details:t}=R.getState().videoData;let s=t.stream_link;e.loadSource(s),e.on(n.Events.MANIFEST_PARSED,()=>ou(e))},cu=(n,e,t)=>{if(e.frag.type!=="audio"){const s=R.dispatch,{settings:r}=R.getState().user,{qualityLevels:i,manualQuality:a,autoQuality:o}=R.getState().controller;C(T.isAutoQuality)?C(T.isAutoQuality)&&o===void 0?(n.nextLevel=-1,t(i[e.frag.level]),s(Us(e.frag.level))):C(T.isAutoQuality)&&(t(i[e.frag.level]),o!==e.frag.level&&s(Us(e.frag.level))):(e.frag.level!==a&&(n.nextLevel=i[r.quality]?r.quality:-1),i[r.quality]?(s(c0(r.quality)),s(Us(void 0))):(t(i[e.frag.level]),s(Us(e.frag.level)),s(ot({...r,quality:-1}))))}},uu=n=>{var r;const e=R.dispatch,s=((r=n.mainForwardBufferInfo)==null?void 0:r.end)/N().duration*100;e(_a(s))},du=(n,e,t)=>{const{params:s}=R.getState().videoData;s.type&&cu(n,e,t)},fu=(n,e,t)=>{const{type:s}=R.getState().videoData.params;s&&cu(n,e,t)},hu=n=>{if(n.event!=="hlsAudioTrackLoading")return{type:"HLS_"+n.type,message:n.error.message}},pu=(n,e)=>{const t=R.dispatch;n.preventDefault(),e.current=Date.now(),t(Gt(!0))},em=(n,e)=>{const t=R.dispatch;n.preventDefault(),e.current=0,t(Gt(!0))},tm=(n,e)=>{const t=R.dispatch,{videoSettings:s}=R.getState().user,{params:r}=R.getState().videoData;n.preventDefault(),e.current=Date.now(),t(Ze(!0)),C(T.hasOnPlayParams)&&r.onPlay(),C(T.isFirstPlay)&&(C(T.hasCurrentTimeParams)||(N().currentTime=s.time,t(Vt(s.time))),C(T.hasFullScreenParams)&&iu(),C(T.isFullScreen)&&Nr(),t($s([Math.floor(N().currentTime)]))),oe(Ho(!0)),t(as(""))},sm=(n,e,t,s,r,i,a,o)=>{const l=R.dispatch,{autoQuality:c,canPlayVideo:u,firstPlay:d,qualityLevels:f}=R.getState().controller,{settings:g}=R.getState().user,h=g.quality===-1&&c?f[c]:f[g.quality];let m=0;a.current&&(m=Date.now()-a.current),d&&N().played&&oe(Ko(e.current,Date.now()-t.current,s.current-t.current,Date.now()-r.current,r)),l(hr(!1)),u&&m>0&&h!==void 0&&(i.current=m,a.current=0,oe(mh(m,h,r,n,o.current)),n.current=n.current+1,r.current=Date.now())},gu=n=>{const e=R.dispatch,{params:t}=R.getState().videoData;n.preventDefault(),oe(Ho(!1)),e(Ze(!1)),C(T.hasOnPauseParams)&&t.onPause()},nm=n=>{const e=R.dispatch,{selectedSubtitle:t}=R.getState().videoData;n.preventDefault(),e(Vt(n.target.currentTime)),C(T.hasActiveCue)&&e(as(t.activeCues[0].text))},mu=n=>{const e=R.dispatch,{settings:t}=R.getState().user;if(n.preventDefault(),e(Gt(!1)),e(Fa(!0)),N().volume=t.volume/100,e(Pa(n.target.duration)),C(T.isIOS)){const s=Object.values(n.target.textTracks);s&&s.length&&e(Vs(Object.values(s[0]).length?s:[]))}else e(Vs(Object.values(n.target.textTracks)))},rm=n=>{const e=R.dispatch,{params:t}=R.getState().videoData;n.preventDefault(),e(gr(!0)),e(Se(!0)),ps(N().duration),C(T.hasOnFinishedParams)&&t.onFinished()},im=(n,e)=>{const t=R.dispatch;n.preventDefault(),e.current=Date.now(),t(hr(!1))},am=()=>{const n=R.dispatch;n(Gt(!1))},om=n=>{const e=R.dispatch;n.preventDefault(),e(Vt(n.target.currentTime))},lm=()=>{const n=R.dispatch,{params:e}=R.getState().videoData;n(gr(!0)),n(Se(!0)),C(T.hasOnFinishedParams)&&e.onFinished()},cm=n=>{const e=R.dispatch;n.preventDefault(),e(Ze(!1))},um=(n,e)=>{const t=R.dispatch;n.preventDefault(),t(Ze(!0)),e.current=Date.now(),t(as("")),C(T.isFirstPlay)&&C(T.hasFullScreenParams)&&(iu(),C(T.isFullScreen)&&Nr())},dm=(n,e,t)=>{const s=R.dispatch,{firstPlay:r}=R.getState().controller;s(Gt(!1)),r&&N().played&&oe(Ko(Math.round(n.current),Date.now()-e.current,0,Date.now()-t.current,t)),s(hr(!1))},fm=n=>{const e=R.dispatch,{selectedSubtitle:t}=R.getState().videoData;n.preventDefault(),e(Vt(n.target.currentTime)),e(Pa(n.target.duration)),C(T.hasActiveCue)&&e(as(t.activeCues[0].text))},hm=n=>{const e=R.dispatch;if(n.preventDefault(),e(Gt(!1)),e(Fa(!0)),C(T.isIOS)){const t=Object.values(n.target.textTracks);t&&t.length&&e(Vs(Object.values(t[0]).length?t:[]))}else e(Vs(Object.values(n.target.textTracks)))},pm=(n,e)=>{n.preventDefault(),Zg(n,e)},yu=async n=>{const{stream_link:e}=R.getState().miniPlayer.details;n.loadSource(e)},Eu=()=>{ps(N().currentTime)},gm=()=>{const n=ve(),e=V(s=>s.miniPlayer.details),t=V(s=>s.miniPlayer.params);return P.useEffect(()=>{let s=new he(Jg());return he.isSupported()?(s.attachMedia(document.getElementById("mini-player-video-tag")),s.on(he.Events.MEDIA_ATTACHED,()=>yu(s))):N().canPlayType("application/vnd.apple.mpegurl")&&(N().src=e.stream_link,au()),()=>{n(C0()),s.detachMedia(),s.off(he.Events.MEDIA_ATTACHED,()=>yu(s))}},[]),P.useEffect(()=>{t.currentTime&&(n(mt(!0)),Ge().currentTime=t.currentTime,n(Ze(!1)),N().pause())},[t.currentTime]),S.jsx(S.Fragment,{children:S.jsx("video",{onPlay:()=>n(mt(!0)),onEnded:()=>n(mt(!1)),onError:jn,poster:t.banner?t.banner:e.banner,id:"mini-player-video-tag",className:"pl-absolute pl-h-full pl-w-full pl-bg-black",autoPlay:!0,muted:!0})})},mm=()=>{const n=ve(),e=V(t=>t.miniPlayer.params);return P.useEffect(()=>{e.currentTime&&(n(mt(!0)),Ge().currentTime=e.currentTime,n(Ze(!1)),N().pause())},[e.currentTime]),S.jsx("video",{poster:e.banner,onPlay:()=>n(mt(!0)),onEnded:()=>n(mt(!1)),onError:jn,src:e.id,id:"mini-player-video-tag",className:"pl-absolute pl-h-full pl-w-full pl-bg-black",autoPlay:!0})},ym=()=>{const n=V(e=>e.miniPlayer.params.type);return S.jsx(S.Fragment,{children:n===xt.static?S.jsx(mm,{}):S.jsx(gm,{})})},Em=({params:n})=>{const e=ve(),t=V(a=>a.miniPlayer.details),s=V(a=>a.miniPlayer.params);V(a=>a.miniPlayer.play);const r=V(a=>a.videoData.params);P.useEffect(()=>{e(v0(n))},[]);const i=async()=>await qo(n.id);return P.useEffect(()=>{n.id&&n.type==="vod"&&i()},[n.id]),S.jsx(S.Fragment,{children:t.stream_link||s.type==="static"&&s.id?S.jsxs("div",{id:"miniPlayer-video-area",style:{zIndex:_e.miniPlayer},className:"pl-relative pl-h-full pl-w-full",children:[S.jsx("div",{className:`pl-absolute pl-right-3 pl-top-3 pl-z-[1000000] pl-cursor-pointer ${C(T.isActiveElements)?"animate__fadeIn pl-pointer-events-auto":"animate__fadeOut pl-pointer-events-none"}`,onClick:()=>{r.id===s.id&&(N().currentTime=Ge().currentTime,e(Vt(Ge().currentTime))),localStorage.setItem("close-miniPlayer","true"),n.onClose()},children:S.jsx("img",{className:"pl-size-4 pl-cursor-pointer",src:re.closeSquare,alt:"close-square"})}),S.jsx("div",{className:`animate__animated animate__faster pl-absolute pl-bottom-0 pl-z-[1000000] pl-w-full ${C(T.isActiveElements)&&!C(T.isLoading)?"animate__fadeIn pl-pointer-events-auto":"animate__fadeOut pl-pointer-events-none"}`,children:S.jsx("div",{className:"pl-flex pl-w-full pl-justify-center",children:S.jsx(Ih,{})})}),S.jsx(ym,{})]}):S.jsx("div",{className:"pl-h-full pl-w-full pl-bg-white"})})},Sm=({params:n})=>S.jsx(Yi,{store:R,children:S.jsx(Yo,{children:S.jsx(Em,{params:n})})}),Tm=()=>{const{details:n,params:e}=V(({videoData:{details:t,params:s}})=>({details:t,params:s}),K);return S.jsx("div",{className:`animate__animated animate__faster pl-ml-4 pl-w-full pl-max-w-[80%] pl-self-start pl-truncate pl-break-words pl-text-left pl-text-[16px] pl-font-normal pl-text-white ${C(T.isActiveElements)?"animate__fadeIn pl-opacity-100":"animate__fadeOut pl-opacity-0"}`,children:C(T.hasTitle)?n.title:e.id})},xm=()=>S.jsxs("div",{className:`animate__animated animate__faster pl-relative ${C(T.isActiveElements)?"animate__fadeIn pl-pointer-events-auto":"animate__fadeOut pl-pointer-events-none"}`,children:[S.jsx("img",{src:re.lock,alt:"lock-icon",width:20,height:20,onClick:()=>jo("unlock")}),!localStorage.getItem("unlock-click")&&S.jsx("p",{className:"pl-absolute pl-left-0 pl-w-max pl-rounded-[8px] pl-bg-[#F7F7F7] pl-px-4 pl-py-3 pl-text-[10px] pl-text-black/[0.87]",children:xe("clickToUnlock")})]}),vm=()=>(V(({controller:{lock:n,activeElements:e}})=>({lock:n,activeElements:e}),K),S.jsxs("div",{className:`pl-mx-4 pl-mt-5 pl-flex pl-items-start pl-justify-end ${C(T.isTouchScreenPortrait)?"pl-h-4":"pl-h-[60px]"}`,children:[C(T.showTitle)&&S.jsx(Tm,{}),C(T.isLock)&&S.jsx(xm,{})]}));function bm(n,e=300,t={}){const s=P.useRef(null),r=P.useCallback(i=>{s.current?(clearTimeout(s.current),s.current=null,n&&n(i)):s.current=setTimeout(()=>{t.onSingleTap&&t.onSingleTap(i),s.current=null},e)},[n,e,t.onSingleTap]);return n?{onClick:r}:{}}const Su=1e3,$i=({type:n,isRightDoubleTouched:e,isLeftDoubleTouched:t,setIsRightDoubleTouched:s,setIsLeftDoubleTouched:r})=>{const[i,a]=P.useState(15),[o,l]=P.useState(!1),c=P.useRef(i),u=ve(),{duration:d}=V(({controller:{currentTime:E,duration:x}})=>({currentTime:E,duration:x}),K),{videoElementSizeInfo:f}=V(({videoData:{videoElementSizeInfo:E,params:x}})=>({videoElementSizeInfo:E,params:x}),K),g=P.useRef(null);P.useEffect(()=>{c.current=i},[i]);let h;h=bm(E=>{["touchBackward","touchForward"].includes(n)&&(E.stopPropagation(),n==="touchBackward"&&r?r(!0):n==="touchForward"&&s&&s(!0),clearTimeout(g.current),g.current=setTimeout(()=>l(!0),Su))},200),P.useEffect(()=>{o&&(l(!1),u(Se(!1)),e&&s?(s(!1),N().duration-N().currentTime<=c.current?Rt(n,N().duration):Rt(n,c.current),a(15)):t&&r&&(r(!1),N().currentTime<=c.current?Rt(n,0):Rt(n,c.current),a(15)))},[o]);const m=E=>{a(x=>x+15),C(T.isTouchScreenLandscape)&&R0(E,n),clearTimeout(g.current),g.current=setTimeout(()=>l(!0),Su)};let p;return["backward","forward"].includes(n)?p=S.jsx("div",{className:`${C(T.isTouchScreen)?"pl-flex pl-size-8 pl-items-center pl-justify-center pl-rounded-full pl-bg-black/50":"hover:pl-scale-125"} pl-cursor-pointer pl-transition-transform pl-ease-in-out ${n==="backward"&&(N().currentTime>=15?"pl-opacity-100":"pl-cursor-default pl-opacity-30 hover:pl-scale-100")} ${n==="forward"&&(d-N().currentTime>=15?"pl-opacity-100":"pl-cursor-default pl-opacity-30 hover:pl-scale-100")}}`,onContextMenu:E=>E.preventDefault(),children:S.jsx("img",{alt:n==="backward"?"backward-icon":"forward-icon",src:n==="backward"?re.backward15:re.forward15,onClick:()=>Rt(n,i),onDoubleClick:E=>E.stopPropagation(),className:"pl-size-6"})}):["touchBackward","touchForward"].includes(n)&&(p=S.jsx("div",{id:n,className:`pl-relative pl-flex pl-flex-col pl-items-center pl-justify-center pl-gap-2 pl-overflow-hidden ${n==="touchBackward"?"pl-rounded-r-full":"pl-rounded-l-full"}`,style:{width:f.width,height:f.width},...h,children:(e||t)&&S.jsxs("div",{className:"pl-flex pl-h-full pl-w-full pl-flex-col pl-items-center pl-justify-center pl-gap-2 pl-bg-secondary-100/[0.3] pl-p-5",onTouchStart:m,children:[S.jsxs("div",{className:`${n==="touchBackward"?"pl-arrow-left":"pl-arrow-right pl-gap-2"} pl-flex pl-items-center pl-justify-center`,children:[S.jsx("img",{alt:"arrow-left-icon",src:re.arrowLeft,className:`pl-size-6 ${n==="touchForward"&&"pl-rotate-180"}`}),S.jsx("img",{alt:"arrow-left-icon",src:re.arrowLeft,className:`pl-size-6 ${n==="touchForward"&&"pl-rotate-180"}`}),S.jsx("img",{alt:"arrow-left-icon",src:re.arrowLeft,className:`pl-size-6 ${n==="touchForward"&&"pl-rotate-180"}`})]}),S.jsxs("p",{className:"pl-text-center pl-text-[14px] pl-font-normal pl-text-white",children:[i," ثانیه"]})]})})),S.jsx(S.Fragment,{children:p})},Cm=Object.freeze(Object.defineProperty({__proto__:null,default:$i},Symbol.toStringTag,{value:"Module"})),wm=()=>(V(({controller:{play:n}})=>({play:n}),K),V(({videoData:{videoElementSizeInfo:n,params:e}})=>({videoElementSizeInfo:n,params:e}),K),S.jsx("div",{className:`${C(T.isTouchScreen)?"pl-flex pl-size-14 pl-items-center pl-justify-center pl-rounded-full pl-bg-black/50":"hover:pl-scale-125"} pl-cursor-pointer pl-transition-transform pl-ease-in-out`,onContextMenu:n=>n.preventDefault(),children:S.jsx("img",{alt:C(T.isPlay)?"pause":"play",src:C(T.isPlay)?re.bigPause:re.bigPlay,onClick:n=>Fr(n),onDoubleClick:n=>n.stopPropagation(),className:`pl-size-8 desktop:pl-size-10 ${C(T.isPlay)?"pl-big-play-icon":"pl-big-pause-icon"}`})})),Lm=()=>S.jsxs("div",{className:"loader-spinner pl-absolute pl-left-[50%] pl-top-[50%] pl-ml-[-42px] pl-mt-[-50px] pl-h-full pl-w-screen pl-overflow-hidden",children:[S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"})]}),vs=1e3,Am=3e3,Dm=6e4,Im=()=>{const[n,e]=P.useState(!1),[t,s]=P.useState(!1);V(({controller:{lock:a,firstPlay:o}})=>({lock:a,firstPlay:o}),K);const{activeElements:r,isLoading:i}=V(({controller:{activeElements:a,isLoading:o}})=>({activeElements:a,isLoading:o}),K);return P.useEffect(()=>{let a=null;return C(T.isFirstPlay)||C(T.isActiveElements)?a=setTimeout(()=>s(!0),100):s(!1),()=>clearTimeout(a)},[r]),P.useEffect(()=>{let a;return C(T.isLoading)?a=setTimeout(()=>e(!0),C(T.isFirstPlay)?0:Am):e(!1),()=>{clearTimeout(a),e(!1)}},[i]),S.jsx("main",{className:"pl-mt-1 pl-flex-1",children:n?S.jsx(Lm,{}):S.jsx(S.Fragment,{children:t&&!C(T.isLock)&&S.jsx("div",{id:"main-content",className:`pl-relative pl-flex pl-h-full pl-items-center pl-justify-center pl-text-center ${C(T.isActiveElements)?"pl-pointer-events-auto":"pl-pointer-events-none"}`,children:S.jsxs("div",{className:"pl-flex pl-w-max pl-items-center pl-justify-center pl-gap-8",style:{zIndex:_e.mainIcons},children:[!C(T.isFirstPlay)&&S.jsx($i,{type:"forward"}),S.jsx(wm,{}),!C(T.isFirstPlay)&&S.jsx($i,{type:"backward"})]})})})})},Vi=n=>{const{videoElementSizeInfo:e}=R.getState().videoData,{duration:t}=R.getState().controller,s=n.clientX!==void 0?n.clientX:n.touches[0].clientX;if(s<=e.right&&s>0)return(s-e.left)/e.width*t},Ut=n=>{const{videoElementSizeInfo:e}=R.getState().videoData,t=n.clientX!==void 0?n.clientX:n.touches[0].clientX;if(t<=e.right&&t>0)return t-e.left},Rm=n=>{const{duration:e}=R.getState().controller;return n*Ys()/e},zn=n=>{n&&(n.style.opacity="0.0",n.style.pointerEvents="none",n.style.zIndex=_e.vttDisable)},km=n=>{n.style.display="block",n.style.zIndex=_e.vtt,n.style.opacity=R.getState().videoData.details.vtt?"1.0":"0.6",n.style.pointerEvents="auto",n.style.transition="opacity 1s ease-out"},Pm=(n,e)=>{const{videoElementSizeInfo:t}=R.getState().videoData,s=document.getElementsByClassName("pl-progressTooltip")[0],r=document.getElementById("parent-player");s&&r&&(Ut(n)>s.getBoundingClientRect().width/2&&Ut(n)<t.right-t.left-s.getBoundingClientRect().width/2?e.style.left=`${Ut(n)-s.offsetWidth/2}px`:Ut(n)<(r.offsetLeft===0?s.offsetWidth:r.offsetLeft)?e.style.left="0px":N().offsetLeft+N().offsetWidth<Ut(n)+s.offsetWidth&&(e.style.left=`${N().offsetWidth-s.offsetWidth}px`))},_m=(n,e,t)=>{e&&km(e),R.getState().videoData.details.vtt?Pm(n,e):e.style.left=`${Ut(n)-30}px`,R.dispatch(d0(Number(Vi(n)))),t.textContent=`${zs(Vi(n))}`},qn=(n,e=!1)=>{const{videoElementSizeInfo:t}=R.getState().videoData,s=document.querySelector(".pl-progressTooltip"),r=document.querySelector(".pl-progressTimeTooltip"),i=n.clientX!==void 0?n.clientX:n.touches[0].clientX;s&&r&&i<=t.right&&i>t.left?(_m(n,s,r),e&&setTimeout(()=>zn(s),2e3)):zn(s)},Tu=n=>{const e=n.clientX!==void 0?n.clientX:n.touches[0].clientX;yt()&&(e<=n.view.innerWidth&&e>0?yt().style.width=`${Ut(n)}px`:e<=n.view.innerWidth?yt().style.width=0:e>0&&(yt().style.width="100%"))},Om=(n,e,t)=>{n.preventDefault(),n.stopPropagation(),t(!0);const s=R.dispatch,r=n.clientX!==void 0?n.clientX:n.touches[0].clientX;r<=n.view.innerWidth&&r>0&&(s(Oa(!0)),s(pr(!0)),sessionStorage.setItem("previousVideoTime",String(N().currentTime)),n.target.setPointerCapture(n.pointerId),e.length>0&&e.map(i=>clearTimeout(i)))},xu=n=>{n.preventDefault(),n.stopPropagation();const e=R.dispatch,{activePointerProgressBar:t}=R.getState().controller,{left:s}=R.getState().videoData.videoElementSizeInfo,r=n.clientX!==void 0?n.clientX:n.touches[0].clientX,i=document.querySelector(".pl-progressTooltip");r>s?(i&&(i.style.display="block !important",i.style.pointerEvents="auto"),t&&(e(pr(!0)),qn(n),Tu(n),N().pause())):i&&(i.style.display="none !important",i.style.pointerEvents="none")},Fm=(n,e,t,s)=>{s(!1),n.preventDefault(),n.stopPropagation();const r=R.dispatch,{duration:i}=R.getState().controller,{left:a,right:o}=R.getState().videoData.videoElementSizeInfo;n.target.removeEventListener("pointermove",xu);const l=n.clientX!==void 0?n.clientX:n.touches[0].clientX;let c=0;l>a&&l<o?c=Vi(n):l<a?c=0:l>0&&(c=i),C(T.isStaticFormat)||ps(N().currentTime,c),N().currentTime=c,R.getState().controller.activePointerProgressBar&&(r(Oa(!1)),r(pr(!1)),N().play(),qn(n,!0),sessionStorage.setItem("current-time",String(c)),Tu(n),Mm(n,r,e,t))},Mm=(n,e,t,s)=>{const r=s;let i=setTimeout(()=>{const{settingPopover:a}=R.getState().popovers,{delayTurnOffControlbar:o}=R.getState().controller;n.pointerType==="touch"&&!a&&o&&e(Se(!1))},vs);r.push(i),t(r)},Nm=()=>{const n=Date.now();N().play().then(()=>oe(ch(Date.now()-n)))},Bm=n=>qn(n),Um=()=>{const n=document.querySelector(".pl-progressTooltip");zn(n)},$m=n=>{const e=n.split("."),s=e[0].split(":");return{milliseconds:parseInt(e[1],10)||0,seconds:parseInt(s.pop(),10)||0,minutes:parseInt(s.pop(),10)||0,hours:parseInt(s.pop(),10)||0}},vu=n=>{const e=$m(n);return parseInt(e.hours*(60*60)+e.minutes*60+e.seconds+e.milliseconds/1e3,10)},Vm=n=>{const e=n.split(/#xywh=/i),t=e[0],r=e[1].match(/[0-9]+/gi);return{x:r[0],y:r[1],w:r[2],h:r[3],image:t}},Gm=(n,e)=>n.indexOf("//")>=0?n:e.indexOf("//")===0?[e.replace(/\/$/gi,""),n.trim()].join("/"):e.indexOf("//")>0?[e.trim(),n.trim()].join("/"):n,Hm=(n,e)=>{const t={};let s=e.split(/\/\w+\.vtt\s?/)[0];if(n=Gm(n,s),!n.match(/#xywh=/i))return t.background='url("'+n+e.split(/\/\w+\.vtt\s?/)[1]+'")',t;const r=Vm(n);return t.background='url("'+r.image+e.split(/\/\w+\.vtt\s?/)[1]+'") no-repeat -'+r.x+"px -"+r.y+"px",t.width=r.w+"px",t.height=r.h+"px",t.url=r.image,t},Km=(n,e)=>{fetch(n).then(t=>{if(!t.ok)throw R.dispatch(Na({...R.getState().videoData.details,vtt:void 0,vtt_mobile:void 0})),new Error("Network response was not ok");return t.text()}).then(t=>{const s=[];t.split(/[\r\n][\r\n]/i).forEach(i=>{if(i.match(/([0-9]{2}:)?([0-9]{2}:)?[0-9]{2}(.[0-9]{3})?( ?--> ?)([0-9]{2}:)?([0-9]{2}:)?[0-9]{2}(.[0-9]{3}).*/gi)){const a=i.split(/[\r\n]/i),l=a[0].split(/ ?--> ?/i),c=l[0],u=l[1],d=a[1],f=Hm(d,n);s.push({start:vu(c),end:vu(u),css:f})}}),e(s)}).catch(t=>{console.error("Error fetching file:",t)})},Wm=(n,e,t)=>{for(let s=0;s<e.length;++s){const r=e[s];if(n>=r.start&&n<r.end){if(r.css.url&&!t[r.css.url]){const i={background:r.css.background,width:r.css.width,height:r.css.height};return t[r.css.url]=i,i}else if(r.css.url)return t[r.css.url]}}},jm=()=>{const{details:n}=V(({videoData:{details:o}})=>({details:o}),K),{tooltipTime:e}=V(({controller:{tooltipTime:o,activeElements:l,isFullScreen:c}})=>({tooltipTime:o,activeElements:l,isFullScreen:c}),K),t={},[s,r]=P.useState(void 0),[i,a]=P.useState(C(T.isTouchScreen)?n.vtt_mobile:n.vtt);return P.useEffect(()=>{a(n.vtt_mobile)},[n.vtt_mobile]),P.useEffect(()=>{i&&Km(n.vtt_mobile,r)},[i]),C(T.isActiveElements)?S.jsxs("div",{className:`pl-progressTooltip pl-absolute pl-bottom-[calc(100%+10px)] pl-mr-[-25px] pl-flex pl-flex-col pl-px-[10px] pl-pt-[5px] pl-text-[14px] pl-text-white ${i&&s?"":"pl-bg-z-gray-700"} pl-rounded-[6px] pl-opacity-0`,children:[i&&!!s&&S.jsx("div",{className:"pl-mb-2 pl-flex-1 pl-rounded-[8px] pl-border pl-border-white",children:S.jsx("div",{className:"pl-rounded-[8px]",style:Wm(e,s,t)})}),S.jsx("div",{className:"pl-progressTimeTooltip pl-flex pl-items-center pl-justify-center pl-text-white !pl-opacity-100"})]}):S.jsx(S.Fragment,{})},zm=P.memo(jm),bs=(n,e)=>{P.useEffect(()=>{const t=s=>{!n.current||n.current.contains(s.target)||e(s)};return document.addEventListener("mousedown",t),document.addEventListener("touchstart",t),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("touchstart",t)}},[n,e])},Gi=({name:n,className:e,dataMarker:t})=>S.jsx("img",{"data-marker":t,src:`${ah()}/${n}.png`,alt:n,className:e}),qm=()=>{const{duration:n,activeElements:e}=V(({controller:{duration:p,activeElements:E,isFullScreen:x}})=>({duration:p,activeElements:E,isFullScreen:x}),K),{markers:t}=V(({videoData:{markers:p,videoElementSizeInfo:E}})=>({markers:p,videoElementSizeInfo:E}),K),[s,r]=P.useState(void 0),[i,a]=P.useState([]),[o,l]=P.useState({}),[c,u]=P.useState(!1),d=p=>n?Ys()*p/n:0,f=(p,E,x,v,w,b,I,A)=>{p.stopPropagation();const U=24*E/(Ys()+5);let O=[],B=0;A.map(Y=>{Y.time>E-U&&Y.time<E+U&&(O.push(Y),B+=Y.time)}),O.length>1?a(O):(O=[],a([]),g(p,E,x,v,w,b,I))},g=(p,E,x,v,w,b,I)=>{p.stopPropagation(),qn(p,I),ps(N().currentTime,E),N().currentTime=E,yt()&&(yt().style.width=d(E)),oe(Wo(x,E,v,w,b))};P.useEffect(()=>{C(T.isActiveElements)||a([])},[e]);const h=P.useRef(null);bs(h,()=>a([])),P.useEffect(()=>{if(i.length>0){const p=_0(document.getElementsByClassName("pl-overlapMarkers")[0]);if(p==="inViewport")return u(!0),l({left:d(i[0].time)});if(p==="OutViewPortFromLeft")return u(!1),l({left:0});if(p==="OutViewPortFromRight")return u(!1),l({right:0})}},[i,document.getElementsByClassName("pl-overlapMarkers")[0]]);const m=p=>{p.preventDefault(),C(T.isTouchScreen)&&r(Number(p.target.getAttribute("data-marker")))};return S.jsxs(S.Fragment,{children:[t.map(p=>S.jsx("div",{onContextMenu:m,"data-marker":p.time,onClick:E=>f(E,p.time,p.id,p.title,p.description,p.sticker,!0,t),onDoubleClick:E=>E.stopPropagation(),children:S.jsxs("div",{className:`pl-emoji-image pl-absolute pl-bottom-[200%] pl-rounded-[6px] pl-bg-z-gray-700/[0.4] pl-p-1 ${C(T.isTouchScreenPortrait),"pl-mb-5"} pl-ml-[-12px] pl-cursor-pointer`,style:{left:d(p.time),zIndex:_e.markers},"data-marker":p.time,children:[p.isPersonal!==null&&p.isPersonal!==void 0&&S.jsx("div",{className:"pl-bg-main pl-absolute pl-right-[-1px] pl-top-[-2px] pl-h-2 pl-w-2 pl-rounded-full"}),S.jsx(Gi,{dataMarker:p.time,name:p.sticker,className:"pl-h-[16px] pl-w-[16px] !pl-max-w-max"})]})},p.id)),i.length>0&&S.jsx("div",{className:`pl-overlapMarkers ${c?"pl-overlayMarkersInViewport":"pl-overlayMarkersOutViewport"} animate__animated animate__fadeInUp pl-absolute pl-bottom-[45px] pl-ml-[-10px] pl-flex pl-flex-row-reverse pl-justify-end pl-gap-3 pl-rounded-[6px] pl-bg-z-gray-700/[0.4] pl-px-1 pl-py-2 pl-opacity-100`,ref:h,style:o,children:i.map(p=>S.jsx("div",{className:"pl-emoji-image pl-cursor-pointer pl-rounded-[6px]","data-marker":p.time,onClick:E=>g(E,p.time,p.id,p.title,p.description,p.sticker,!0),onDoubleClick:E=>E.stopPropagation(),children:S.jsx(Gi,{dataMarker:p.time,name:p.sticker,className:"pl-h-[24px] pl-w-[24px] !pl-max-w-max"})},p.id))})]})},Ym=P.memo(qm),Xm=()=>{const[n,e]=P.useState(!1);P.useEffect(()=>{zn(document.querySelector(".progressTooltip"))},[]);const{duration:t,currentTime:s,bufferedTimeWidth:r}=V(({controller:{duration:o,currentTime:l,bufferedTimeWidth:c}})=>({duration:o,currentTime:l,bufferedTimeWidth:c}),K);V(({videoData:{params:o,videoElementSizeInfo:l}})=>({params:o,videoElementSizeInfo:l}),K);const[i,a]=P.useState([]);return S.jsxs("div",{className:"pl-relative",children:[S.jsxs("div",{className:"pl-relative",children:[S.jsx(zm,{}),S.jsx(Ym,{})]}),S.jsx("div",{className:"pl-flex pl-w-full pl-items-end",onPointerDown:o=>Om(o,i,e),onPointerMove:xu,onPointerUp:o=>Fm(o,a,i,e),onMouseMove:Bm,onMouseOut:Um,onClick:Nm,onDoubleClick:o=>o.stopPropagation(),children:S.jsxs("div",{id:"progress-area",className:"pl-absolute pl-w-full",children:[S.jsx("div",{className:"pl-h-10 pl-w-full"}),S.jsxs("div",{id:"time-progress-area",className:"pl-m-auto !pl-h-[5px] !pl-w-full pl-cursor-pointer pl-rounded !pl-bg-gray-highLight pl-transition-transform pl-duration-300",style:{transform:n?"scaleY(1.8)":"unset"},children:[S.jsx("div",{id:"time-progress-buffer",className:"pl-absolute pl-h-[5px] pl-rounded pl-bg-z-gray-400/[0.7]",style:{width:`${r}%`}}),S.jsx("div",{id:"time-progress-bar",className:`pl-relative pl-h-[5px] pl-cursor-pointer pl-rounded pl-bg-primary before:pl-inline-block before:pl-h-4 before:pl-w-4 before:pl-bg-primary ${n&&"before:pl-h-3 before:pl-w-7"}`,style:{width:`${s/t*Ys()}px`}})]})]})})]})},Tt=({title:n,className:e})=>S.jsx("span",{className:`pl-absolute pl-w-max pl-bg-paper pl-text-white/[0.9] ${C(T.isFullScreen)?"pl-bottom-[300%]":"pl-bottom-[270%]"} pl-rounded-[8px] pl-px-4 pl-py-[13px] pl-text-[10px] pl-font-normal ${e}`,children:n}),Zm=()=>{const{isFullScreen:n}=V(({controller:{firstPlay:r,isFullScreen:i}})=>({firstPlay:r,isFullScreen:i}),K),[e,t]=P.useState(!1),s=ve();return P.useEffect(()=>{C(T.isFirstPlay)||s(Se(!1))},[n]),S.jsxs("div",{className:"pl-relative pl-flex pl-items-center",children:[S.jsx("img",{src:C(T.isFullScreen)?re.nonFullScreen:re.fullScreen,alt:"fullScreen-icon",className:"pl-size-5 pl-cursor-pointer",onMouseOver:()=>!C(T.isTouchScreen)&&t(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&t(!1),onClick:()=>{Mr(),Nr()}}),e&&S.jsx(Tt,{title:`${C(T.isFullScreen)?xe("existFrom"):""} ${xe("fullscreen")}`})]})},Qm=()=>{const[n,e]=P.useState(!1);return S.jsxs("div",{className:"pl-relative pl-flex pl-items-center",children:[S.jsx("img",{alt:"pictureInPicture",onMouseOver:()=>!C(T.isTouchScreen)&&e(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&e(!1),src:re.pictureInPicture,className:"pl-flex pl-size-5 pl-cursor-pointer",onClick:()=>N().requestPictureInPicture()}),n&&S.jsx(Tt,{title:xe("pictureInPicture")})]})},Jm=()=>{const[n,e]=P.useState(!1),t=ve(),{settings:s}=V(({user:{settings:o}})=>({settings:o}),K),r=P.useRef(s.volume),i=()=>{if(r.current!==s.volume){const{settings:o}=R.getState().user;oe(ln(r.current,o.volume)),r.current=o.volume,t(ot({...o,volume:o.volume}))}},a=o=>{const{settings:l}=R.getState().user;o==="mute"?(un(0),oe(ln(l.volume,0))):(oe(ln(l.volume,100)),un(100))};return S.jsxs("div",{className:"pl-sound-icon pl-relative pl-inline-flex pl-items-center pl-gap-2",children:[!C(T.isTouchScreen)&&S.jsx("input",{onMouseUp:i,type:"range",min:"0",max:"100",value:s.volume,onChange:o=>un(+o.target.value),className:"pl-soundVolume rounded-full pl-cursor-pointer",style:{background:`linear-gradient(to right, white ${s.volume}%, rgba(255,255,255,0.3) 0)`}}),S.jsxs("div",{className:"pl-relative pl-flex pl-items-center",children:[S.jsx("img",{src:C(T.hasSound)?re.unMute:re.mute,alt:C(T.hasSound)?"unmute-icon":"mute-icon",className:"pl-flex pl-size-5 pl-cursor-pointer pl-items-center",onClick:()=>C(T.hasSound)?a("mute"):a("unmute"),onDoubleClick:o=>o.stopPropagation(),onMouseOver:()=>!C(T.isTouchScreen)&&e(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&e(!1)}),n&&S.jsx(Tt,{className:"pl-left-0",title:xe("volume")})]})]})},ey=({className:n,onClick:e})=>S.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,onClick:e,children:[S.jsx("path",{d:"M6 6L18.7742 18.7742",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),S.jsx("path",{d:"M6 18.7744L18.7742 6.00022",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Cs=P.forwardRef(({children:n,status:e,onClose:t,type:s,classNames:r,parentClassNames:i,styles:a,isBlurBackground:o,isFullHeight:l=!1,isHeader:c,isHasCatchUpLineOnTop:u=!1,animation:d,scrollbar:f=!1,isFocusOnInput:g=!1,headerTitle:h="",customHeader:m,headerClassName:p,showCloseIcon:E=!0},x)=>{const[v,w]=P.useState(e),[b,I]=P.useState(0),[A,F]=P.useState(0),{videoElementSizeInfo:U}=V(({videoData:{videoElementSizeInfo:j}})=>({videoElementSizeInfo:j}),K),O=P.useRef(0);P.useEffect(()=>{let j;return e?w(!0):j=setTimeout(()=>{t(!1),I(0),w(!1)},500),()=>clearTimeout(j)},[e]);const B=j=>{const Q=document.getElementById("popover-content");O.current||(O.current=window.innerHeight-U.top-(Q==null?void 0:Q.getBoundingClientRect().top)),j.stopPropagation(),window.innerHeight-U.top-j.touches[0].clientY<O.current&&I(window.innerHeight-j.touches[0].clientY),F(_e.maxPopover)},Y=()=>{t()},$=S.jsxs(S.Fragment,{children:[o&&S.jsx("div",{className:`animate__animated animate__faster pl-fixed pl-right-0 pl-top-0 pl-h-screen pl-w-screen pl-bg-black/[0.5] ${e?"animate__fadeIn":"animate__fadeOut"}`,style:{zIndex:_e.popoverBlurBackground}}),S.jsx("div",{className:`${s==="modal"&&"pl-fixed pl-left-0 pl-top-0 pl-flex pl-h-full pl-w-full pl-items-end pl-justify-center sm:pl-items-center"} ${i}`,style:{zIndex:l&&!g?A:_e.popoverContent},children:S.jsx("div",{className:`animate__animated animate__faster pl-flex pl-flex-col pl-rounded-lg pl-bg-new-net_1-9 pl-text-white ${l&&"pl-h-full"} ${d||(window.innerWidth>768&&s==="modal"?e?"animate__fadeIn":"animate__fadeOut":e?"animate__fadeInUp":"animate__fadeOutDown")} ${C(T.isTouchScreenPortrait)?"!pl-fixed !pl-bottom-0 !pl-left-0 !pl-right-0 !pl-mb-0 !pl-w-full pl-rounded-[12px] !pl-rounded-b-none !pl-bg-bg-primary":"before:pl-hidden"} ${s!=="modal"&&"no-scrollbar pl-absolute pl-bottom-[130%] pl-overflow-auto"} ${r} `,style:{height:b||"max-content",maxHeight:"80vh",zIndex:_e.popoverContent,...a},ref:x,id:"popover-content",children:S.jsxs(S.Fragment,{children:[c&&S.jsxs("div",{onTouchMove:u?B:()=>{},onTouchEndCapture:u?Y:()=>{},className:"pl-flex pl-flex-col pl-pt-4",children:[u&&S.jsx("div",{className:"pl-absolute pl-mb-4 pl-h-1 pl-w-8 pl-self-center pl-rounded-[20px] pl-bg-new-net_1-7"}),S.jsx("div",{className:`pl-mx-4 pl-mb-4 ${p}`,children:m||S.jsxs("div",{className:"pl-flex pl-items-center pl-justify-between pl-py-[19px]",children:[S.jsx("p",{className:"pl-text-[18px] pl-font-bold pl-text-black dark:pl-text-white",children:h}),E&&S.jsx(ey,{className:"pl-stroke-secondary-400 dark:pl-stroke-dark-5 pl-cursor-pointer",onClick:t})]})})]}),S.jsx("div",{className:`pl-h-full pl-w-full pl-overflow-y-auto ${!f&&"no-scrollbar"}`,onTouchMove:j=>j.stopPropagation(),children:n})]})})})]});return S.jsx(S.Fragment,{children:v&&S.jsx(S.Fragment,{children:s==="modal"?ku.createPortal(S.jsx(S.Fragment,{children:$}),document.getElementById("dialog-react-root-videoPlayer")):S.jsx("div",{children:$})})})});Cs.displayName="popover";const ty=({className:n,onClick:e,onMouseOver:t,onMouseLeave:s})=>S.jsxs("svg",{width:"18",height:"15",viewBox:"0 0 18 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,onClick:e,onMouseOver:t,onMouseLeave:s,children:[S.jsx("path",{d:"M10.5488 1.53559C8.20532 1.02852 5.66339 1.68608 3.84359 3.50588C1.15649 6.19298 1.00481 10.4572 3.39041 13.3215C3.55135 13.5148 3.8176 13.6347 4.13036 13.6347H13.8687C14.1816 13.6347 14.4476 13.5149 14.6085 13.3217C16.0815 11.5533 16.5884 9.25027 16.1258 7.11249C16.0528 6.77512 16.2671 6.44245 16.6045 6.36945C16.9418 6.29645 17.2745 6.51077 17.3475 6.84814C17.8886 9.34866 17.2968 12.0474 15.569 14.1217C15.1326 14.6455 14.489 14.8847 13.8687 14.8847H4.13036C3.50995 14.8847 2.86616 14.6453 2.42991 14.1215C-0.36559 10.765 -0.188583 5.77029 2.95971 2.622C5.09241 0.489299 8.07189 -0.279272 10.8132 0.31386C11.1505 0.386857 11.3648 0.719527 11.2918 1.0569C11.2188 1.39427 10.8862 1.60859 10.5488 1.53559Z"}),S.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M14.9976 2.66523C15.2417 2.9093 15.2417 3.30503 14.9976 3.54911L10.7129 7.83399C10.8469 8.09798 10.9225 8.39667 10.9225 8.713C10.9225 9.78688 10.0519 10.6574 8.97805 10.6574C7.90417 10.6574 7.03362 9.78688 7.03362 8.713C7.03362 7.63912 7.90417 6.76856 8.97805 6.76856C9.27953 6.76856 9.56498 6.83718 9.81965 6.95963C9.82222 6.95697 9.82483 6.95432 9.82746 6.95168L14.1137 2.66525C14.3578 2.42116 14.7535 2.42115 14.9976 2.66523ZM9.67249 8.713C9.67249 9.09652 9.36158 9.40743 8.97805 9.40743C8.59453 9.40743 8.28362 9.09652 8.28362 8.713C8.28362 8.32947 8.59453 8.01856 8.97805 8.01856C9.36158 8.01856 9.67249 8.32947 9.67249 8.713Z"})]}),sy=[.5,1,1.5,2],ny=({setSection:n,showSpeedIcon:e})=>{const t=ve();V(({videoData:{videoElementSizeInfo:c,params:u}})=>({videoElementSizeInfo:c,params:u}),K);const{speedPopover:s}=V(({popovers:{speedPopover:c}})=>({speedPopover:c}),K),{settings:r}=V(({user:{settings:c}})=>({settings:c}),K),i=P.useRef(null),[a,o]=P.useState(!1);bs(i,()=>t(Gs(!1))),P.useEffect(()=>{N()&&(N().playbackRate=r.speed)},[]);const l=S.jsxs("div",{id:me.speed,className:"animate__animated animate__fadeIn pl-flex pl-flex-col pl-gap-4 pl-py-4 pl-text-white",children:[S.jsxs("div",{className:"pl-flex pl-items-center pl-gap-3 pl-px-4",children:[S.jsx("img",{src:re.chevronRight,alt:"chevronRight",onClick:()=>{n&&n(me.main)},className:"pl-size-4 pl-cursor-pointer"}),S.jsx("p",{className:"pl-text-[15px] pl-font-medium",children:xe("speed")})]}),S.jsx("ul",{className:"pl-flex pl-flex-col pl-gap-2",children:sy.map((c,u)=>S.jsxs("li",{className:`pl-relative pl-flex pl-cursor-pointer pl-items-center pl-gap-4 pl-rounded-[4px] pl-px-4 pl-text-sm pl-font-medium desktop:pl-gap-3 ${r.speed===c&&"!pl-cursor-default pl-bg-primary"} ${C(T.isTouchScreen)?"pl-py-1.5":"pl-py-[9.5px]"}`,onClick:r.speed===c?()=>{}:()=>{C(T.isStaticFormat)||oe(oh(c)),t(Se(!1)),t(Lt(!1)),t(Gs(!1)),t(ot({...r,speed:c})),N().playbackRate=c,n&&n(me.main)},children:[S.jsx("img",{src:re.tick,alt:"tick",className:`pl-h-auto pl-w-[15px] pl-opacity-0 ${r.speed===c&&"pl-opacity-100"}`}),S.jsxs("p",{className:"pl-flex pl-w-full pl-items-center pl-gap-1",children:[c===1?xe("normalSpeed"):c,c!==1&&S.jsx("img",{src:re.close,alt:"x",className:"pl-size-[14px]"})]})]},u))})]});return S.jsx(S.Fragment,{children:e?S.jsxs("div",{className:"pl-relative pl-flex pl-items-center",ref:i,children:[S.jsx(ty,{className:"size-5 pl-size-5 pl-cursor-pointer pl-fill-white",onClick:()=>t(Gs(!s)),onMouseOver:()=>!C(T.isTouchScreen)&&!C(T.showSpeedPopover)&&o(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&o(!1)}),a&&S.jsx(Tt,{title:xe("speed")}),S.jsx(Cs,{classNames:`!pl-p-0 pl-overflow-hidden !pl-bg-white ${C(T.isTouchScreen)?"!pl-fixed !pl-bottom-0 !pl-rounded-t-[20px] pl-rounded-b-none":"!pl-w-[230px] pl-right-0 pl-mb-[33px] !pl-rounded-[12px]"} ${C(T.isTouchScreenPortrait)&&"!pl-w-screen tablet:!pl-max-w-[440px] tablet:!pl-mx-auto"} ${C(T.isTouchScreenLandscape)&&"pl-w-full pl-max-w-[440px]"}`,status:s,onClose:()=>t(Gs(!1)),type:C(T.isTouchScreen)?"modal":"popover",isBlurBackground:C(T.isTouchScreenPortrait),ref:C(T.isTouchScreenPortrait)?i:void 0,isHeader:C(T.isTouchScreen),customHeader:S.jsx(S.Fragment,{}),isHasCatchUpLineOnTop:C(T.isTouchScreen),children:l})]}):S.jsx(S.Fragment,{children:l})})},ry=({enabled:n,setEnabled:e})=>S.jsx("div",{className:`pl-relative pl-h-[22px] pl-w-[37px] pl-cursor-pointer pl-rounded-[15px] pl-transition-colors pl-duration-150 pl-ease-linear ${n?"pl-border pl-border-transparent pl-bg-primary":"pl-border pl-border-gray-highLight pl-bg-secondary-200"}`,onClick:e,children:S.jsx("div",{className:`pl-absolute pl-left-1 pl-top-[2px] pl-h-[16px] pl-w-[16px] pl-rounded-full pl-transition-transform pl-duration-150 pl-ease-linear ${n?"pl-translate-x-[13px] pl-bg-white":"-pl-translate-x-0.5 pl-bg-black/[0.16]"}`})}),iy=({setSection:n})=>{const e=ve(),{subtitles:t,selectedSubtitle:s}=V(({videoData:{subtitles:r,selectedSubtitle:i}})=>({subtitles:r,selectedSubtitle:i}),K);return S.jsx("div",{id:me.subtitles,className:"animate__animated animate__fadeIn pl-p-[14px]",children:S.jsxs("ul",{className:"pl-m-0 pl-flex pl-flex-col pl-p-0",children:[S.jsx("li",{className:`hover:pl-bg-main/[0.1] pl-relative pl-flex pl-cursor-pointer pl-items-center pl-rounded-[4px] pl-p-1 pl-pr-2 pl-text-[14px] pl-leading-6 hover:dark:pl-bg-white/[0.25] ${!s&&"pl-bg-main-light hover:!pl-bg-main-light pl-text-dark-5"}`,onClick:()=>{e(Se(!1)),e(Lt(!1)),e(os(void 0)),n(me.main);const r=Object.values(N().textTracks).find(i=>i.mode==="showing");r&&(r.mode="disabled"),e(as("")),oe(hs("empty"))},children:"بدون زیرنویس"}),t.map((r,i)=>S.jsx("li",{className:`hover:pl-bg-main/[0.1] pl-relative pl-flex pl-cursor-pointer pl-items-center pl-rounded-[4px] pl-p-1 pl-pr-2 pl-text-[14px] pl-leading-6 hover:dark:pl-bg-white/[0.25] ${s&&s.language===r.language&&"pl-bg-main-light hover:!pl-bg-main-light pl-text-dark-5"}`,onClick:()=>{e(Se(!1)),e(Lt(!1)),e(os(r)),N().textTracks[i].mode="showing",n(me.main),oe(hs(r.language))},children:S.jsx("span",{children:r.label})},i))]})})},ay=P.memo(iy),oy=({setSection:n,showQualityLevelsIcon:e})=>{const t=ve();let{qualityLevels:s}=V(({controller:{qualityLevels:d,manualQuality:f,autoQuality:g}})=>({qualityLevels:d,manualQuality:f,autoQuality:g}),K);const{settings:r}=V(({user:{settings:d}})=>({settings:d}),K),{qualityLevelsPopover:i}=V(({popovers:{qualityLevelsPopover:d}})=>({qualityLevelsPopover:d}),K);V(({videoData:{params:d,videoElementSizeInfo:f}})=>({params:d,videoElementSizeInfo:f}),K);const[a,o]=P.useState(!1);s=[-1,...s];const l=(d,f)=>C(T.isAutoQuality)&&f===-1?!0:!C(T.isAutoQuality)&&r.quality===d,c=P.useRef(null);bs(c,()=>t(Hs(!1)));const u=S.jsx("div",{id:me.qualityLevels,className:"animate__animated animate__fadeIn pl-py-2",children:S.jsx("ul",{className:"pl-flex pl-flex-col pl-gap-2",children:s.map((d,f)=>S.jsxs("li",{className:`pl-relative pl-flex pl-cursor-pointer pl-items-center pl-rounded-[4px] pl-ps-[24.2px] pl-text-[14px] pl-font-medium ${l(f-1,d)&&"!pl-cursor-default pl-bg-primary/[0.12]"} ${C(T.isTouchScreen)?"pl-py-[13.5px]":"pl-py-[9.5px]"}`,onClick:l(f-1,d)?()=>{}:()=>{oe(lh(d===-1?"auto":`${d}P`)),t(Se(!1)),t(Lt(!1)),t(Hs(!1)),t(ot({...r,quality:d===-1?-1:f-1})),n&&n(me.main)},children:[!C(T.isTouchScreen)&&l(f-1,d)&&S.jsx("div",{className:"pl-absolute pl-right-[11.8px]",children:S.jsx("img",{src:re.tick,alt:"",width:12,height:9})}),C(T.isTouchScreen)&&S.jsx("div",{className:`pl-h-5 pl-w-5 pl-rounded-full pl-border pl-border-black/[0.5] pl-p-0.5 ${l(f-1,d)&&"pl-border-primary"}`,children:l(f-1,d)&&S.jsx("div",{className:"pl-h-full pl-w-full pl-rounded-full pl-bg-primary"})}),S.jsx("span",{className:`pl-w-full pl-text-[14px] pl-text-black/[0.87] ${C(T.isTouchScreen)?"pl-pr-[21px]":"pl-pr-[10px]"}`,children:d===-1?S.jsxs("span",{children:[S.jsx("span",{children:"خودکار "}),S.jsx("span",{className:"pl-text-[10px] pl-font-normal pl-text-black/[0.5]",children:"(بر اساس سرعت اینترنت شما)"})]}):`${d}p`})]},f))})});return S.jsx(S.Fragment,{children:e?S.jsxs("div",{className:"pl-relative pl-flex pl-items-center",ref:c,children:[S.jsx("img",{src:re.qualitySetting1,alt:"speed-icon",onClick:()=>t(Hs(!i)),onMouseOver:()=>!C(T.isTouchScreen)&&!C(T.showQualityLevelsPopover)&&o(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&o(!1),className:"pl-size-5 pl-cursor-pointer"}),a&&S.jsx(Tt,{title:xe("quality")}),S.jsx(Cs,{classNames:`!pl-p-0 pl-overflow-hidden !pl-bg-white ${C(T.isTouchScreen)?"!pl-fixed !pl-bottom-0 !pl-rounded-t-[20px] pl-rounded-b-none":"pl-right-0 pl-mb-[33px] !pl-rounded-[12px] pl-w-[230px]"} ${C(T.isTouchScreenPortrait)&&"!pl-w-screen tablet:pl-max-w-[440px]"} ${C(T.isTouchScreenLandscape)&&"pl-w-full pl-max-w-[440px]"}`,status:i,onClose:()=>t(Hs(!1)),type:C(T.isTouchScreen)?"modal":"popover",isBlurBackground:C(T.isTouchScreenPortrait),ref:C(T.isTouchScreenPortrait)?c:void 0,isHeader:C(T.isTouchScreen),customHeader:S.jsx(S.Fragment,{}),isHasCatchUpLineOnTop:C(T.isTouchScreen),children:u})]}):S.jsx(S.Fragment,{children:u})})},bu=P.memo(oy),ly=()=>{const n=ve(),{selectedSubtitle:e}=V(({videoData:{params:l,subtitles:c,selectedSubtitle:u}})=>({params:l,subtitles:c,selectedSubtitle:u}),K),{settingPopover:t}=V(({popovers:{settingPopover:l}})=>({settingPopover:l}),K);V(({user:{settings:l}})=>({settings:l}),K);const[s,r]=P.useState(me.main),[i,a]=P.useState(!1),o=P.useRef(null);return bs(o,()=>{n(Lt(!1)),setTimeout(()=>r(me.main),500)}),S.jsxs("div",{className:`pl-inline-flex ${C(T.isLandscape)&&"pl-relative"}`,ref:o,children:[S.jsxs("div",{className:"pl-relative pl-flex pl-cursor-pointer pl-items-center",onClick:()=>n(Lt(!t)),onMouseOver:()=>!C(T.isTouchScreen)&&!C(T.showSettingPopover)&&a(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&a(!1),children:[S.jsx("img",{src:re.settings,alt:"settings",className:"pl-size-5"}),i&&S.jsx(Tt,{title:xe("setting")})]}),S.jsx(Cs,{classNames:`!pl-p-0 pl-overflow-hidden ${C(T.isTouchScreen)?"!pl-fixed !pl-bottom-0 !pl-rounded-t-[28px] pl-rounded-b-none":"!pl-w-[230px] pl-right-0 pl-mb-[33px]"} ${C(T.isTouchScreenPortrait)&&"!pl-w-screen tablet:!pl-max-w-[285px] tablet:!pl-mx-auto"} ${C(T.isTouchScreenLandscape)&&"pl-w-full pl-max-w-[285px]"}`,status:t,onClose:()=>{n(Lt(!1)),setTimeout(()=>r(me.main),500)},type:C(T.isTouchScreen)?"modal":"popover",isBlurBackground:C(T.isTouchScreenPortrait),ref:C(T.isTouchScreenPortrait)?o:void 0,isHeader:C(T.isTouchScreen),customHeader:S.jsx(S.Fragment,{}),isHasCatchUpLineOnTop:C(T.isTouchScreen),children:S.jsxs(S.Fragment,{children:[s===me.main&&S.jsxs("div",{id:me.main,className:"animate__animated animate__fadeIn pl-flex pl-flex-col pl-gap-5 pl-rounded-[10px] pl-p-4",children:[!C(T.isStaticFormat)&&S.jsx(S.Fragment,{children:S.jsxs("div",{className:"pl-flex pl-cursor-pointer pl-items-center pl-gap-[10px]",onClick:()=>r(me.qualityLevels),children:[S.jsx("img",{src:re.qualitySetting,alt:"qualitySetting",width:16,height:16}),S.jsx("p",{className:"pl-ml-auto pl-text-[12px] pl-font-medium pl-text-black/[0.87]",children:xe("quality")}),S.jsx("img",{src:re.chevronRight,alt:"chevronRight",className:"pl-size-4"})]})}),C(T.hasNoSpeed)&&S.jsxs("div",{className:"pl-flex pl-cursor-pointer pl-items-center pl-justify-between pl-gap-[10px] pl-text-white",onClick:()=>r(me.speed),children:[S.jsx("p",{className:"pl-text-sm pl-font-medium",children:xe("speed")}),S.jsx("img",{src:re.chevronRight,alt:"chevronRight",onClick:()=>{r&&r(me.main)},className:"pl-size-4 pl-rotate-180 pl-cursor-pointer"})]}),C(T.hasSubtitles)&&C(T.isTouchScreenPortrait)&&S.jsxs("div",{className:"pl-flex pl-cursor-pointer pl-items-center pl-gap-[10px]",children:[S.jsx("img",{src:re.subtitleOutlineGray,alt:"subtitle-icon",className:"pl-size-5"}),S.jsx("p",{className:"pl-ml-auto pl-text-[12px] pl-font-medium pl-text-black/[0.87]",children:xe("subtitle")}),S.jsx(ry,{enabled:!!e,setEnabled:dn})]})]}),s===me.qualityLevels&&S.jsx(bu,{setSection:r}),s===me.speed&&S.jsx(ny,{setSection:r}),s===me.subtitles&&S.jsx(ay,{setSection:r})]})})]})},cy=P.memo(ly),Cu=()=>{const{duration:n,currentTime:e}=V(({controller:{duration:t,currentTime:s}})=>({duration:t,currentTime:s}),K);return V(({videoData:{videoElementSizeInfo:t,params:s}})=>({videoElementSizeInfo:t,params:s}),K),S.jsx(S.Fragment,{children:S.jsxs("div",{className:`pl-mr-auto pl-w-full pl-max-w-max pl-text-[12px] pl-font-bold !pl-text-white ${C(T.isFullScreen)?"pl-ml-8":"pl-ml-4"} ${C(T.isTouchScreenPortrait)?"!pl-ml-0":"pl-absolute pl-bottom-full pl-left-0 pl-mb-[33px]"}`,children:[S.jsx("span",{children:zs(n)}),S.jsx("span",{children:" / "}),S.jsx("span",{children:zs(e)})]})})},uy=()=>S.jsx("img",{src:re.unlock,alt:"unlock-icon",onClick:()=>jo("lock"),className:"pl-size-5"}),dy=()=>{const[n,e]=P.useState(!1);return V(({videoData:{selectedSubtitle:t,videoElementSizeInfo:s,params:r}})=>({selectedSubtitle:t,videoElementSizeInfo:s,params:r}),K),S.jsxs("div",{className:"pl-relative pl-flex pl-items-center",children:[S.jsx("img",{alt:"subtitle-icon",src:C(T.isSelectedSubtitle)?re.subtitleFill:re.subtitleOutline,className:"pl-size-5 pl-cursor-pointer",onClick:dn,onDoubleClick:t=>t.stopPropagation(),onMouseOver:()=>!C(T.isTouchScreen)&&e(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&e(!1)}),n&&S.jsx(Tt,{title:xe("subtitle")})]})},fy=n=>(V(({videoData:{videoElementSizeInfo:e,params:t}})=>({videoElementSizeInfo:e,params:t}),K),S.jsxs("svg",{width:20,height:20,viewBox:"0 0 22 22",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:[S.jsx("rect",{x:"3",y:"3",width:"4",height:"4",rx:"1.5"}),S.jsx("rect",{x:"3",y:"9",width:"4",height:"4",rx:"1.5"}),S.jsx("rect",{x:"3",y:"15",width:"4",height:"4",rx:"1.5"}),S.jsx("rect",{x:"8",y:"16",width:"11",height:"2",rx:"1"}),S.jsx("rect",{x:"8",y:"10",width:"11",height:"2",rx:"1"}),S.jsx("rect",{x:"8",y:"4",width:"11",height:"2",rx:"1"})]})),hy=()=>{const[n,e]=P.useState(!1),{markers:t}=V(({videoData:{markers:l,params:c,videoElementSizeInfo:u}})=>({markers:l,params:c,videoElementSizeInfo:u}),K),{markersListPopover:s}=V(({popovers:{markersListPopover:l}})=>({markersListPopover:l}),K),r=P.useRef(null),i=ve();bs(r,()=>i(Ks(!1)));const a=(l,c,u,d,f)=>{yt()&&(yt().style.width=`${Rm(l)}px`),ps(N().currentTime,l),N().currentTime=l,i(Ks(!1)),oe(Wo(c,l,u,d,f))},o=()=>{i(Ks(!s))};return S.jsxs("div",{className:`pl-relative pl-flex pl-items-center pl-p-1 ${C(T.showMarkerListPopover)&&"pl-bg-secondary-50/[0.4] pl-rounded-[4px]"}`,ref:r,children:[S.jsx(fy,{className:"pl-fill-dark-5 pl-cursor-pointer",onClick:o,onMouseOver:()=>!C(T.isTouchScreen)&&e(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&e(!1)}),n&&S.jsx(Tt,{title:"لیست نشانگرها (e)",className:"!pl-bottom-[180%] !pl-right-[-48px]"}),S.jsx(Cs,{classNames:"!pl-p-0 pl-left-0 !pl-bg-white dark:!pl-bg-dark-13 !pl-rounded-[4px] pl-mb-[33px]",status:C(T.showMarkerListPopover),onClose:()=>{i(Ks(!1))},headerTitle:"نشانگرها",isHeader:!0,type:"popover",children:S.jsx("div",{className:"pl-mx-2 pl-mt-2 pl-flex pl-flex-col pl-gap-6",children:S.jsx("div",{className:"pl-flex pl-flex-col pl-gap-2 pl-pb-2",children:t.map(l=>S.jsx("div",{onClick:()=>a(l.time,l.id,l.title,l.description,l.sticker),className:"odd:pl-bg-main/[0.1] hover:pl-bg-main/[0.1] hover:dark:bg-white/[0.25] pl-rounded-[8px] odd:dark:pl-bg-dark-1",children:S.jsxs("div",{className:"pl-item-center pl-relative pl-mx-2 pl-flex pl-cursor-pointer pl-gap-2 pl-rounded-[4px] pl-p-2",children:[l.banner||!l.sticker?S.jsx("img",{src:l.banner?l.banner:"IMAGES.defaultMarkersListItemIcon",width:40,height:40,alt:l.title}):S.jsx("div",{className:"pl-bg-secondary dark:pl-bg-secondary-50 pl-flex pl-h-[40px] pl-w-[40px] pl-items-center pl-rounded-[6px]",children:S.jsx(Gi,{name:l.sticker,className:"pl-mx-auto pl-h-[20px] pl-w-[20px]"})}),S.jsxs("div",{className:"pl-text-gray-800 dark:pl-text-white",children:[S.jsx("p",{className:"pl-mb-1 pl-flex pl-w-[130px] pl-items-center pl-overflow-hidden pl-text-ellipsis pl-whitespace-nowrap pl-text-[14px] pl-font-bold",children:S.jsx("div",{children:l.title})}),S.jsx("p",{className:"pl-w-[200px] pl-overflow-hidden pl-text-ellipsis pl-whitespace-nowrap pl-text-[13px] pl-font-normal",children:l.description})]}),S.jsx("span",{className:"pl-bg-secondary/[0.3] dark:pl-bg-secondary/[0.6] pl-absolute pl-left-9 pl-top-2 pl-rounded-[4px] pl-p-[3px] pl-text-[12px] pl-font-bold pl-text-gray-800 dark:pl-text-white",children:zs(l.time)})]})},l.id))})})})]})},py=()=>{V(({controller:{isFullScreen:e}})=>({isFullScreen:e}),K),V(({videoData:{videoElementSizeInfo:e,params:t}})=>({videoElementSizeInfo:e,params:t}),K);let n="";return C(T.isTouchScreen)?C(T.isFullScreen)&&(n="pl-mx-6"):C(T.isFullScreen)?n="pl-mx-8":n="pl-mx-4",S.jsxs("div",{id:"player-controllbar",className:`pl-flex pl-items-center pl-justify-between ${n}`,children:[S.jsxs("div",{className:"pl-flex pl-items-center pl-gap-4",children:[S.jsx(Zm,{}),C(T.isTouchScreenLandscape)&&S.jsx(uy,{}),C(T.showPictureInPicture)&&S.jsx(Qm,{}),C(T.showSettingIcon)&&S.jsx(cy,{}),C(T.isFullScreen)&&!C(T.isStaticFormat)&&S.jsx(bu,{showQualityLevelsIcon:!0}),C(T.hasSubtitles)&&!C(T.isTouchScreenPortrait)&&S.jsx(dy,{})]}),S.jsxs("div",{className:"pl-flex pl-items-center pl-gap-4",children:[C(T.isTouchScreenPortrait)&&S.jsx(Cu,{}),!C(T.isIOS)&&S.jsx(Jm,{}),C(T.hasMarkers)&&S.jsx(hy,{})]})]})},gy=P.memo(py),my=()=>{const{subtitleText:n}=V(({videoData:{subtitleText:t,selectedSubtitle:s}})=>({subtitleText:t,selectedSubtitle:s}),K);V(({controller:{isFullScreen:t}})=>({isFullScreen:t}),K);const e=()=>{let t="";return C(T.isLock)?t="pl-bottom-3":C(T.isActiveElements)?C(T.isTouchScreenPortrait)?t="pl-bottom-[45px]":C(T.isFullScreen)?t="pl-bottom-[120px]":t="pl-bottom-[85px]":C(T.isActiveElements)||(t="pl-bottom-3"),t};return S.jsx("div",{id:"subtitle-id",style:{direction:"ltr"},className:`pl-absolute pl-w-full pl-px-6 pl-text-center pl-text-[14px] ${C(T.isFullScreen)&&"pl-text-[16px]"} pl-font-normal pl-text-white ${e()}`,children:P0(n).map((t,s)=>S.jsx("p",{className:"pl-mx-auto",style:{textShadow:"0 0 4px #000000"},children:O0(t)},s))})},yy=()=>{V(({controller:{lock:e,isFullScreen:t,isLoading:s,activeElements:r}})=>({lock:e,isFullScreen:t,isLoading:s,activeElements:r}),K),V(({videoData:{subtitles:e,selectedSubtitle:t}})=>({subtitles:e,selectedSubtitle:t}),K);let n="";return C(T.isTouchScreen)?C(T.isFullScreen)?n="pl-gap-6 pl-mb-6":n="pl-gap-3 pl-mb-0":C(T.isFullScreen)?n="pl-gap-6 pl-mb-8":n="pl-gap-4 pl-mb-3",S.jsx("div",{id:"footer",className:"pl-relative",style:{zIndex:_e.footer},children:S.jsxs(S.Fragment,{children:[C(T.showSubtitle)&&S.jsx(my,{}),!C(T.isLock)&&S.jsx(S.Fragment,{children:S.jsxs("div",{className:`animate__animated animate__faster pl-mx-auto pl-flex pl-w-full pl-flex-col pl-px-4 pl-py-3 desktop:pl-px-0 desktop:pl-py-0 ${n} ${C(T.isActiveElements)&&!C(T.isLoading)?"animate__fadeIn pl-pointer-events-auto":"animate__fadeOut pl-pointer-events-none"}`,children:[!C(T.isTouchScreenPortrait)&&S.jsx(Cu,{}),C(T.showProgressbar)&&S.jsx(Xm,{}),S.jsx(gy,{})]})})]})})},Ey=P.lazy(()=>Promise.resolve().then(()=>Oy)),Sy=P.lazy(()=>Promise.resolve().then(()=>By)),Ty=()=>S.jsx(P.Suspense,{fallback:"",children:C(T.isStaticFormat)?S.jsx(Ey,{}):S.jsx(Sy,{})}),xy=()=>{const n=ve();V(({videoData:{params:e}})=>({params:e}),K),P.useEffect(()=>{const e=()=>{document.fullscreenElement?n(is(!0)):(n(is(!1)),zo(),oe(Or("exitFullScreen")))};document.addEventListener&&(document.addEventListener("webkitfullscreenchange",e,!1),document.addEventListener("mozfullscreenchange",e,!1),document.addEventListener("fullscreenchange",e,!1),document.addEventListener("MSFullscreenChange",e,!1))},[])},vy=(n,e)=>{const t=ve(),{activeElements:s}=V(({controller:{activeElements:o}})=>({activeElements:o}),K),r=P.useRef(null),i=P.useRef(n),a=P.useRef(e);P.useEffect(()=>{i.current=n},[n]),P.useEffect(()=>{a.current=e},[e]),P.useEffect(()=>{let o=!1;const l=d=>{const{activeElements:f,isEnded:g}=R.getState().controller;g?t(Se(!0)):d.pointerType==="mouse"&&(clearTimeout(r.current),f?["player-tag","main-content","player-controllbar","video-opacity","playerElements","touchBackward","touchForward"].includes(d.target.id)&&(o=!0):t(Se(!0)),r.current=setTimeout(()=>{const{settingPopover:h,speedPopover:m,qualityLevelsPopover:p}=R.getState().popovers,{play:E}=R.getState().controller;!h&&!m&&!p&&E&&o&&t(Se(!1))},vs))},c=d=>{setTimeout(()=>{const{activeElements:f,isEnded:g,firstPlay:h}=R.getState().controller;if(clearTimeout(r.current),g)return t(Se(!0));Ht()&&!h&&!i.current&&!a.current&&(["player-tag","main-content","video-opacity","touchBackward","touchForward"].includes(d.target.id)||yr(d,"playerElements")?(t(Se(!f)),r.current=setTimeout(()=>{const{settingPopover:m,speedPopover:p,qualityLevelsPopover:E}=R.getState().popovers;!m&&!p&&!E&&t(Se(!1))},vs)):r.current=setTimeout(()=>{const{settingPopover:m,speedPopover:p,qualityLevelsPopover:E}=R.getState().popovers;!m&&!p&&!E&&t(Se(!1))},vs))},200)},u=()=>{clearTimeout(r.current),r.current=setTimeout(()=>{const{activeElements:d,isEnded:f}=R.getState().controller,{settingPopover:g,speedPopover:h,qualityLevelsPopover:m}=R.getState().popovers;f?t(Se(!0)):!g&&!h&&!m&&d&&!f&&t(Se(!d))},vs)};return document.getElementById("video-area").addEventListener("touchstart",c),document.getElementById("video-area").addEventListener("touchmove",u),document.getElementById("video-area").addEventListener("pointermove",l),()=>{const d=document.getElementById("video-area");d&&(d.removeEventListener("touchstart",c),d.removeEventListener("touchmove",u),d.removeEventListener("pointermove",l))}},[s,n,e])},by=()=>{const{firstPlay:n,isFullScreen:e}=V(({controller:{firstPlay:t,isFullScreen:s}})=>({firstPlay:t,isFullScreen:s}),K);P.useEffect(()=>{if(N()){let t;const s=()=>{t=setTimeout(()=>{zo()},Ht()?0:300)};return s(),window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s),clearTimeout(t)}}},[n,e,N()])},Cy=()=>{const{firstPlay:n}=V(({controller:{firstPlay:e}})=>({firstPlay:e}),K);V(({videoData:{details:e}})=>({details:e}),K),P.useEffect(()=>{C(T.setSubtitleFirstPlay)&&dn()},[n])},wy=P.lazy(()=>Promise.resolve().then(()=>Vy)),wu=P.lazy(()=>Promise.resolve().then(()=>Cm)),Lu=()=>{const[n,e]=P.useState(!1),[t,s]=P.useState(!1);return V(({videoData:{details:r,params:i,videoElementSizeInfo:a}})=>({details:r,params:i,videoElementSizeInfo:a}),K),V(({controller:{firstPlay:r,isFullScreen:i,isLoading:a,canPlayVideo:o}})=>({firstPlay:r,isFullScreen:i,isLoading:a,canPlayVideo:o}),K),xy(),by(),vy(n,t),Cy(),S.jsx(S.Fragment,{children:S.jsxs("div",{id:"video-area",style:{zIndex:C(T.isFullScreen)?_e.videoPlayerInFullScreen:"unset"},onClick:r=>C(T.isFirstPlay)&&Fr(r),onDoubleClick:r=>Sh(r),className:`pl-flex pl-h-full pl-max-h-screen pl-items-center pl-bg-black !pl-bg-contain !pl-bg-center !pl-bg-no-repeat desktop:pl-aspect-video ${!C(T.isTouchScreen)&&!C(T.isFullScreen)&&"!pl-rounded-[12px]"} ${C(T.isFullScreen)&&"dvh !pl-fixed !pl-w-screen"} pl-relative pl-w-full ${!C(T.isActiveElements)&&"pl-cursor-none"}`,children:[S.jsx("div",{id:"video-opacity",className:`pl-absolute pl-h-full pl-w-full pl-bg-black pl-transition-all pl-duration-500 desktop:pl-aspect-video ${!C(T.isTouchScreen)&&!C(T.isFullScreen)&&"!pl-rounded-[12px]"} ${C(T.isActiveElements)?"pl-bg-opacity-50":"pl-bg-opacity-0"}`}),S.jsx(P.Suspense,{fallback:"",children:C(T.showTouchVolumeBrightness)&&S.jsx(wy,{})}),C(T.showBackwardForward)&&S.jsx(P.Suspense,{fallback:"",children:S.jsxs("div",{className:"pl-absolute pl-right-0 pl-top-0 pl-flex pl-h-full pl-w-full pl-items-center pl-overflow-hidden",style:{zIndex:t||n?_e.backwardForwardActive:_e.backwardForwardInActive},children:[S.jsx(wu,{type:"touchForward",isRightDoubleTouched:n,setIsRightDoubleTouched:e}),S.jsx(wu,{type:"touchBackward",isLeftDoubleTouched:t,setIsLeftDoubleTouched:s})]})}),S.jsx(Ty,{}),S.jsx("div",{id:"playerElements",className:"pl-absolute pl-right-0 pl-top-0 pl-h-full pl-w-full",children:S.jsxs("div",{className:"pl-flex pl-h-full pl-w-full pl-flex-col pl-justify-between",children:[C(T.showHeader)&&S.jsx(vm,{}),C(T.showMain)&&S.jsx(Im,{}),C(T.showFooter)&&S.jsx(yy,{})]})})]})})},Ly=Object.freeze(Object.defineProperty({__proto__:null,default:Lu},Symbol.toStringTag,{value:"Module"})),Ay=Object.freeze(Object.defineProperty({__proto__:null,default:()=>S.jsx("div",{className:`pl-h-full pl-w-full desktop:pl-aspect-video ${!C(T.isTouchScreen)&&!C(T.isFullScreen)&&"!pl-rounded-[12px]"}`,children:S.jsx(Lu,{})})},Symbol.toStringTag,{value:"Module"})),Dy=()=>{const{params:n}=V(({videoData:{params:e}})=>({params:e}),K);V(({controller:{isEnded:e}})=>({isEnded:e}),K),P.useEffect(()=>{C(T.getDetails)&&qo()},[n.id,n.type])},Iy=()=>{Dy()},Au=()=>{const{params:n}=R.getState().videoData,e=N().currentTime;if(e!==0){const t=N().duration,s={video_id:+n.id,video_type:2,time:e===t?0:Math.floor(N().currentTime)};let r=localStorage.getItem("viewedVideos");if(r){let i=JSON.parse(r);i=i.filter(a=>a.video_id!==s.video_id||a.video_type!==s.video_type),i.length<10||i.shift(),i.push(s),localStorage.setItem("viewedVideos",JSON.stringify(i))}else localStorage.setItem("viewedVideos",JSON.stringify([s]))}},Ry=()=>{const n=R.dispatch,{params:e}=R.getState().videoData;let t=localStorage.getItem("viewedVideos");if(t){const r=JSON.parse(t).find(i=>i.video_id===Number(e.id)&&i.video_type===2);r&&n(S0({time:r.time}))}},ky=P.lazy(()=>Promise.resolve().then(()=>Ly)),Py=P.lazy(()=>Promise.resolve().then(()=>Gy)),_y=Object.freeze(Object.defineProperty({__proto__:null,default:()=>(V(({videoData:{params:n,details:e,isFetchDetails:t,isValidAddress:s}})=>({params:n,details:e,isFetchDetails:t,isValidAddress:s}),K),Iy(),Ry(),S.jsx(S.Fragment,{children:C(T.isFetchDetails)?C(T.isValidAddress)?S.jsx(P.Suspense,{fallback:"",children:S.jsx("div",{className:`pl-max-h-[100dvh] pl-bg-dark-1 ${!C(T.isTouchScreen)&&!C(T.isFullScreen)&&"!pl-rounded-[12px]"}`,children:S.jsx(ky,{})})}):S.jsx(P.Suspense,{fallback:"",children:S.jsx("div",{className:"pl-aspect-video pl-w-full",children:S.jsx(Py,{})})}):S.jsx("div",{className:"pl-flex pl-aspect-video pl-w-full pl-items-center pl-justify-center"})}))},Symbol.toStringTag,{value:"Module"})),Du=()=>{const n=ve(),{params:e}=V(({videoData:{params:t}})=>({params:t}),K);P.useEffect(()=>{C(T.hasCurrentTimeParams)&&(N().currentTime=e.currentTime,n(Vt(e.currentTime)))},[e.currentTime])},Iu=()=>{const{details:n}=V(({videoData:{details:e}})=>({details:e}),K);P.useEffect(()=>{const e=N().getElementsByTagName("track");for(let t=0;t<e.length;t++)e[t].addEventListener("cuechange",s=>{const r=s.target.track;let i;r.activeCues&&(i=r.activeCues[0]),i&&(setTimeout(()=>{const a=document.getElementById("subtitle-id");a&&(a.style.display="block")},300),i.onexit=()=>{const a=document.getElementById("subtitle-id");a&&(a.style.display="none")})})},[n.subtitles])},Oy=Object.freeze(Object.defineProperty({__proto__:null,default:()=>{const n=ve(),{params:e}=V(({videoData:{params:a}})=>({params:a}),K);V(({controller:{firstPlay:a}})=>({firstPlay:a}),K);const t=P.useRef(0),s=P.useRef(0),r=P.useRef(null),i=P.useRef(null);return P.useEffect(()=>{Xa(t),s.current=Date.now()},[]),P.useEffect(()=>{const a=()=>{var l;const o=(l=N())==null?void 0:l.getBoundingClientRect();o&&n(Ba(o))};return C(T.isFirstPlay)&&a(),window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a),clearInterval(i.current)}},[e.id]),Iu(),Du(),S.jsxs("video",{poster:e.banner?e.banner:void 0,preload:"metadata",autoPlay:C(T.hasAutoPlay),id:"player-tag",crossOrigin:"anonymous",className:"pl-h-full pl-w-full pl-flex-1 pl-items-center pl-rounded-[12px]",onCanPlay:hm,onPause:cm,onPlay:a=>um(a,r),onPlaying:()=>dm(t,s,r),onTimeUpdate:fm,onLoadedData:a=>pm(a,i),onError:jn,playsInline:!0,"aria-label":e.bannerAlt?e.bannerAlt:xe("bannerAlt"),children:[S.jsx("source",{src:e.id}),C(T.hasSubtitlesInParams)&&Ja(e.subtitles).map(a=>S.jsx("track",{id:`player-tracker-${a.lang}`,src:a.url,label:eo(a.lang),kind:"subtitles",srcLang:a.lang},a.id))]})}},Symbol.toStringTag,{value:"Module"})),Fy=()=>{let n=null;const{isEnded:e}=V(({controller:{isEnded:t}})=>({isEnded:t}),K);P.useEffect(()=>(n=setInterval(()=>Au(),Dm),()=>clearInterval(n)),[]),P.useEffect(()=>{C(T.isEnded)&&clearInterval(n)},[e])},My=n=>{const[e,t]=P.useState([]),[s,r]=P.useState(0),{qualityLevels:i}=V(({controller:{qualityLevels:a}})=>({qualityLevels:a}),K);P.useEffect(()=>{if(n){let a=[];switch(e.length){case 0:a=[n];break;case 1:a=[n,...e];break;case 2:a=[n,...e],oe(Go(`${a[0]}P`,`${a[1]}P`,i.indexOf(a[0])-i.indexOf(a[1])));break;default:a=[n,e[0],e[1]],a[1]!==a[2]&&oe(Go(`${a[1]}P`,`${a[2]}P`,i.indexOf(a[1])-i.indexOf(a[2])));break}t(a)}},[n]),P.useEffect(()=>{e.length===3&&e[0]===e[2]?(oe(gh(s,e)),t([]),r(0)):r(new Date().getTime())},[e])},Ny=()=>{P.useEffect(()=>{const n=()=>{Au()};return window.addEventListener("beforeunload",n),()=>window.removeEventListener("beforeunload",n)},[])},By=Object.freeze(Object.defineProperty({__proto__:null,default:()=>{const[n,e]=P.useState(void 0),t=ve(),{params:s,details:r,videoElementSizeInfo:i}=V(({videoData:{params:p,details:E,videoElementSizeInfo:x}})=>({params:p,details:E,videoElementSizeInfo:x}),K),{currentTime:a,duration:o}=V(({controller:{currentTime:p,duration:E,isEnded:x,firstPlay:v}})=>({currentTime:p,duration:E,isEnded:x,firstPlay:v}),K),l=P.useRef(null),c=P.useRef(0),u=P.useRef(0),d=P.useRef(0),f=P.useRef(0),g=P.useRef(0),h=P.useRef(1),m=P.useRef(N()?N().currentTime:0);return Fy(),Ny(),P.useLayoutEffect(()=>{let p=new he(Qg());return Xa(g),d.current=Date.now(),he.isSupported()?(p.attachMedia(N()),p.on(he.Events.MEDIA_ATTACHED,()=>lu(he,p)),p.on(he.Events.FRAG_BUFFERED,()=>uu(p)),p.on(he.Events.FRAG_CHANGED,(E,x)=>du(p,x,e)),p.on(he.Events.FRAG_PARSED,(E,x)=>fu(p,x,e)),p.on(he.Events.ERROR,(E,x)=>ct(hu(x))),N().addEventListener("waiting",E=>pu(E,u)),N().addEventListener("seeking",E=>em(E,u)),N().addEventListener("play",E=>tm(E,l)),N().addEventListener("playing",()=>sm(h,g,d,f,l,c,u,m)),N().addEventListener("pause",gu),N().addEventListener("timeupdate",nm),N().addEventListener("canplay",mu),N().addEventListener("ended",rm),N().addEventListener("error",jn),document.addEventListener("visibilitychange",Eu)):N().canPlayType("application/vnd.apple.mpegurl")&&(N().src=r.stream_link,N().addEventListener("waiting",E=>pu(E,u)),N().addEventListener("play",E=>im(E,l)),N().addEventListener("playing",am),N().addEventListener("canplay",mu),N().addEventListener("timeupdate",om),N().addEventListener("ended",lm),N().addEventListener("pause",gu),au()),()=>{yh(),p.detachMedia(),p.off(he.Events.MEDIA_ATTACHED,()=>lu(he,p)),p.off(he.Events.FRAG_BUFFERED,()=>uu(p)),p.off(he.Events.FRAG_CHANGED,(E,x)=>du(p,x,e)),p.off(he.Events.FRAG_PARSED,(E,x)=>fu(p,x,e)),p.off(he.Events.ERROR,(E,x)=>hu(x)),p.off(he.Events.MANIFEST_PARSED,()=>ou(p)),document.removeEventListener("visibilitychange",Eu)}},[r.stream_link]),P.useEffect(()=>{a<o&&C(T.isEnded)&&t(gr(!1))},[a]),P.useEffect(()=>{C(T.hasPlayStatusParams)&&(s.playStatus?N().play():N().pause())},[s.playStatus]),My(n),Iu(),Du(),S.jsx(S.Fragment,{children:S.jsxs("video",{poster:s.banner?s.banner:r.banner,preload:"metadata",crossOrigin:"anonymous",id:"player-tag",playsInline:!0,className:"pl-h-full pl-flex-1 pl-items-center",style:{width:"100%",height:"100%",maxWidth:i.width?i.width:"100%",maxHeight:i.width?i.width<i.height?i.width*9/16:i.width*16/9:"100%"},autoPlay:C(T.hasAutoPlay),children:[S.jsx("img",{onLoad:()=>f.current=Date.now(),src:s.banner?s.banner:r.banner,alt:s.bannerAlt?s.bannerAlt:C(T.isStaticFormat)?xe("bannerAlt"):r.title,className:"pl-size-full"}),C(T.hasSubtitlesInDetails)&&Ja(r.subtitles).map(p=>S.jsx("track",{id:`player-tracker-${p.lang}`,src:p.url,label:eo(p.lang),kind:"subtitles",srcLang:p.lang},p.id))]})})}},Symbol.toStringTag,{value:"Module"})),Uy=({className:n,onClick:e})=>S.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,onClick:e,children:S.jsxs("g",{opacity:"0.7",children:[S.jsx("path",{d:"M11.6997 10.7997C12.2247 10.2747 13.1247 10.6497 13.1247 11.3914V13.833C13.1247 15.2664 12.6081 16.3414 11.6831 16.858C11.3081 17.0664 10.8914 17.1664 10.4581 17.1664C9.79141 17.1664 9.07474 16.9414 8.34141 16.483L7.80807 16.1497C7.35807 15.8664 7.28307 15.233 7.65807 14.858L11.6997 10.7997Z"}),S.jsx("path",{d:"M18.141 1.85742C17.891 1.60742 17.4827 1.60742 17.2327 1.85742L13.1077 5.98242C13.0577 4.64909 12.5577 3.64909 11.6743 3.15742C10.741 2.64076 9.54935 2.77409 8.33268 3.53242L5.90768 5.04909C5.74102 5.14909 5.54935 5.20742 5.35768 5.20742H4.58268H4.16602C2.14935 5.20742 1.04102 6.31575 1.04102 8.33242V11.6658C1.04102 13.6824 2.14935 14.7908 4.16602 14.7908H4.29935L1.84935 17.2408C1.59935 17.4908 1.59935 17.8991 1.84935 18.1491C1.98268 18.2658 2.14102 18.3324 2.30768 18.3324C2.47435 18.3324 2.63268 18.2658 2.75768 18.1408L18.141 2.75742C18.3994 2.50742 18.3994 2.10742 18.141 1.85742Z"})]})}),$y=({className:n,onClick:e})=>S.jsx("svg",{width:"13",height:"16",viewBox:"0 0 13 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,onClick:e,children:S.jsx("path",{d:"M10.6827 1.14944C9.74935 0.632778 8.55768 0.766111 7.34102 1.52444L4.90768 3.04944C4.74102 3.14944 4.54935 3.20778 4.35768 3.20778H3.58268H3.16602C1.14935 3.20778 0.0410156 4.31611 0.0410156 6.33278V9.66611C0.0410156 11.6828 1.14935 12.7911 3.16602 12.7911H3.58268H4.35768C4.54935 12.7911 4.74102 12.8494 4.90768 12.9494L7.34102 14.4744C8.07435 14.9328 8.79102 15.1578 9.45768 15.1578C9.89102 15.1578 10.3077 15.0578 10.6827 14.8494C11.6077 14.3328 12.1243 13.2578 12.1243 11.8244V4.17444C12.1243 2.74111 11.6077 1.66611 10.6827 1.14944Z"})}),Vy=Object.freeze(Object.defineProperty({__proto__:null,default:()=>{const[n,e]=P.useState(""),t=ve(),{settings:s}=V(({user:{settings:l}})=>({settings:l}),K),r=P.useRef(s.brightness),i=P.useRef(s.volume),a=P.useRef(n);P.useEffect(()=>{a.current=n},[n]),P.useEffect(()=>{let l=0;const c=f=>{C(T.hidePopovers)&&!yr(f,"progress-area")&&(l=f.touches[0].clientY)},u=f=>{C(T.hidePopovers)&&!yr(f,"progress-area")&&(f.stopPropagation(),f.touches[0].clientX>window.innerWidth/2?o(f,"volume",l,window.innerHeight):f.touches[0].clientX<window.innerWidth/2&&o(f,"brightness",l,window.innerHeight))},d=()=>{const{settings:f}=R.getState().user;a.current==="brightness"&&r.current!==f.brightness?(oe(dh(r.current,f.brightness)),r.current=f.brightness):a.current==="volume"&&i.current!==f.volume&&(oe(ln(i.current,f.volume)),i.current=f.volume),setTimeout(()=>e(""),500)};return document.addEventListener("touchstart",f=>c(f)),document.addEventListener("touchmove",f=>u(f)),document.addEventListener("touchend",()=>d()),()=>{document.removeEventListener("touchstart",f=>c(f)),document.removeEventListener("touchmove",f=>u(f)),document.removeEventListener("touchend",()=>d())}},[]),P.useEffect(()=>{s.volume===0&&!n&&(i.current=0)},[s.volume]);const o=(l,c,u,d)=>{const{settings:f}=R.getState().user,{activePointerProgressBar:g}=R.getState().controller;try{g||t(Se(!1)),l.stopPropagation(),e(c);const{height:h}=document.getElementsByClassName("pl-bar")[0].getBoundingClientRect();if(c==="volume"){const m=f.volume+(u-l.touches[0].clientY)/40*h/d;let p;m>100?p=100:m<0?p=0:p=Math.ceil(Math.abs(m)),t(ot({...f,volume:p})),N().volume=p/100}else if(c==="brightness"){const m=f.brightness+(u-l.touches[0].clientY)/40*h/d;m>100?t(ot({...f,brightness:100})):m<0?t(ot({...f,brightness:0})):t(ot({...f,brightness:Math.ceil(Math.abs(m))}))}}catch{return!1}};return S.jsxs("div",{id:"volume-brightness",children:[S.jsx("div",{className:"pl-fixed pl-right-0 pl-top-0 pl-h-screen pl-w-screen pl-bg-black",style:{opacity:s.brightness<10?.9:1-s.brightness/100}}),S.jsxs("div",{className:"pl-absolute pl-right-0 pl-top-0 pl-flex pl-h-full pl-w-full pl-items-center pl-justify-between",children:[S.jsx("div",{className:"pl-flex pl-h-full pl-flex-1 pl-items-center pl-pr-6",children:S.jsx("div",{id:"volume-progressbar",className:`pl-bar pl-relative pl-h-[200px] pl-w-6 ${n==="volume"&&"pl-bg-gray-300"} pl-flex pl-max-h-[80vh] pl-items-end pl-justify-end pl-overflow-hidden pl-rounded-[50px]`,children:n==="volume"&&S.jsxs(S.Fragment,{children:[S.jsx("div",{className:"pl-absolute pl-w-full pl-rounded-b-[50px] pl-bg-secondary-600",style:{height:`${s.volume}%`}}),S.jsxs("div",{className:"pl-mb-[7px] pl-ml-0.5 pl-flex pl-items-center pl-gap-1",children:[S.jsxs("div",{className:"pl-relative pl-flex pl-items-center",children:[s.volume>0&&S.jsx("div",{className:"pl-absolute pl-right-[2px] pl-flex pl-h-2 pl-w-2 pl-items-center pl-justify-center pl-rounded-full pl-border-2 pl-border-r-2 pl-border-transparent pl-border-r-z-yellow-light"}),s.volume>33&&S.jsx("div",{className:"pl-absolute pl-right-[-1px] pl-flex pl-h-3 pl-w-3 pl-items-center pl-justify-center pl-rounded-full pl-border-2 pl-border-r-2 pl-border-transparent pl-border-r-z-yellow-light"}),s.volume>66&&S.jsx("div",{className:"pl-absolute pl-right-[-4px] pl-flex pl-h-4 pl-w-4 pl-items-center pl-justify-center pl-rounded-full pl-border-2 pl-border-r-2 pl-border-transparent pl-border-r-z-yellow-light"})]}),s.volume===0?S.jsx(Uy,{className:"pl-z-[1] pl-h-[13px] pl-w-[13px] pl-fill-dark-7"}):S.jsx($y,{className:"pl-z-[1] pl-h-[13px] pl-w-[13px] pl-fill-dark-7"})]})]})})}),n&&S.jsx("div",{className:"pl-flex pl-h-[54px] pl-w-[54px] pl-items-center pl-justify-center pl-rounded-full pl-bg-secondary-700/[0.8] pl-text-[32px] pl-font-normal pl-text-white",children:n==="volume"?s.volume:s.brightness}),S.jsx("div",{className:"pl-flex pl-h-full pl-flex-1 pl-items-center pl-justify-end pl-pl-6",children:S.jsx("div",{id:"brightness-progressbar",className:`pl-bar pl-relative pl-h-[200px] pl-w-6 ${n==="brightness"&&"pl-bg-gray-300"} pl-flex pl-max-h-[80vh] pl-items-end pl-justify-end pl-overflow-hidden pl-rounded-[50px]`,children:n==="brightness"&&S.jsxs(S.Fragment,{children:[S.jsx("div",{className:"pl-absolute pl-w-full pl-rounded-b-[50px] pl-bg-primary-600",style:{height:`${s.brightness}%`}}),S.jsx("div",{className:"pl-mb-[7px] pl-ml-0.5 pl-flex pl-items-center pl-gap-1",style:{opacity:s.brightness/100},children:S.jsx("img",{alt:"",src:re.sun,className:"pl-size-5 pl-flex-1"})})]})})})]})]})}},Symbol.toStringTag,{value:"Module"})),Gy=Object.freeze(Object.defineProperty({__proto__:null,default:()=>S.jsxs("div",{className:"pl-flex pl-h-full pl-w-full pl-flex-col pl-items-center pl-justify-center pl-rounded-2xl",children:[S.jsx("div",{className:"pl-flex pl-justify-center",children:S.jsx("img",{src:re.notFound,alt:"notFound",width:120,height:70})}),S.jsx("h1",{className:"pl-mb-2 pl-mt-4 pl-text-xs pl-font-medium pl-text-black/[0.87]",children:xe("notFoundVideo")}),S.jsx("p",{className:"pl-text-xs pl-font-medium pl-text-black/[0.50]",children:xe("watchSimilarVideo")})]})},Symbol.toStringTag,{value:"Module"}));Ae.FeatureExcept=Yn,Ae.MiniPlayerLibrary=Sm,Ae.VideoPlayerLibrary=Dh,Object.defineProperty(Ae,Symbol.toStringTag,{value:"Module"})});
@@ -4493,7 +4493,7 @@ const Hi = {
4493
4493
  }), ut("KeyC", () => {
4494
4494
  B(w.isPressKeyC) && cf();
4495
4495
  });
4496
- }, df = Za(() => import("./staticPlayer-gyGSd3Rl.js")), ff = Za(() => import("./vodPlayer-Dnsv67UV.js")), hf = (n) => {
4496
+ }, df = Za(() => import("./staticPlayer-BTRN9YU3.js")), ff = Za(() => import("./vodPlayer-CNxFD4OL.js")), hf = (n) => {
4497
4497
  const { params: e } = Ue(({ videoData: { isReady: s, params: i } }) => ({ isReady: s, params: i }), si);
4498
4498
  $e(() => (e.id && n.params.id !== e.id && (e.type === xt.static && (W().pause(), W().removeAttribute("src"), W().load()), Ir()), () => Ir()), [n.params.id]), T0(n.params), uf(), Ue(({ controller: { isFullScreen: s } }) => ({ isFullScreen: s }), si);
4499
4499
  let t = /* @__PURE__ */ se(Jt, {});
@@ -1,9 +1,9 @@
1
1
  import { jsx as L, Fragment as B, jsxs as Q } from "react/jsx-runtime";
2
- import { u as g, s as v, c as h, C as m, e as P, z as w, A as $, a as z, m as a, H as r, B as W, j, D, E as S, F as I, G as V, J, K as F, L as _, M as q, N as K, O as X, P as C, Q as Y, R as k, S as Z, r as ee, T as H, U as ae, V as ne, W as te, X as se, Y as ie, Z as de, _ as re, $ as oe, t as le, w as ue, x as ce } from "./index-XQMSuoNz.js";
2
+ import { u as g, s as v, c as h, C as m, e as P, z as w, A as $, a as z, m as a, H as r, B as W, j, D, E as S, F as I, G as V, J, K as F, L as _, M as q, N as K, O as X, P as C, Q as Y, R as k, S as Z, r as ee, T as H, U as ae, V as ne, W as te, X as se, Y as ie, Z as de, _ as re, $ as oe, t as le, w as ue, x as ce } from "./index-CW_ClzaD.js";
3
3
  import { useEffect as E, useState as A, useRef as c, useLayoutEffect as Ee } from "react";
4
- import { c as fe } from "./videoArea-BPmDAlBS.js";
5
- import { a as x } from "./user.actions-BwJhTy_X.js";
6
- import { u as he, a as me } from "./useHideSubtitle-ltrIzN4m.js";
4
+ import { c as fe } from "./videoArea-B4cjXIvK.js";
5
+ import { a as x } from "./user.actions-C6v7qndr.js";
6
+ import { u as he, a as me } from "./useHideSubtitle-i05TvEsd.js";
7
7
  const pe = () => {
8
8
  let i = null;
9
9
  const { isEnded: s } = g(({ controller: { isEnded: f } }) => ({ isEnded: f }), v);
@@ -1,5 +1,5 @@
1
1
  import { jsxs as e, jsx as l } from "react/jsx-runtime";
2
- import { I as s, t } from "./index-XQMSuoNz.js";
2
+ import { I as s, t } from "./index-CW_ClzaD.js";
3
3
  const a = () => /* @__PURE__ */ e("div", { className: "pl-flex pl-h-full pl-w-full pl-flex-col pl-items-center pl-justify-center pl-rounded-2xl", children: [
4
4
  /* @__PURE__ */ l("div", { className: "pl-flex pl-justify-center", children: /* @__PURE__ */ l("img", { src: s.notFound, alt: "notFound", width: 120, height: 70 }) }),
5
5
  /* @__PURE__ */ l("h1", { className: "pl-mb-2 pl-mt-4 pl-text-xs pl-font-medium pl-text-black/[0.87]", children: t("notFoundVideo") }),
@@ -1,6 +1,6 @@
1
1
  import { jsx as e } from "react/jsx-runtime";
2
- import { c as o, C as r } from "./index-XQMSuoNz.js";
3
- import { V as i } from "./videoArea-BPmDAlBS.js";
2
+ import { c as o, C as r } from "./index-CW_ClzaD.js";
3
+ import { V as i } from "./videoArea-B4cjXIvK.js";
4
4
  const a = () => /* @__PURE__ */ e(
5
5
  "div",
6
6
  {
@@ -1,23 +1,23 @@
1
1
  import { jsxs as h, jsx as u } from "react/jsx-runtime";
2
- import { useRef as n, useEffect as m } from "react";
3
- import { a as y, u as p, s as f, j as P, c as t, C as s, k as S, l as V, n as b, o as w, p as L, q as v, r as D, t as E, w as R, x as T, m as A, y as C } from "./index-XQMSuoNz.js";
4
- import { u as x, a as k } from "./useHideSubtitle-ltrIzN4m.js";
2
+ import { useRef as n, useEffect as p } from "react";
3
+ import { a as y, u as m, s as f, j as P, c as t, C as s, k as S, l as V, n as b, o as w, p as L, q as v, r as D, t as E, w as R, x as T, m as x, y as A } from "./index-CW_ClzaD.js";
4
+ import { u as C, a as k } from "./useHideSubtitle-i05TvEsd.js";
5
5
  const N = () => {
6
- const g = y(), { params: e } = p(({ videoData: { params: a } }) => ({ params: a }), f);
7
- p(({ controller: { firstPlay: a } }) => ({ firstPlay: a }), f);
6
+ const g = y(), { params: e } = m(({ videoData: { params: a } }) => ({ params: a }), f);
7
+ m(({ controller: { firstPlay: a } }) => ({ firstPlay: a }), f);
8
8
  const i = n(0), r = n(0), o = n(null), l = n(null);
9
- return m(() => {
9
+ return p(() => {
10
10
  P(i), r.current = Date.now();
11
- }, []), m(() => {
11
+ }, []), p(() => {
12
12
  const a = () => {
13
13
  var c;
14
- const d = (c = A()) == null ? void 0 : c.getBoundingClientRect();
15
- d && g(C(d));
14
+ const d = (c = x()) == null ? void 0 : c.getBoundingClientRect();
15
+ d && g(A(d));
16
16
  };
17
17
  return t(s.isFirstPlay) && a(), window.addEventListener("resize", a), () => {
18
18
  window.removeEventListener("resize", a), clearInterval(l.current);
19
19
  };
20
- }, [e.id]), x(), k(), /* @__PURE__ */ h(
20
+ }, [e.id]), C(), k(), /* @__PURE__ */ h(
21
21
  "video",
22
22
  {
23
23
  poster: e.banner ? e.banner : void 0,
@@ -25,7 +25,7 @@ const N = () => {
25
25
  autoPlay: t(s.hasAutoPlay),
26
26
  id: "player-tag",
27
27
  crossOrigin: "anonymous",
28
- className: "pl-h-full pl-w-full pl-flex-1 pl-items-center",
28
+ className: "pl-h-full pl-w-full pl-flex-1 pl-items-center pl-rounded-[12px]",
29
29
  onCanPlay: S,
30
30
  onPause: V,
31
31
  onPlay: (a) => b(a, o),
@@ -1,6 +1,6 @@
1
1
  import { jsx as l, jsxs as p, Fragment as C } from "react/jsx-runtime";
2
2
  import { useState as j, useRef as b, useEffect as x } from "react";
3
- import { a as H, u as T, s as V, I as P, c as N, C as L, b as E, d as w, e as M, f as B, v as z, h as R, i as m, m as k } from "./index-XQMSuoNz.js";
3
+ import { a as H, u as T, s as V, I as P, c as N, C as L, b as E, d as w, e as M, f as B, v as z, h as R, i as m, m as k } from "./index-CW_ClzaD.js";
4
4
  const A = ({ className: s, onClick: i }) => /* @__PURE__ */ l(
5
5
  "svg",
6
6
  {
@@ -1,5 +1,5 @@
1
1
  import { useEffect as r } from "react";
2
- import { a as l, u as c, s as o, c as d, C as p, m as u, a1 as T } from "./index-XQMSuoNz.js";
2
+ import { a as l, u as c, s as o, c as d, C as p, m as u, a1 as T } from "./index-CW_ClzaD.js";
3
3
  const y = () => {
4
4
  const a = l(), { params: e } = c(({ videoData: { params: t } }) => ({ params: t }), o);
5
5
  r(() => {
@@ -1,4 +1,4 @@
1
- import { d as n, a0 as l, m as s } from "./index-XQMSuoNz.js";
1
+ import { d as n, a0 as l, m as s } from "./index-CW_ClzaD.js";
2
2
  const v = () => {
3
3
  const { params: a } = n.getState().videoData, o = s().currentTime;
4
4
  if (o !== 0) {
@@ -1,6 +1,6 @@
1
1
  import { jsx as t, jsxs as u, Fragment as P } from "react/jsx-runtime";
2
2
  import { useRef as F, useCallback as Xe, useState as k, useEffect as C, memo as Q, forwardRef as Ve, lazy as re, Suspense as he } from "react";
3
- import { u as g, s as v, c as s, C as o, I as T, a2 as $e, t as I, a as O, h as E, m as y, a3 as Y, a4 as Ae, a5 as Ie, a6 as z, d as b, a7 as Re, a8 as se, a9 as qe, aa as oe, ab as Me, ac as xe, ad as we, e as D, ae as He, af as X, ag as We, ah as Ue, ai as _e, aj as Qe, ak as Ze, al as ue, v as me, i as be, am as te, an as N, ao as Ge, ap as R, aq as ke, ar as Ye, as as Pe, at as Je, au as le, av as Se, aw as ie, ax as Ke, ay as et, az as Ne, aA as Fe, aB as tt, aC as ze, b as lt, aD as it } from "./index-XQMSuoNz.js";
3
+ import { u as g, s as v, c as s, C as o, I as T, a2 as $e, t as I, a as O, h as E, m as y, a3 as Y, a4 as Ae, a5 as Ie, a6 as z, d as b, a7 as Re, a8 as se, a9 as qe, aa as oe, ab as Me, ac as xe, ad as we, e as D, ae as He, af as X, ag as We, ah as Ue, ai as _e, aj as Qe, ak as Ze, al as ue, v as me, i as be, am as te, an as N, ao as Ge, ap as R, aq as ke, ar as Ye, as as Pe, at as Je, au as le, av as Se, aw as ie, ax as Ke, ay as et, az as Ne, aA as Fe, aB as tt, aC as ze, b as lt, aD as it } from "./index-CW_ClzaD.js";
4
4
  import { createPortal as st } from "react-dom";
5
5
  const ot = () => {
6
6
  const { details: e, params: l } = g(({ videoData: { details: i, params: n } }) => ({ details: i, params: n }), v);
@@ -1221,7 +1221,7 @@ const jt = ({ className: e, onClick: l, onMouseOver: i, onMouseLeave: n }) => /*
1221
1221
  }
1222
1222
  ) })
1223
1223
  ] }) });
1224
- }, ll = re(() => import("./staticVideoTag-2d4nOyft.js")), il = re(() => import("./nonStaticVideoTag-DHCx3xCm.js")), sl = () => /* @__PURE__ */ t(he, { fallback: "", children: s(o.isStaticFormat) ? /* @__PURE__ */ t(ll, {}) : /* @__PURE__ */ t(il, {}) }), ol = () => {
1224
+ }, ll = re(() => import("./staticVideoTag-NEy2u0WU.js")), il = re(() => import("./nonStaticVideoTag-B3sAiPBp.js")), sl = () => /* @__PURE__ */ t(he, { fallback: "", children: s(o.isStaticFormat) ? /* @__PURE__ */ t(ll, {}) : /* @__PURE__ */ t(il, {}) }), ol = () => {
1225
1225
  const e = O();
1226
1226
  g(({ videoData: { params: l } }) => ({ params: l }), v), C(() => {
1227
1227
  const l = () => {
@@ -1300,7 +1300,7 @@ const jt = ({ className: e, onClick: l, onMouseOver: i, onMouseLeave: n }) => /*
1300
1300
  g(({ videoData: { details: l } }) => ({ details: l }), v), C(() => {
1301
1301
  s(o.setSubtitleFirstPlay) && Se();
1302
1302
  }, [e]);
1303
- }, pl = re(() => import("./touchVolumeBrightness-BmenRx76.js")), Ee = re(() => Promise.resolve().then(() => pt)), cl = () => {
1303
+ }, pl = re(() => import("./touchVolumeBrightness-DWgEsXvn.js")), Ee = re(() => Promise.resolve().then(() => pt)), cl = () => {
1304
1304
  const [e, l] = k(!1), [i, n] = k(!1);
1305
1305
  return g(
1306
1306
  ({ videoData: { details: r, params: a, videoElementSizeInfo: m } }) => ({
@@ -1,7 +1,7 @@
1
1
  import { jsx as e, Fragment as d } from "react/jsx-runtime";
2
- import { u as i, s as o, c as l, C as t, g as m } from "./index-XQMSuoNz.js";
2
+ import { u as i, s as o, c as l, C as t, g as m } from "./index-CW_ClzaD.js";
3
3
  import { useEffect as u, lazy as c, Suspense as r } from "react";
4
- import { h as f } from "./user.actions-BwJhTy_X.js";
4
+ import { h as f } from "./user.actions-C6v7qndr.js";
5
5
  const h = () => {
6
6
  const { params: a } = i(({ videoData: { params: s } }) => ({ params: s }), o);
7
7
  i(({ controller: { isEnded: s } }) => ({ isEnded: s }), o), u(() => {
@@ -9,7 +9,7 @@ const h = () => {
9
9
  }, [a.id, a.type]);
10
10
  }, v = () => {
11
11
  h();
12
- }, D = c(() => import("./videoArea-BPmDAlBS.js").then((a) => a.v)), y = c(() => import("./notActive-DmTPzw_E.js")), b = () => (i(
12
+ }, D = c(() => import("./videoArea-B4cjXIvK.js").then((a) => a.v)), y = c(() => import("./notActive-B0SZitoZ.js")), b = () => (i(
13
13
  ({ videoData: { params: a, details: s, isFetchDetails: p, isValidAddress: n } }) => ({ params: a, details: s, isFetchDetails: p, isValidAddress: n }),
14
14
  o
15
15
  ), v(), f(), /* @__PURE__ */ e(d, { children: l(t.isFetchDetails) ? l(t.isValidAddress) ? /* @__PURE__ */ e(r, { fallback: "", children: /* @__PURE__ */ e(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hamrahi-player-library",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"