r.width&&(c=r.width),c=Math.round(c),this.el_.style.right=`-${c}px`,this.write(n)}write(e){Vn(this.el_,e)}updateTime(e,i,n,r){this.requestNamedAnimationFrame("TimeTooltip#updateTime",()=>{let s;const a=this.player_.duration();if(this.player_.liveTracker&&this.player_.liveTracker.isLive()){const o=this.player_.liveTracker.liveWindow(),l=o-i*o;s=(l<1?"":"-")+gr(l,o)}else s=gr(n,a);this.update(e,i,s),r&&r()})}}B.registerComponent("TimeTooltip",I4);class Jp extends B{constructor(e,i){super(e,i),this.setIcon("circle"),this.update=Fi(Ee(this,this.update),ni)}createEl(){return super.createEl("div",{className:"vjs-play-progress vjs-slider-bar"},{"aria-hidden":"true"})}update(e,i){const n=this.getChild("timeTooltip");if(!n)return;const r=this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime();n.updateTime(e,i,r)}}Jp.prototype.options_={children:[]};!Tt&&!Ri&&Jp.prototype.options_.children.push("timeTooltip");B.registerComponent("PlayProgressBar",Jp);class _T extends B{constructor(e,i){super(e,i),this.update=Fi(Ee(this,this.update),ni)}createEl(){return super.createEl("div",{className:"vjs-mouse-display"})}update(e,i){const n=i*this.player_.duration();this.getChild("timeTooltip").updateTime(e,i,n,()=>{this.el_.style.left=`${e.width*i}px`})}}_T.prototype.options_={children:["timeTooltip"]};B.registerComponent("MouseTimeDisplay",_T);const Tl=5,xy=12;class Zp extends Yp{constructor(e,i){super(e,i),this.setEventHandlers_()}setEventHandlers_(){this.update_=Ee(this,this.update),this.update=Fi(this.update_,ni),this.on(this.player_,["ended","durationchange","timeupdate"],this.update),this.player_.liveTracker&&this.on(this.player_.liveTracker,"liveedgechange",this.update),this.updateInterval=null,this.enableIntervalHandler_=e=>this.enableInterval_(e),this.disableIntervalHandler_=e=>this.disableInterval_(e),this.on(this.player_,["playing"],this.enableIntervalHandler_),this.on(this.player_,["ended","pause","waiting"],this.disableIntervalHandler_),"hidden"in V&&"visibilityState"in V&&this.on(V,"visibilitychange",this.toggleVisibility_)}toggleVisibility_(e){V.visibilityState==="hidden"?(this.cancelNamedAnimationFrame("SeekBar#update"),this.cancelNamedAnimationFrame("Slider#update"),this.disableInterval_(e)):(!this.player_.ended()&&!this.player_.paused()&&this.enableInterval_(),this.update())}enableInterval_(){this.updateInterval||(this.updateInterval=this.setInterval(this.update,ni))}disableInterval_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&e&&e.type!=="ended"||this.updateInterval&&(this.clearInterval(this.updateInterval),this.updateInterval=null)}createEl(){return super.createEl("div",{className:"vjs-progress-holder"},{"aria-label":this.localize("Progress Bar")})}update(e){if(V.visibilityState==="hidden")return;const i=super.update();return this.requestNamedAnimationFrame("SeekBar#update",()=>{const n=this.player_.ended()?this.player_.duration():this.getCurrentTime_(),r=this.player_.liveTracker;let s=this.player_.duration();r&&r.isLive()&&(s=this.player_.liveTracker.liveCurrentTime()),this.percent_!==i&&(this.el_.setAttribute("aria-valuenow",(i*100).toFixed(2)),this.percent_=i),(this.currentTime_!==n||this.duration_!==s)&&(this.el_.setAttribute("aria-valuetext",this.localize("progress bar timing: currentTime={1} duration={2}",[gr(n,s),gr(s,s)],"{1} of {2}")),this.currentTime_=n,this.duration_=s),this.bar&&this.bar.update(bs(this.el()),this.getProgress())}),i}userSeek_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&this.player_.liveTracker.nextSeekedFromUser(),this.player_.currentTime(e)}getCurrentTime_(){return this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime()}getPercent(){const e=this.getCurrentTime_();let i;const n=this.player_.liveTracker;return n&&n.isLive()?(i=(e-n.seekableStart())/n.liveWindow(),n.atLiveEdge()&&(i=1)):i=e/this.player_.duration(),i}handleMouseDown(e){ho(e)&&(e.stopPropagation(),this.videoWasPlaying=!this.player_.paused(),this.player_.pause(),super.handleMouseDown(e))}handleMouseMove(e,i=!1){if(!ho(e)||isNaN(this.player_.duration()))return;!i&&!this.player_.scrubbing()&&this.player_.scrubbing(!0);let n;const r=this.calculateDistance(e),s=this.player_.liveTracker;if(!s||!s.isLive())n=r*this.player_.duration(),n===this.player_.duration()&&(n=n-.1);else{if(r>=.99){s.seekToLiveEdge();return}const a=s.seekableStart(),o=s.liveCurrentTime();if(n=a+r*s.liveWindow(),n>=o&&(n=o),n<=a&&(n=a+.1),n===1/0)return}this.userSeek_(n)}enable(){super.enable();const e=this.getChild("mouseTimeDisplay");e&&e.show()}disable(){super.disable();const e=this.getChild("mouseTimeDisplay");e&&e.hide()}handleMouseUp(e){super.handleMouseUp(e),e&&e.stopPropagation(),this.player_.scrubbing(!1),this.player_.trigger({type:"timeupdate",target:this,manuallyTriggered:!0}),this.videoWasPlaying?Ci(this.player_.play()):this.update_()}stepForward(){this.userSeek_(this.player_.currentTime()+Tl)}stepBack(){this.userSeek_(this.player_.currentTime()-Tl)}handleAction(e){this.player_.paused()?this.player_.play():this.player_.pause()}handleKeyDown(e){const i=this.player_.liveTracker;if(re.isEventKey(e,"Space")||re.isEventKey(e,"Enter"))e.preventDefault(),e.stopPropagation(),this.handleAction(e);else if(re.isEventKey(e,"Home"))e.preventDefault(),e.stopPropagation(),this.userSeek_(0);else if(re.isEventKey(e,"End"))e.preventDefault(),e.stopPropagation(),i&&i.isLive()?this.userSeek_(i.liveCurrentTime()):this.userSeek_(this.player_.duration());else if(/^[0-9]$/.test(re(e))){e.preventDefault(),e.stopPropagation();const n=(re.codes[re(e)]-re.codes[0])*10/100;i&&i.isLive()?this.userSeek_(i.seekableStart()+i.liveWindow()*n):this.userSeek_(this.player_.duration()*n)}else re.isEventKey(e,"PgDn")?(e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()-Tl*xy)):re.isEventKey(e,"PgUp")?(e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()+Tl*xy)):super.handleKeyDown(e)}dispose(){this.disableInterval_(),this.off(this.player_,["ended","durationchange","timeupdate"],this.update),this.player_.liveTracker&&this.off(this.player_.liveTracker,"liveedgechange",this.update),this.off(this.player_,["playing"],this.enableIntervalHandler_),this.off(this.player_,["ended","pause","waiting"],this.disableIntervalHandler_),"hidden"in V&&"visibilityState"in V&&this.off(V,"visibilitychange",this.toggleVisibility_),super.dispose()}}Zp.prototype.options_={children:["loadProgressBar","playProgressBar"],barName:"playProgressBar"};!Tt&&!Ri&&Zp.prototype.options_.children.splice(1,0,"mouseTimeDisplay");B.registerComponent("SeekBar",Zp);class TT extends B{constructor(e,i){super(e,i),this.handleMouseMove=Fi(Ee(this,this.handleMouseMove),ni),this.throttledHandleMouseSeek=Fi(Ee(this,this.handleMouseSeek),ni),this.handleMouseUpHandler_=n=>this.handleMouseUp(n),this.handleMouseDownHandler_=n=>this.handleMouseDown(n),this.enable()}createEl(){return super.createEl("div",{className:"vjs-progress-control vjs-control"})}handleMouseMove(e){const i=this.getChild("seekBar");if(!i)return;const n=i.getChild("playProgressBar"),r=i.getChild("mouseTimeDisplay");if(!n&&!r)return;const s=i.el(),a=co(s);let o=Tc(s,e).x;o=bo(o,0,1),r&&r.update(a,o),n&&n.update(a,i.getProgress())}handleMouseSeek(e){const i=this.getChild("seekBar");i&&i.handleMouseMove(e)}enabled(){return this.enabled_}disable(){if(this.children().forEach(e=>e.disable&&e.disable()),!!this.enabled()&&(this.off(["mousedown","touchstart"],this.handleMouseDownHandler_),this.off(this.el_,"mousemove",this.handleMouseMove),this.removeListenersAddedOnMousedownAndTouchstart(),this.addClass("disabled"),this.enabled_=!1,this.player_.scrubbing())){const e=this.getChild("seekBar");this.player_.scrubbing(!1),e.videoWasPlaying&&Ci(this.player_.play())}}enable(){this.children().forEach(e=>e.enable&&e.enable()),!this.enabled()&&(this.on(["mousedown","touchstart"],this.handleMouseDownHandler_),this.on(this.el_,"mousemove",this.handleMouseMove),this.removeClass("disabled"),this.enabled_=!0)}removeListenersAddedOnMousedownAndTouchstart(){const e=this.el_.ownerDocument;this.off(e,"mousemove",this.throttledHandleMouseSeek),this.off(e,"touchmove",this.throttledHandleMouseSeek),this.off(e,"mouseup",this.handleMouseUpHandler_),this.off(e,"touchend",this.handleMouseUpHandler_)}handleMouseDown(e){const i=this.el_.ownerDocument,n=this.getChild("seekBar");n&&n.handleMouseDown(e),this.on(i,"mousemove",this.throttledHandleMouseSeek),this.on(i,"touchmove",this.throttledHandleMouseSeek),this.on(i,"mouseup",this.handleMouseUpHandler_),this.on(i,"touchend",this.handleMouseUpHandler_)}handleMouseUp(e){const i=this.getChild("seekBar");i&&i.handleMouseUp(e),this.removeListenersAddedOnMousedownAndTouchstart()}}TT.prototype.options_={children:["seekBar"]};B.registerComponent("ProgressControl",TT);class xT extends Vt{constructor(e,i){super(e,i),this.setIcon("picture-in-picture-enter"),this.on(e,["enterpictureinpicture","leavepictureinpicture"],n=>this.handlePictureInPictureChange(n)),this.on(e,["disablepictureinpicturechanged","loadedmetadata"],n=>this.handlePictureInPictureEnabledChange(n)),this.on(e,["loadedmetadata","audioonlymodechange","audiopostermodechange"],()=>this.handlePictureInPictureAudioModeChange()),this.disable()}buildCSSClass(){return`vjs-picture-in-picture-control vjs-hidden ${super.buildCSSClass()}`}handlePictureInPictureAudioModeChange(){if(!(this.player_.currentType().substring(0,5)==="audio"||this.player_.audioPosterMode()||this.player_.audioOnlyMode())){this.show();return}this.player_.isInPictureInPicture()&&this.player_.exitPictureInPicture(),this.hide()}handlePictureInPictureEnabledChange(){V.pictureInPictureEnabled&&this.player_.disablePictureInPicture()===!1||this.player_.options_.enableDocumentPictureInPicture&&"documentPictureInPicture"in A?this.enable():this.disable()}handlePictureInPictureChange(e){this.player_.isInPictureInPicture()?(this.setIcon("picture-in-picture-exit"),this.controlText("Exit Picture-in-Picture")):(this.setIcon("picture-in-picture-enter"),this.controlText("Picture-in-Picture")),this.handlePictureInPictureEnabledChange()}handleClick(e){this.player_.isInPictureInPicture()?this.player_.exitPictureInPicture():this.player_.requestPictureInPicture()}show(){typeof V.exitPictureInPicture=="function"&&super.show()}}xT.prototype.controlText_="Picture-in-Picture";B.registerComponent("PictureInPictureToggle",xT);class ST extends Vt{constructor(e,i){super(e,i),this.setIcon("fullscreen-enter"),this.on(e,"fullscreenchange",n=>this.handleFullscreenChange(n)),V[e.fsApi_.fullscreenEnabled]===!1&&this.disable()}buildCSSClass(){return`vjs-fullscreen-control ${super.buildCSSClass()}`}handleFullscreenChange(e){this.player_.isFullscreen()?(this.controlText("Exit Fullscreen"),this.setIcon("fullscreen-exit")):(this.controlText("Fullscreen"),this.setIcon("fullscreen-enter"))}handleClick(e){this.player_.isFullscreen()?this.player_.exitFullscreen():this.player_.requestFullscreen()}}ST.prototype.controlText_="Fullscreen";B.registerComponent("FullscreenToggle",ST);const L4=function(t,e){e.tech_&&!e.tech_.featuresVolumeControl&&t.addClass("vjs-hidden"),t.on(e,"loadstart",function(){e.tech_.featuresVolumeControl?t.removeClass("vjs-hidden"):t.addClass("vjs-hidden")})};class O4 extends B{createEl(){const e=super.createEl("div",{className:"vjs-volume-level"});return this.setIcon("circle",e),e.appendChild(super.createEl("span",{className:"vjs-control-text"})),e}}B.registerComponent("VolumeLevel",O4);class N4 extends B{constructor(e,i){super(e,i),this.update=Fi(Ee(this,this.update),ni)}createEl(){return super.createEl("div",{className:"vjs-volume-tooltip"},{"aria-hidden":"true"})}update(e,i,n,r){if(!n){const s=bs(this.el_),a=bs(this.player_.el()),o=e.width*i;if(!a||!s)return;const l=e.left-a.left+o,c=e.width-o+(a.right-e.right);let p=s.width/2;ls.width&&(p=s.width),this.el_.style.right=`-${p}px`}this.write(`${r}%`)}write(e){Vn(this.el_,e)}updateVolume(e,i,n,r,s){this.requestNamedAnimationFrame("VolumeLevelTooltip#updateVolume",()=>{this.update(e,i,n,r.toFixed(0)),s&&s()})}}B.registerComponent("VolumeLevelTooltip",N4);class ET extends B{constructor(e,i){super(e,i),this.update=Fi(Ee(this,this.update),ni)}createEl(){return super.createEl("div",{className:"vjs-mouse-display"})}update(e,i,n){const r=100*i;this.getChild("volumeLevelTooltip").updateVolume(e,i,n,r,()=>{n?this.el_.style.bottom=`${e.height*i}px`:this.el_.style.left=`${e.width*i}px`})}}ET.prototype.options_={children:["volumeLevelTooltip"]};B.registerComponent("MouseVolumeLevelDisplay",ET);class Dc extends Yp{constructor(e,i){super(e,i),this.on("slideractive",n=>this.updateLastVolume_(n)),this.on(e,"volumechange",n=>this.updateARIAAttributes(n)),e.ready(()=>this.updateARIAAttributes())}createEl(){return super.createEl("div",{className:"vjs-volume-bar vjs-slider-bar"},{"aria-label":this.localize("Volume Level"),"aria-live":"polite"})}handleMouseDown(e){ho(e)&&super.handleMouseDown(e)}handleMouseMove(e){const i=this.getChild("mouseVolumeLevelDisplay");if(i){const n=this.el(),r=bs(n),s=this.vertical();let a=Tc(n,e);a=s?a.y:a.x,a=bo(a,0,1),i.update(r,a,s)}ho(e)&&(this.checkMuted(),this.player_.volume(this.calculateDistance(e)))}checkMuted(){this.player_.muted()&&this.player_.muted(!1)}getPercent(){return this.player_.muted()?0:this.player_.volume()}stepForward(){this.checkMuted(),this.player_.volume(this.player_.volume()+.1)}stepBack(){this.checkMuted(),this.player_.volume(this.player_.volume()-.1)}updateARIAAttributes(e){const i=this.player_.muted()?0:this.volumeAsPercentage_();this.el_.setAttribute("aria-valuenow",i),this.el_.setAttribute("aria-valuetext",i+"%")}volumeAsPercentage_(){return Math.round(this.player_.volume()*100)}updateLastVolume_(){const e=this.player_.volume();this.one("sliderinactive",()=>{this.player_.volume()===0&&this.player_.lastVolume_(e)})}}Dc.prototype.options_={children:["volumeLevel"],barName:"volumeLevel"};!Tt&&!Ri&&Dc.prototype.options_.children.splice(0,0,"mouseVolumeLevelDisplay");Dc.prototype.playerEvent="volumechange";B.registerComponent("VolumeBar",Dc);class bT extends B{constructor(e,i={}){i.vertical=i.vertical||!1,(typeof i.volumeBar>"u"||Ss(i.volumeBar))&&(i.volumeBar=i.volumeBar||{},i.volumeBar.vertical=i.vertical),super(e,i),L4(this,e),this.throttledHandleMouseMove=Fi(Ee(this,this.handleMouseMove),ni),this.handleMouseUpHandler_=n=>this.handleMouseUp(n),this.on("mousedown",n=>this.handleMouseDown(n)),this.on("touchstart",n=>this.handleMouseDown(n)),this.on("mousemove",n=>this.handleMouseMove(n)),this.on(this.volumeBar,["focus","slideractive"],()=>{this.volumeBar.addClass("vjs-slider-active"),this.addClass("vjs-slider-active"),this.trigger("slideractive")}),this.on(this.volumeBar,["blur","sliderinactive"],()=>{this.volumeBar.removeClass("vjs-slider-active"),this.removeClass("vjs-slider-active"),this.trigger("sliderinactive")})}createEl(){let e="vjs-volume-horizontal";return this.options_.vertical&&(e="vjs-volume-vertical"),super.createEl("div",{className:`vjs-volume-control vjs-control ${e}`})}handleMouseDown(e){const i=this.el_.ownerDocument;this.on(i,"mousemove",this.throttledHandleMouseMove),this.on(i,"touchmove",this.throttledHandleMouseMove),this.on(i,"mouseup",this.handleMouseUpHandler_),this.on(i,"touchend",this.handleMouseUpHandler_)}handleMouseUp(e){const i=this.el_.ownerDocument;this.off(i,"mousemove",this.throttledHandleMouseMove),this.off(i,"touchmove",this.throttledHandleMouseMove),this.off(i,"mouseup",this.handleMouseUpHandler_),this.off(i,"touchend",this.handleMouseUpHandler_)}handleMouseMove(e){this.volumeBar.handleMouseMove(e)}}bT.prototype.options_={children:["volumeBar"]};B.registerComponent("VolumeControl",bT);const R4=function(t,e){e.tech_&&!e.tech_.featuresMuteControl&&t.addClass("vjs-hidden"),t.on(e,"loadstart",function(){e.tech_.featuresMuteControl?t.removeClass("vjs-hidden"):t.addClass("vjs-hidden")})};class CT extends Vt{constructor(e,i){super(e,i),R4(this,e),this.on(e,["loadstart","volumechange"],n=>this.update(n))}buildCSSClass(){return`vjs-mute-control ${super.buildCSSClass()}`}handleClick(e){const i=this.player_.volume(),n=this.player_.lastVolume_();if(i===0){const r=n<.1?.1:n;this.player_.volume(r),this.player_.muted(!1)}else this.player_.muted(!this.player_.muted())}update(e){this.updateIcon_(),this.updateControlText_()}updateIcon_(){const e=this.player_.volume();let i=3;this.setIcon("volume-high"),Tt&&this.player_.tech_&&this.player_.tech_.el_&&this.player_.muted(this.player_.tech_.el_.muted),e===0||this.player_.muted()?(this.setIcon("volume-mute"),i=0):e<.33?(this.setIcon("volume-low"),i=1):e<.67&&(this.setIcon("volume-medium"),i=2),vc(this.el_,[0,1,2,3].reduce((n,r)=>n+`${r?" ":""}vjs-vol-${r}`,"")),lr(this.el_,`vjs-vol-${i}`)}updateControlText_(){const i=this.player_.muted()||this.player_.volume()===0?"Unmute":"Mute";this.controlText()!==i&&this.controlText(i)}}CT.prototype.controlText_="Mute";B.registerComponent("MuteToggle",CT);class wT extends B{constructor(e,i={}){typeof i.inline<"u"?i.inline=i.inline:i.inline=!0,(typeof i.volumeControl>"u"||Ss(i.volumeControl))&&(i.volumeControl=i.volumeControl||{},i.volumeControl.vertical=!i.inline),super(e,i),this.handleKeyPressHandler_=n=>this.handleKeyPress(n),this.on(e,["loadstart"],n=>this.volumePanelState_(n)),this.on(this.muteToggle,"keyup",n=>this.handleKeyPress(n)),this.on(this.volumeControl,"keyup",n=>this.handleVolumeControlKeyUp(n)),this.on("keydown",n=>this.handleKeyPress(n)),this.on("mouseover",n=>this.handleMouseOver(n)),this.on("mouseout",n=>this.handleMouseOut(n)),this.on(this.volumeControl,["slideractive"],this.sliderActive_),this.on(this.volumeControl,["sliderinactive"],this.sliderInactive_)}sliderActive_(){this.addClass("vjs-slider-active")}sliderInactive_(){this.removeClass("vjs-slider-active")}volumePanelState_(){this.volumeControl.hasClass("vjs-hidden")&&this.muteToggle.hasClass("vjs-hidden")&&this.addClass("vjs-hidden"),this.volumeControl.hasClass("vjs-hidden")&&!this.muteToggle.hasClass("vjs-hidden")&&this.addClass("vjs-mute-toggle-only")}createEl(){let e="vjs-volume-panel-horizontal";return this.options_.inline||(e="vjs-volume-panel-vertical"),super.createEl("div",{className:`vjs-volume-panel vjs-control ${e}`})}dispose(){this.handleMouseOut(),super.dispose()}handleVolumeControlKeyUp(e){re.isEventKey(e,"Esc")&&this.muteToggle.focus()}handleMouseOver(e){this.addClass("vjs-hover"),Ht(V,"keyup",this.handleKeyPressHandler_)}handleMouseOut(e){this.removeClass("vjs-hover"),lt(V,"keyup",this.handleKeyPressHandler_)}handleKeyPress(e){re.isEventKey(e,"Esc")&&this.handleMouseOut()}}wT.prototype.options_={children:["muteToggle","volumeControl"]};B.registerComponent("VolumePanel",wT);class M4 extends Vt{constructor(e,i){super(e,i),this.validOptions=[5,10,30],this.skipTime=this.getSkipForwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.setIcon(`forward-${this.skipTime}`),this.controlText(this.localize("Skip forward {1} seconds",[this.skipTime])),this.show()):this.hide()}getSkipForwardTime(){const e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.forward}buildCSSClass(){return`vjs-skip-forward-${this.getSkipForwardTime()} ${super.buildCSSClass()}`}handleClick(e){if(isNaN(this.player_.duration()))return;const i=this.player_.currentTime(),n=this.player_.liveTracker,r=n&&n.isLive()?n.seekableEnd():this.player_.duration();let s;i+this.skipTime<=r?s=i+this.skipTime:s=r,this.player_.currentTime(s)}handleLanguagechange(){this.controlText(this.localize("Skip forward {1} seconds",[this.skipTime]))}}B.registerComponent("SkipForward",M4);class DT extends Vt{constructor(e,i){super(e,i),this.validOptions=[5,10,30],this.skipTime=this.getSkipBackwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.setIcon(`replay-${this.skipTime}`),this.controlText(this.localize("Skip backward {1} seconds",[this.skipTime])),this.show()):this.hide()}getSkipBackwardTime(){const e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.backward}buildCSSClass(){return`vjs-skip-backward-${this.getSkipBackwardTime()} ${super.buildCSSClass()}`}handleClick(e){const i=this.player_.currentTime(),n=this.player_.liveTracker,r=n&&n.isLive()&&n.seekableStart();let s;r&&i-this.skipTime<=r?s=r:i>=this.skipTime?s=i-this.skipTime:s=0,this.player_.currentTime(s)}handleLanguagechange(){this.controlText(this.localize("Skip backward {1} seconds",[this.skipTime]))}}DT.prototype.controlText_="Skip Backward";B.registerComponent("SkipBackward",DT);class AT extends B{constructor(e,i){super(e,i),i&&(this.menuButton_=i.menuButton),this.focusedChild_=-1,this.on("keydown",n=>this.handleKeyDown(n)),this.boundHandleBlur_=n=>this.handleBlur(n),this.boundHandleTapClick_=n=>this.handleTapClick(n)}addEventListenerForItem(e){e instanceof B&&(this.on(e,"blur",this.boundHandleBlur_),this.on(e,["tap","click"],this.boundHandleTapClick_))}removeEventListenerForItem(e){e instanceof B&&(this.off(e,"blur",this.boundHandleBlur_),this.off(e,["tap","click"],this.boundHandleTapClick_))}removeChild(e){typeof e=="string"&&(e=this.getChild(e)),this.removeEventListenerForItem(e),super.removeChild(e)}addItem(e){const i=this.addChild(e);i&&this.addEventListenerForItem(i)}createEl(){const e=this.options_.contentElType||"ul";this.contentEl_=ae(e,{className:"vjs-menu-content"}),this.contentEl_.setAttribute("role","menu");const i=super.createEl("div",{append:this.contentEl_,className:"vjs-menu"});return i.appendChild(this.contentEl_),Ht(i,"click",function(n){n.preventDefault(),n.stopImmediatePropagation()}),i}dispose(){this.contentEl_=null,this.boundHandleBlur_=null,this.boundHandleTapClick_=null,super.dispose()}handleBlur(e){const i=e.relatedTarget||V.activeElement;if(!this.children().some(n=>n.el()===i)){const n=this.menuButton_;n&&n.buttonPressed_&&i!==n.el().firstChild&&n.unpressButton()}}handleTapClick(e){if(this.menuButton_){this.menuButton_.unpressButton();const i=this.children();if(!Array.isArray(i))return;const n=i.filter(r=>r.el()===e.target)[0];if(!n)return;n.name()!=="CaptionSettingsMenuItem"&&this.menuButton_.focus()}}handleKeyDown(e){re.isEventKey(e,"Left")||re.isEventKey(e,"Down")?(e.preventDefault(),e.stopPropagation(),this.stepForward()):(re.isEventKey(e,"Right")||re.isEventKey(e,"Up"))&&(e.preventDefault(),e.stopPropagation(),this.stepBack())}stepForward(){let e=0;this.focusedChild_!==void 0&&(e=this.focusedChild_+1),this.focus(e)}stepBack(){let e=0;this.focusedChild_!==void 0&&(e=this.focusedChild_-1),this.focus(e)}focus(e=0){const i=this.children().slice();i.length&&i[0].hasClass("vjs-menu-title")&&i.shift(),i.length>0&&(e<0?e=0:e>=i.length&&(e=i.length-1),this.focusedChild_=e,i[e].el_.focus())}}B.registerComponent("Menu",AT);class em extends B{constructor(e,i={}){super(e,i),this.menuButton_=new Vt(e,i),this.menuButton_.controlText(this.controlText_),this.menuButton_.el_.setAttribute("aria-haspopup","true");const n=Vt.prototype.buildCSSClass();this.menuButton_.el_.className=this.buildCSSClass()+" "+n,this.menuButton_.removeClass("vjs-control"),this.addChild(this.menuButton_),this.update(),this.enabled_=!0;const r=s=>this.handleClick(s);this.handleMenuKeyUp_=s=>this.handleMenuKeyUp(s),this.on(this.menuButton_,"tap",r),this.on(this.menuButton_,"click",r),this.on(this.menuButton_,"keydown",s=>this.handleKeyDown(s)),this.on(this.menuButton_,"mouseenter",()=>{this.addClass("vjs-hover"),this.menu.show(),Ht(V,"keyup",this.handleMenuKeyUp_)}),this.on("mouseleave",s=>this.handleMouseLeave(s)),this.on("keydown",s=>this.handleSubmenuKeyDown(s))}update(){const e=this.createMenu();this.menu&&(this.menu.dispose(),this.removeChild(this.menu)),this.menu=e,this.addChild(e),this.buttonPressed_=!1,this.menuButton_.el_.setAttribute("aria-expanded","false"),this.items&&this.items.length<=this.hideThreshold_?(this.hide(),this.menu.contentEl_.removeAttribute("role")):(this.show(),this.menu.contentEl_.setAttribute("role","menu"))}createMenu(){const e=new AT(this.player_,{menuButton:this});if(this.hideThreshold_=0,this.options_.title){const i=ae("li",{className:"vjs-menu-title",textContent:Fe(this.options_.title),tabIndex:-1}),n=new B(this.player_,{el:i});e.addItem(n)}if(this.items=this.createItems(),this.items)for(let i=0;ire.isEventKey(e,i))||super.handleKeyDown(e)}handleClick(e){this.selected(!0)}selected(e){this.selectable&&(e?(this.addClass("vjs-selected"),this.el_.setAttribute("aria-checked","true"),this.controlText(", selected"),this.isSelected_=!0):(this.removeClass("vjs-selected"),this.el_.setAttribute("aria-checked","false"),this.controlText(""),this.isSelected_=!1))}}B.registerComponent("MenuItem",Co);class wo extends Co{constructor(e,i){const n=i.track,r=e.textTracks();i.label=n.label||n.language||"Unknown",i.selected=n.mode==="showing",super(e,i),this.track=n,this.kinds=(i.kinds||[i.kind||this.track.kind]).filter(Boolean);const s=(...o)=>{this.handleTracksChange.apply(this,o)},a=(...o)=>{this.handleSelectedLanguageChange.apply(this,o)};if(e.on(["loadstart","texttrackchange"],s),r.addEventListener("change",s),r.addEventListener("selectedlanguagechange",a),this.on("dispose",function(){e.off(["loadstart","texttrackchange"],s),r.removeEventListener("change",s),r.removeEventListener("selectedlanguagechange",a)}),r.onchange===void 0){let o;this.on(["tap","click"],function(){if(typeof A.Event!="object")try{o=new A.Event("change")}catch{}o||(o=V.createEvent("Event"),o.initEvent("change",!0,!0)),r.dispatchEvent(o)})}this.handleTracksChange()}handleClick(e){const i=this.track,n=this.player_.textTracks();if(super.handleClick(e),!!n)for(let r=0;r-1&&a.mode==="showing"){n=!1;break}}n!==this.isSelected_&&this.selected(n)}handleSelectedLanguageChange(e){const i=this.player().textTracks();let n=!0;for(let r=0,s=i.length;r-1&&a.mode==="showing"){n=!1;break}}n&&(this.player_.cache_.selectedLanguage={enabled:!1})}handleLanguagechange(){this.$(".vjs-menu-item-text").textContent=this.player_.localize(this.options_.label),super.handleLanguagechange()}}B.registerComponent("OffTextTrackMenuItem",kT);class Fs extends tm{constructor(e,i={}){i.tracks=e.textTracks(),super(e,i)}createItems(e=[],i=wo){let n;this.label_&&(n=`${this.label_} off`),e.push(new kT(this.player_,{kinds:this.kinds_,kind:this.kind_,label:n})),this.hideThreshold_+=1;const r=this.player_.textTracks();Array.isArray(this.kinds_)||(this.kinds_=[this.kind_]);for(let s=0;s-1){const o=new i(this.player_,{track:a,kinds:this.kinds_,kind:this.kind_,selectable:!0,multiSelectable:!1});o.addClass(`vjs-${a.kind}-menu-item`),e.push(o)}}return e}}B.registerComponent("TextTrackButton",Fs);class PT extends Co{constructor(e,i){const n=i.track,r=i.cue,s=e.currentTime();i.selectable=!0,i.multiSelectable=!1,i.label=r.text,i.selected=r.startTime<=s&&s{this.items.forEach(r=>{r.selected(this.track_.activeCues[0]===r.cue)})}}buildCSSClass(){return`vjs-chapters-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-chapters-button ${super.buildWrapperCSSClass()}`}update(e){if(e&&e.track&&e.track.kind!=="chapters")return;const i=this.findChaptersTrack();i!==this.track_?(this.setTrack(i),super.update()):(!this.items||i&&i.cues&&i.cues.length!==this.items.length)&&super.update()}setTrack(e){if(this.track_!==e){if(this.updateHandler_||(this.updateHandler_=this.update.bind(this)),this.track_){const i=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);i&&i.removeEventListener("load",this.updateHandler_),this.track_.removeEventListener("cuechange",this.selectCurrentItem_),this.track_=null}if(this.track_=e,this.track_){this.track_.mode="hidden";const i=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);i&&i.addEventListener("load",this.updateHandler_),this.track_.addEventListener("cuechange",this.selectCurrentItem_)}}}findChaptersTrack(){const e=this.player_.textTracks()||[];for(let i=e.length-1;i>=0;i--){const n=e[i];if(n.kind===this.kind_)return n}}getMenuCaption(){return this.track_&&this.track_.label?this.track_.label:this.localize(Fe(this.kind_))}createMenu(){return this.options_.title=this.getMenuCaption(),super.createMenu()}createItems(){const e=[];if(!this.track_)return e;const i=this.track_.cues;if(!i)return e;for(let n=0,r=i.length;n-1&&(this.label_="captions",this.setIcon("captions")),this.menuButton_.controlText(Fe(this.label_))}buildCSSClass(){return`vjs-subs-caps-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-subs-caps-button ${super.buildWrapperCSSClass()}`}createItems(){let e=[];return!(this.player().tech_&&this.player().tech_.featuresNativeTextTracks)&&this.player().getChild("textTrackSettings")&&(e.push(new sm(this.player_,{kind:this.label_})),this.hideThreshold_+=1),e=super.createItems(e,IT),e}}om.prototype.kinds_=["captions","subtitles"];om.prototype.controlText_="Subtitles";B.registerComponent("SubsCapsButton",om);class LT extends Co{constructor(e,i){const n=i.track,r=e.audioTracks();i.label=n.label||n.language||"Unknown",i.selected=n.enabled,super(e,i),this.track=n,this.addClass(`vjs-${n.kind}-menu-item`);const s=(...a)=>{this.handleTracksChange.apply(this,a)};r.addEventListener("change",s),this.on("dispose",()=>{r.removeEventListener("change",s)})}createEl(e,i,n){const r=super.createEl(e,i,n),s=r.querySelector(".vjs-menu-item-text");return["main-desc","description"].indexOf(this.options_.track.kind)>=0&&(s.appendChild(ae("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),s.appendChild(ae("span",{className:"vjs-control-text",textContent:" "+this.localize("Descriptions")}))),r}handleClick(e){if(super.handleClick(e),this.track.enabled=!0,this.player_.tech_.featuresNativeAudioTracks){const i=this.player_.audioTracks();for(let n=0;nthis.update(s))}handleClick(e){super.handleClick(),this.player().playbackRate(this.rate)}update(e){this.selected(this.player().playbackRate()===this.rate)}}lm.prototype.contentElType="button";B.registerComponent("PlaybackRateMenuItem",lm);class NT extends em{constructor(e,i){super(e,i),this.menuButton_.el_.setAttribute("aria-describedby",this.labelElId_),this.updateVisibility(),this.updateLabel(),this.on(e,"loadstart",n=>this.updateVisibility(n)),this.on(e,"ratechange",n=>this.updateLabel(n)),this.on(e,"playbackrateschange",n=>this.handlePlaybackRateschange(n))}createEl(){const e=super.createEl();return this.labelElId_="vjs-playback-rate-value-label-"+this.id_,this.labelEl_=ae("div",{className:"vjs-playback-rate-value",id:this.labelElId_,textContent:"1x"}),e.appendChild(this.labelEl_),e}dispose(){this.labelEl_=null,super.dispose()}buildCSSClass(){return`vjs-playback-rate ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-playback-rate ${super.buildWrapperCSSClass()}`}createItems(){const e=this.playbackRates(),i=[];for(let n=e.length-1;n>=0;n--)i.push(new lm(this.player(),{rate:e[n]+"x"}));return i}handlePlaybackRateschange(e){this.update()}playbackRates(){const e=this.player();return e.playbackRates&&e.playbackRates()||[]}playbackRateSupported(){return this.player().tech_&&this.player().tech_.featuresPlaybackRate&&this.playbackRates()&&this.playbackRates().length>0}updateVisibility(e){this.playbackRateSupported()?this.removeClass("vjs-hidden"):this.addClass("vjs-hidden")}updateLabel(e){this.playbackRateSupported()&&(this.labelEl_.textContent=this.player().playbackRate()+"x")}}NT.prototype.controlText_="Playback Rate";B.registerComponent("PlaybackRateMenuButton",NT);class RT extends B{buildCSSClass(){return`vjs-spacer ${super.buildCSSClass()}`}createEl(e="div",i={},n={}){return i.className||(i.className=this.buildCSSClass()),super.createEl(e,i,n)}}B.registerComponent("Spacer",RT);class F4 extends RT{buildCSSClass(){return`vjs-custom-control-spacer ${super.buildCSSClass()}`}createEl(){return super.createEl("div",{className:this.buildCSSClass(),textContent:" "})}}B.registerComponent("CustomControlSpacer",F4);class MT extends B{createEl(){return super.createEl("div",{className:"vjs-control-bar",dir:"ltr"})}}MT.prototype.options_={children:["playToggle","skipBackward","skipForward","volumePanel","currentTimeDisplay","timeDivider","durationDisplay","progressControl","liveDisplay","seekToLive","remainingTimeDisplay","customControlSpacer","playbackRateMenuButton","chaptersButton","descriptionsButton","subsCapsButton","audioTrackButton","pictureInPictureToggle","fullscreenToggle"]};B.registerComponent("ControlBar",MT);class BT extends Ms{constructor(e,i){super(e,i),this.on(e,"error",n=>this.open(n))}buildCSSClass(){return`vjs-error-display ${super.buildCSSClass()}`}content(){const e=this.player().error();return e?this.localize(e.message):""}}BT.prototype.options_=Object.assign({},Ms.prototype.options_,{pauseOnOpen:!1,fillAlways:!0,temporary:!1,uncloseable:!0});B.registerComponent("ErrorDisplay",BT);const jd="vjs-text-track-settings",Sy=["#000","Black"],Ey=["#00F","Blue"],by=["#0FF","Cyan"],Cy=["#0F0","Green"],wy=["#F0F","Magenta"],Dy=["#F00","Red"],Ay=["#FFF","White"],ky=["#FF0","Yellow"],$d=["1","Opaque"],Vd=["0.5","Semi-Transparent"],Py=["0","Transparent"],Zn={backgroundColor:{selector:".vjs-bg-color > select",id:"captions-background-color-%s",label:"Color",options:[Sy,Ay,Dy,Cy,Ey,ky,wy,by]},backgroundOpacity:{selector:".vjs-bg-opacity > select",id:"captions-background-opacity-%s",label:"Opacity",options:[$d,Vd,Py]},color:{selector:".vjs-text-color > select",id:"captions-foreground-color-%s",label:"Color",options:[Ay,Sy,Dy,Cy,Ey,ky,wy,by]},edgeStyle:{selector:".vjs-edge-style > select",id:"%s",label:"Text Edge Style",options:[["none","None"],["raised","Raised"],["depressed","Depressed"],["uniform","Uniform"],["dropshadow","Drop shadow"]]},fontFamily:{selector:".vjs-font-family > select",id:"captions-font-family-%s",label:"Font Family",options:[["proportionalSansSerif","Proportional Sans-Serif"],["monospaceSansSerif","Monospace Sans-Serif"],["proportionalSerif","Proportional Serif"],["monospaceSerif","Monospace Serif"],["casual","Casual"],["script","Script"],["small-caps","Small Caps"]]},fontPercent:{selector:".vjs-font-percent > select",id:"captions-font-size-%s",label:"Font Size",options:[["0.50","50%"],["0.75","75%"],["1.00","100%"],["1.25","125%"],["1.50","150%"],["1.75","175%"],["2.00","200%"],["3.00","300%"],["4.00","400%"]],default:2,parser:t=>t==="1.00"?null:Number(t)},textOpacity:{selector:".vjs-text-opacity > select",id:"captions-foreground-opacity-%s",label:"Opacity",options:[$d,Vd]},windowColor:{selector:".vjs-window-color > select",id:"captions-window-color-%s",label:"Color"},windowOpacity:{selector:".vjs-window-opacity > select",id:"captions-window-opacity-%s",label:"Opacity",options:[Py,Vd,$d]}};Zn.windowColor.options=Zn.backgroundColor.options;function FT(t,e){if(e&&(t=e(t)),t&&t!=="none")return t}function U4(t,e){const i=t.options[t.options.selectedIndex].value;return FT(i,e)}function j4(t,e,i){if(e){for(let n=0;n{this.saveSettings(),this.close()}),this.on(this.$(".vjs-default-button"),"click",()=>{this.setDefaults(),this.updateDisplay()}),ns(Zn,n=>{this.on(this.$(n.selector),"change",this.updateDisplay)}),this.options_.persistTextTrackSettings&&this.restoreSettings()}dispose(){this.endDialog=null,super.dispose()}createElSelect_(e,i="",n="label"){const r=Zn[e],s=r.id.replace("%s",this.id_),a=[i,s].join(" ").trim();return[`<${n} id="${s}" class="${n==="label"?"vjs-label":""}">`,this.localize(r.label),`${n}>`,`").join("")}createElFgColor_(){const e=`captions-text-legend-${this.id_}`;return['"].join("")}createElBgColor_(){const e=`captions-background-${this.id_}`;return['"].join("")}createElWinColor_(){const e=`captions-window-${this.id_}`;return['"].join("")}createElColors_(){return ae("div",{className:"vjs-track-settings-colors",innerHTML:[this.createElFgColor_(),this.createElBgColor_(),this.createElWinColor_()].join("")})}createElFont_(){return ae("div",{className:"vjs-track-settings-font",innerHTML:['",'",'"].join("")})}createElControls_(){const e=this.localize("restore all settings to the default values");return ae("div",{className:"vjs-track-settings-controls",innerHTML:[`",``].join("")})}content(){return[this.createElColors_(),this.createElFont_(),this.createElControls_()]}label(){return this.localize("Caption Settings Dialog")}description(){return this.localize("Beginning of dialog window. Escape will cancel and close the window.")}buildCSSClass(){return super.buildCSSClass()+" vjs-text-track-settings"}getValues(){return N2(Zn,(e,i,n)=>{const r=U4(this.$(i.selector),i.parser);return r!==void 0&&(e[n]=r),e},{})}setValues(e){ns(Zn,(i,n)=>{j4(this.$(i.selector),e[n],i.parser)})}setDefaults(){ns(Zn,e=>{const i=e.hasOwnProperty("default")?e.default:0;this.$(e.selector).selectedIndex=i})}restoreSettings(){let e;try{e=JSON.parse(A.localStorage.getItem(jd))}catch(i){oe.warn(i)}e&&this.setValues(e)}saveSettings(){if(!this.options_.persistTextTrackSettings)return;const e=this.getValues();try{Object.keys(e).length?A.localStorage.setItem(jd,JSON.stringify(e)):A.localStorage.removeItem(jd)}catch(i){oe.warn(i)}}updateDisplay(){const e=this.player_.getChild("textTrackDisplay");e&&e.updateDisplay()}conditionalBlur_(){this.previouslyActiveEl_=null;const e=this.player_.controlBar,i=e&&e.subsCapsButton,n=e&&e.captionsButton;i?i.focus():n&&n.focus()}handleLanguagechange(){this.fill()}}B.registerComponent("TextTrackSettings",$4);class V4 extends B{constructor(e,i){let n=i.ResizeObserver||A.ResizeObserver;i.ResizeObserver===null&&(n=!1);const r=xe({createEl:!n,reportTouchActivity:!1},i);super(e,r),this.ResizeObserver=i.ResizeObserver||A.ResizeObserver,this.loadListener_=null,this.resizeObserver_=null,this.debouncedHandler_=iT(()=>{this.resizeHandler()},100,!1,this),n?(this.resizeObserver_=new this.ResizeObserver(this.debouncedHandler_),this.resizeObserver_.observe(e.el())):(this.loadListener_=()=>{if(!this.el_||!this.el_.contentWindow)return;const s=this.debouncedHandler_;let a=this.unloadListener_=function(){lt(this,"resize",s),lt(this,"unload",a),a=null};Ht(this.el_.contentWindow,"unload",a),Ht(this.el_.contentWindow,"resize",s)},this.one("load",this.loadListener_))}createEl(){return super.createEl("iframe",{className:"vjs-resize-manager",tabIndex:-1,title:this.localize("No content")},{"aria-hidden":"true"})}resizeHandler(){!this.player_||!this.player_.trigger||this.player_.trigger("playerresize")}dispose(){this.debouncedHandler_&&this.debouncedHandler_.cancel(),this.resizeObserver_&&(this.player_.el()&&this.resizeObserver_.unobserve(this.player_.el()),this.resizeObserver_.disconnect()),this.loadListener_&&this.off("load",this.loadListener_),this.el_&&this.el_.contentWindow&&this.unloadListener_&&this.unloadListener_.call(this.el_.contentWindow),this.ResizeObserver=null,this.resizeObserver=null,this.debouncedHandler_=null,this.loadListener_=null,super.dispose()}}B.registerComponent("ResizeManager",V4);const z4={trackingThreshold:20,liveTolerance:15};class H4 extends B{constructor(e,i){const n=xe(z4,i,{createEl:!1});super(e,n),this.trackLiveHandler_=()=>this.trackLive_(),this.handlePlay_=r=>this.handlePlay(r),this.handleFirstTimeupdate_=r=>this.handleFirstTimeupdate(r),this.handleSeeked_=r=>this.handleSeeked(r),this.seekToLiveEdge_=r=>this.seekToLiveEdge(r),this.reset_(),this.on(this.player_,"durationchange",r=>this.handleDurationchange(r)),this.on(this.player_,"canplay",()=>this.toggleTracking())}trackLive_(){const e=this.player_.seekable();if(!e||!e.length)return;const i=Number(A.performance.now().toFixed(4)),n=this.lastTime_===-1?0:(i-this.lastTime_)/1e3;this.lastTime_=i,this.pastSeekEnd_=this.pastSeekEnd()+n;const r=this.liveCurrentTime(),s=this.player_.currentTime();let a=this.player_.paused()||this.seekedBehindLive_||Math.abs(r-s)>this.options_.liveTolerance;(!this.timeupdateSeen_||r===1/0)&&(a=!1),a!==this.behindLiveEdge_&&(this.behindLiveEdge_=a,this.trigger("liveedgechange"))}handleDurationchange(){this.toggleTracking()}toggleTracking(){this.player_.duration()===1/0&&this.liveWindow()>=this.options_.trackingThreshold?(this.player_.options_.liveui&&this.player_.addClass("vjs-liveui"),this.startTracking()):(this.player_.removeClass("vjs-liveui"),this.stopTracking())}startTracking(){this.isTracking()||(this.timeupdateSeen_||(this.timeupdateSeen_=this.player_.hasStarted()),this.trackingInterval_=this.setInterval(this.trackLiveHandler_,ni),this.trackLive_(),this.on(this.player_,["play","pause"],this.trackLiveHandler_),this.timeupdateSeen_?this.on(this.player_,"seeked",this.handleSeeked_):(this.one(this.player_,"play",this.handlePlay_),this.one(this.player_,"timeupdate",this.handleFirstTimeupdate_)))}handleFirstTimeupdate(){this.timeupdateSeen_=!0,this.on(this.player_,"seeked",this.handleSeeked_)}handleSeeked(){const e=Math.abs(this.liveCurrentTime()-this.player_.currentTime());this.seekedBehindLive_=this.nextSeekedFromUser_&&e>2,this.nextSeekedFromUser_=!1,this.trackLive_()}handlePlay(){this.one(this.player_,"timeupdate",this.seekToLiveEdge_)}reset_(){this.lastTime_=-1,this.pastSeekEnd_=0,this.lastSeekEnd_=-1,this.behindLiveEdge_=!0,this.timeupdateSeen_=!1,this.seekedBehindLive_=!1,this.nextSeekedFromUser_=!1,this.clearInterval(this.trackingInterval_),this.trackingInterval_=null,this.off(this.player_,["play","pause"],this.trackLiveHandler_),this.off(this.player_,"seeked",this.handleSeeked_),this.off(this.player_,"play",this.handlePlay_),this.off(this.player_,"timeupdate",this.handleFirstTimeupdate_),this.off(this.player_,"timeupdate",this.seekToLiveEdge_)}nextSeekedFromUser(){this.nextSeekedFromUser_=!0}stopTracking(){this.isTracking()&&(this.reset_(),this.trigger("liveedgechange"))}seekableEnd(){const e=this.player_.seekable(),i=[];let n=e?e.length:0;for(;n--;)i.push(e.end(n));return i.length?i.sort()[i.length-1]:1/0}seekableStart(){const e=this.player_.seekable(),i=[];let n=e?e.length:0;for(;n--;)i.push(e.start(n));return i.length?i.sort()[0]:0}liveWindow(){const e=this.liveCurrentTime();return e===1/0?0:e-this.seekableStart()}isLive(){return this.isTracking()}atLiveEdge(){return!this.behindLiveEdge()}liveCurrentTime(){return this.pastSeekEnd()+this.seekableEnd()}pastSeekEnd(){const e=this.seekableEnd();return this.lastSeekEnd_!==-1&&e!==this.lastSeekEnd_&&(this.pastSeekEnd_=0),this.lastSeekEnd_=e,this.pastSeekEnd_}behindLiveEdge(){return this.behindLiveEdge_}isTracking(){return typeof this.trackingInterval_=="number"}seekToLiveEdge(){this.seekedBehindLive_=!1,!this.atLiveEdge()&&(this.nextSeekedFromUser_=!1,this.player_.currentTime(this.liveCurrentTime()))}dispose(){this.stopTracking(),super.dispose()}}B.registerComponent("LiveTracker",H4);class q4 extends B{constructor(e,i){super(e,i),this.on("statechanged",n=>this.updateDom_()),this.updateDom_()}createEl(){return this.els={title:ae("div",{className:"vjs-title-bar-title",id:`vjs-title-bar-title-${Bi()}`}),description:ae("div",{className:"vjs-title-bar-description",id:`vjs-title-bar-description-${Bi()}`})},ae("div",{className:"vjs-title-bar"},{},R2(this.els))}updateDom_(){const e=this.player_.tech_,i=e&&e.el_,n={title:"aria-labelledby",description:"aria-describedby"};["title","description"].forEach(r=>{const s=this.state[r],a=this.els[r],o=n[r];xc(a),s&&Vn(a,s),i&&(i.removeAttribute(o),s&&i.setAttribute(o,a.id))}),this.state.title||this.state.description?this.show():this.hide()}update(e){this.setState(e)}dispose(){const e=this.player_.tech_,i=e&&e.el_;i&&(i.removeAttribute("aria-labelledby"),i.removeAttribute("aria-describedby")),super.dispose(),this.els=null}}B.registerComponent("TitleBar",q4);const rf=t=>{const e=t.el();if(e.hasAttribute("src"))return t.triggerSourceset(e.src),!0;const i=t.$$("source"),n=[];let r="";if(!i.length)return!1;for(let s=0;s{let i={};for(let n=0;nUT([t.el(),A.HTMLMediaElement.prototype,A.Element.prototype,W4],"innerHTML"),Iy=function(t){const e=t.el();if(e.resetSourceWatch_)return;const i={},n=G4(t),r=s=>(...a)=>{const o=s.apply(e,a);return rf(t),o};["append","appendChild","insertAdjacentHTML"].forEach(s=>{e[s]&&(i[s]=e[s],e[s]=r(i[s]))}),Object.defineProperty(e,"innerHTML",xe(n,{set:r(n.set)})),e.resetSourceWatch_=()=>{e.resetSourceWatch_=null,Object.keys(i).forEach(s=>{e[s]=i[s]}),Object.defineProperty(e,"innerHTML",n)},t.one("sourceset",e.resetSourceWatch_)},X4=Object.defineProperty({},"src",{get(){return this.hasAttribute("src")?hT(A.Element.prototype.getAttribute.call(this,"src")):""},set(t){return A.Element.prototype.setAttribute.call(this,"src",t),t}}),K4=t=>UT([t.el(),A.HTMLMediaElement.prototype,X4],"src"),Q4=function(t){if(!t.featuresSourceset)return;const e=t.el();if(e.resetSourceset_)return;const i=K4(t),n=e.setAttribute,r=e.load;Object.defineProperty(e,"src",xe(i,{set:s=>{const a=i.set.call(e,s);return t.triggerSourceset(e.src),a}})),e.setAttribute=(s,a)=>{const o=n.call(e,s,a);return/src/i.test(s)&&t.triggerSourceset(e.src),o},e.load=()=>{const s=r.call(e);return rf(t)||(t.triggerSourceset(""),Iy(t)),s},e.currentSrc?t.triggerSourceset(e.currentSrc):rf(t)||Iy(t),e.resetSourceset_=()=>{e.resetSourceset_=null,e.load=r,e.setAttribute=n,Object.defineProperty(e,"src",i),e.resetSourceWatch_&&e.resetSourceWatch_()}};class W extends se{constructor(e,i){super(e,i);const n=e.source;let r=!1;if(this.featuresVideoFrameCallback=this.featuresVideoFrameCallback&&this.el_.tagName==="VIDEO",n&&(this.el_.currentSrc!==n.src||e.tag&&e.tag.initNetworkState_===3)?this.setSource(n):this.handleLateInit_(this.el_),e.enableSourceset&&this.setupSourcesetHandling_(),this.isScrubbing_=!1,this.el_.hasChildNodes()){const s=this.el_.childNodes;let a=s.length;const o=[];for(;a--;){const l=s[a];l.nodeName.toLowerCase()==="track"&&(this.featuresNativeTextTracks?(this.remoteTextTrackEls().addTrackElement_(l),this.remoteTextTracks().addTrack(l.track),this.textTracks().addTrack(l.track),!r&&!this.el_.hasAttribute("crossorigin")&&Cc(l.src)&&(r=!0)):o.push(l))}for(let l=0;l{i=[];for(let s=0;se.removeEventListener("change",n));const r=()=>{for(let s=0;s{e.removeEventListener("change",n),e.removeEventListener("change",r),e.addEventListener("change",r)}),this.on("webkitendfullscreen",()=>{e.removeEventListener("change",n),e.addEventListener("change",n),e.removeEventListener("change",r)})}overrideNative_(e,i){if(i!==this[`featuresNative${e}Tracks`])return;const n=e.toLowerCase();this[`${n}TracksListeners_`]&&Object.keys(this[`${n}TracksListeners_`]).forEach(r=>{this.el()[`${n}Tracks`].removeEventListener(r,this[`${n}TracksListeners_`][r])}),this[`featuresNative${e}Tracks`]=!i,this[`${n}TracksListeners_`]=null,this.proxyNativeTracksForType_(n)}overrideNativeAudioTracks(e){this.overrideNative_("Audio",e)}overrideNativeVideoTracks(e){this.overrideNative_("Video",e)}proxyNativeTracksForType_(e){const i=ei[e],n=this.el()[i.getterName],r=this[i.getterName]();if(!this[`featuresNative${i.capitalName}Tracks`]||!n||!n.addEventListener)return;const s={change:o=>{const l={type:"change",target:r,currentTarget:r,srcElement:r};r.trigger(l),e==="text"&&this[Ds.remoteText.getterName]().trigger(l)},addtrack(o){r.addTrack(o.track)},removetrack(o){r.removeTrack(o.track)}},a=function(){const o=[];for(let l=0;l{const l=s[o];n.addEventListener(o,l),this.on("dispose",c=>n.removeEventListener(o,l))}),this.on("loadstart",a),this.on("dispose",o=>this.off("loadstart",a))}proxyNativeTracks_(){ei.names.forEach(e=>{this.proxyNativeTracksForType_(e)})}createEl(){let e=this.options_.tag;if(!e||!(this.options_.playerElIngest||this.movingMediaElementInDOM)){if(e){const n=e.cloneNode(!0);e.parentNode&&e.parentNode.insertBefore(n,e),W.disposeMediaElement(e),e=n}else{e=V.createElement("video");const n=this.options_.tag&&vn(this.options_.tag),r=xe({},n);(!uo||this.options_.nativeControlsForTouch!==!0)&&delete r.controls,z2(e,Object.assign(r,{id:this.options_.techId,class:"vjs-tech"}))}e.playerId=this.options_.playerId}typeof this.options_.preload<"u"&&Es(e,"preload",this.options_.preload),this.options_.disablePictureInPicture!==void 0&&(e.disablePictureInPicture=this.options_.disablePictureInPicture);const i=["loop","muted","playsinline","autoplay"];for(let n=0;n=2&&i.push("loadeddata"),e.readyState>=3&&i.push("canplay"),e.readyState>=4&&i.push("canplaythrough"),this.ready(function(){i.forEach(function(n){this.trigger(n)},this)})}setScrubbing(e){this.isScrubbing_=e}scrubbing(){return this.isScrubbing_}setCurrentTime(e){try{this.isScrubbing_&&this.el_.fastSeek&&yc?this.el_.fastSeek(e):this.el_.currentTime=e}catch(i){oe(i,"Video is not ready. (Video.js)")}}duration(){if(this.el_.duration===1/0&&Ri&&Mi&&this.el_.currentTime===0){const e=()=>{this.el_.currentTime>0&&(this.el_.duration===1/0&&this.trigger("durationchange"),this.off("timeupdate",e))};return this.on("timeupdate",e),NaN}return this.el_.duration||NaN}width(){return this.el_.offsetWidth}height(){return this.el_.offsetHeight}proxyWebkitFullscreen_(){if(!("webkitDisplayingFullscreen"in this.el_))return;const e=function(){this.trigger("fullscreenchange",{isFullscreen:!1}),this.el_.controls&&!this.options_.nativeControlsForTouch&&this.controls()&&(this.el_.controls=!1)},i=function(){"webkitPresentationMode"in this.el_&&this.el_.webkitPresentationMode!=="picture-in-picture"&&(this.one("webkitendfullscreen",e),this.trigger("fullscreenchange",{isFullscreen:!0,nativeIOSFullscreen:!0}))};this.on("webkitbeginfullscreen",i),this.on("dispose",()=>{this.off("webkitbeginfullscreen",i),this.off("webkitendfullscreen",e)})}supportsFullScreen(){return typeof this.el_.webkitEnterFullScreen=="function"}enterFullScreen(){const e=this.el_;if(e.paused&&e.networkState<=e.HAVE_METADATA)Ci(this.el_.play()),this.setTimeout(function(){e.pause();try{e.webkitEnterFullScreen()}catch(i){this.trigger("fullscreenerror",i)}},0);else try{e.webkitEnterFullScreen()}catch(i){this.trigger("fullscreenerror",i)}}exitFullScreen(){if(!this.el_.webkitDisplayingFullscreen){this.trigger("fullscreenerror",new Error("The video is not fullscreen"));return}this.el_.webkitExitFullScreen()}requestPictureInPicture(){return this.el_.requestPictureInPicture()}requestVideoFrameCallback(e){return this.featuresVideoFrameCallback&&!this.el_.webkitKeys?this.el_.requestVideoFrameCallback(e):super.requestVideoFrameCallback(e)}cancelVideoFrameCallback(e){this.featuresVideoFrameCallback&&!this.el_.webkitKeys?this.el_.cancelVideoFrameCallback(e):super.cancelVideoFrameCallback(e)}src(e){if(e===void 0)return this.el_.src;this.setSrc(e)}reset(){W.resetMediaElement(this.el_)}currentSrc(){return this.currentSource_?this.currentSource_.src:this.el_.currentSrc}setControls(e){this.el_.controls=!!e}addTextTrack(e,i,n){return this.featuresNativeTextTracks?this.el_.addTextTrack(e,i,n):super.addTextTrack(e,i,n)}createRemoteTextTrack(e){if(!this.featuresNativeTextTracks)return super.createRemoteTextTrack(e);const i=V.createElement("track");return e.kind&&(i.kind=e.kind),e.label&&(i.label=e.label),(e.language||e.srclang)&&(i.srclang=e.language||e.srclang),e.default&&(i.default=e.default),e.id&&(i.id=e.id),e.src&&(i.src=e.src),i}addRemoteTextTrack(e,i){const n=super.addRemoteTextTrack(e,i);return this.featuresNativeTextTracks&&this.el().appendChild(n),n}removeRemoteTextTrack(e){if(super.removeRemoteTextTrack(e),this.featuresNativeTextTracks){const i=this.$$("track");let n=i.length;for(;n--;)(e===i[n]||e===i[n].track)&&this.el().removeChild(i[n])}}getVideoPlaybackQuality(){if(typeof this.el().getVideoPlaybackQuality=="function")return this.el().getVideoPlaybackQuality();const e={};return typeof this.el().webkitDroppedFrameCount<"u"&&typeof this.el().webkitDecodedFrameCount<"u"&&(e.droppedVideoFrames=this.el().webkitDroppedFrameCount,e.totalVideoFrames=this.el().webkitDecodedFrameCount),A.performance&&(e.creationTime=A.performance.now()),e}}fc(W,"TEST_VID",function(){if(!Os())return;const t=V.createElement("video"),e=V.createElement("track");return e.kind="captions",e.srclang="en",e.label="English",t.appendChild(e),t});W.isSupported=function(){try{W.TEST_VID.volume=.5}catch{return!1}return!!(W.TEST_VID&&W.TEST_VID.canPlayType)};W.canPlayType=function(t){return W.TEST_VID.canPlayType(t)};W.canPlaySource=function(t,e){return W.canPlayType(t.type)};W.canControlVolume=function(){try{const t=W.TEST_VID.volume;W.TEST_VID.volume=t/2+.1;const e=t!==W.TEST_VID.volume;return e&&Tt?(A.setTimeout(()=>{W&&W.prototype&&(W.prototype.featuresVolumeControl=t!==W.TEST_VID.volume)}),!1):e}catch{return!1}};W.canMuteVolume=function(){try{const t=W.TEST_VID.muted;return W.TEST_VID.muted=!t,W.TEST_VID.muted?Es(W.TEST_VID,"muted","muted"):_c(W.TEST_VID,"muted","muted"),t!==W.TEST_VID.muted}catch{return!1}};W.canControlPlaybackRate=function(){if(Ri&&Mi&&pc<58)return!1;try{const t=W.TEST_VID.playbackRate;return W.TEST_VID.playbackRate=t/2+.1,t!==W.TEST_VID.playbackRate}catch{return!1}};W.canOverrideAttributes=function(){try{const t=()=>{};Object.defineProperty(V.createElement("video"),"src",{get:t,set:t}),Object.defineProperty(V.createElement("audio"),"src",{get:t,set:t}),Object.defineProperty(V.createElement("video"),"innerHTML",{get:t,set:t}),Object.defineProperty(V.createElement("audio"),"innerHTML",{get:t,set:t})}catch{return!1}return!0};W.supportsNativeTextTracks=function(){return yc||Tt&&Mi};W.supportsNativeVideoTracks=function(){return!!(W.TEST_VID&&W.TEST_VID.videoTracks)};W.supportsNativeAudioTracks=function(){return!!(W.TEST_VID&&W.TEST_VID.audioTracks)};W.Events=["loadstart","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","ended","durationchange","timeupdate","progress","play","pause","ratechange","resize","volumechange"];[["featuresMuteControl","canMuteVolume"],["featuresPlaybackRate","canControlPlaybackRate"],["featuresSourceset","canOverrideAttributes"],["featuresNativeTextTracks","supportsNativeTextTracks"],["featuresNativeVideoTracks","supportsNativeVideoTracks"],["featuresNativeAudioTracks","supportsNativeAudioTracks"]].forEach(function([t,e]){fc(W.prototype,t,()=>W[e](),!0)});W.prototype.featuresVolumeControl=W.canControlVolume();W.prototype.movingMediaElementInDOM=!Tt;W.prototype.featuresFullscreenResize=!0;W.prototype.featuresProgressEvents=!0;W.prototype.featuresTimeupdateEvents=!0;W.prototype.featuresVideoFrameCallback=!!(W.TEST_VID&&W.TEST_VID.requestVideoFrameCallback);W.disposeMediaElement=function(t){if(t){for(t.parentNode&&t.parentNode.removeChild(t);t.hasChildNodes();)t.removeChild(t.firstChild);t.removeAttribute("src"),typeof t.load=="function"&&function(){try{t.load()}catch{}}()}};W.resetMediaElement=function(t){if(!t)return;const e=t.querySelectorAll("source");let i=e.length;for(;i--;)t.removeChild(e[i]);t.removeAttribute("src"),typeof t.load=="function"&&function(){try{t.load()}catch{}}()};["muted","defaultMuted","autoplay","controls","loop","playsinline"].forEach(function(t){W.prototype[t]=function(){return this.el_[t]||this.el_.hasAttribute(t)}});["muted","defaultMuted","autoplay","loop","playsinline"].forEach(function(t){W.prototype["set"+Fe(t)]=function(e){this.el_[t]=e,e?this.el_.setAttribute(t,t):this.el_.removeAttribute(t)}});["paused","currentTime","buffered","volume","poster","preload","error","seeking","seekable","ended","playbackRate","defaultPlaybackRate","disablePictureInPicture","played","networkState","readyState","videoWidth","videoHeight","crossOrigin"].forEach(function(t){W.prototype[t]=function(){return this.el_[t]}});["volume","src","poster","preload","playbackRate","defaultPlaybackRate","disablePictureInPicture","crossOrigin"].forEach(function(t){W.prototype["set"+Fe(t)]=function(e){this.el_[t]=e}});["pause","load","play"].forEach(function(t){W.prototype[t]=function(){return this.el_[t]()}});se.withSourceHandlers(W);W.nativeSourceHandler={};W.nativeSourceHandler.canPlayType=function(t){try{return W.TEST_VID.canPlayType(t)}catch{return""}};W.nativeSourceHandler.canHandleSource=function(t,e){if(t.type)return W.nativeSourceHandler.canPlayType(t.type);if(t.src){const i=Wp(t.src);return W.nativeSourceHandler.canPlayType(`video/${i}`)}return""};W.nativeSourceHandler.handleSource=function(t,e,i){e.setSrc(t.src)};W.nativeSourceHandler.dispose=function(){};W.registerSourceHandler(W.nativeSourceHandler);se.registerTech("Html5",W);const jT=["progress","abort","suspend","emptied","stalled","loadedmetadata","loadeddata","timeupdate","resize","volumechange","texttrackchange"],zd={canplay:"CanPlay",canplaythrough:"CanPlayThrough",playing:"Playing",seeked:"Seeked"},sf=["tiny","xsmall","small","medium","large","xlarge","huge"],Ul={};sf.forEach(t=>{const e=t.charAt(0)==="x"?`x-${t.substring(1)}`:t;Ul[t]=`vjs-layout-${e}`});const Y4={tiny:210,xsmall:320,small:425,medium:768,large:1440,xlarge:2560,huge:1/0};class be extends B{constructor(e,i,n){if(e.id=e.id||i.id||`vjs_video_${Bi()}`,i=Object.assign(be.getTagSettings(e),i),i.initChildren=!1,i.createEl=!1,i.evented=!1,i.reportTouchActivity=!1,!i.language){const a=e.closest("[lang]");a&&(i.language=a.getAttribute("lang"))}if(super(null,i,n),this.boundDocumentFullscreenChange_=a=>this.documentFullscreenChange_(a),this.boundFullWindowOnEscKey_=a=>this.fullWindowOnEscKey(a),this.boundUpdateStyleEl_=a=>this.updateStyleEl_(a),this.boundApplyInitTime_=a=>this.applyInitTime_(a),this.boundUpdateCurrentBreakpoint_=a=>this.updateCurrentBreakpoint_(a),this.boundHandleTechClick_=a=>this.handleTechClick_(a),this.boundHandleTechDoubleClick_=a=>this.handleTechDoubleClick_(a),this.boundHandleTechTouchStart_=a=>this.handleTechTouchStart_(a),this.boundHandleTechTouchMove_=a=>this.handleTechTouchMove_(a),this.boundHandleTechTouchEnd_=a=>this.handleTechTouchEnd_(a),this.boundHandleTechTap_=a=>this.handleTechTap_(a),this.isFullscreen_=!1,this.log=L2(this.id_),this.fsApi_=Su,this.isPosterFromTech_=!1,this.queuedCallbacks_=[],this.isReady_=!1,this.hasStarted_=!1,this.userActive_=!1,this.debugEnabled_=!1,this.audioOnlyMode_=!1,this.audioPosterMode_=!1,this.audioOnlyCache_={playerHeight:null,hiddenChildren:[]},!this.options_||!this.options_.techOrder||!this.options_.techOrder.length)throw new Error("No techOrder specified. Did you overwrite videojs.options instead of just changing the properties you want to override?");if(this.tag=e,this.tagAttributes=e&&vn(e),this.language(this.options_.language),i.languages){const a={};Object.getOwnPropertyNames(i.languages).forEach(function(o){a[o.toLowerCase()]=i.languages[o]}),this.languages_=a}else this.languages_=be.prototype.options_.languages;this.resetCache_(),this.poster_=i.poster||"",this.controls_=!!i.controls,e.controls=!1,e.removeAttribute("controls"),this.changingSrc_=!1,this.playCallbacks_=[],this.playTerminatedQueue_=[],e.hasAttribute("autoplay")?this.autoplay(!0):this.autoplay(this.options_.autoplay),i.plugins&&Object.keys(i.plugins).forEach(a=>{if(typeof this[a]!="function")throw new Error(`plugin "${a}" does not exist`)}),this.scrubbing_=!1,this.el_=this.createEl(),Vp(this,{eventBusKey:"el_"}),this.fsApi_.requestFullscreen&&(Ht(V,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),this.on(this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_)),this.fluid_&&this.on(["playerreset","resize"],this.boundUpdateStyleEl_);const r=xe(this.options_);if(i.plugins&&Object.keys(i.plugins).forEach(a=>{this[a](i.plugins[a])}),i.debug&&this.debug(!0),this.options_.playerOptions=r,this.middleware_=[],this.playbackRates(i.playbackRates),i.experimentalSvgIcons){const o=new A.DOMParser().parseFromString(x4,"image/svg+xml");if(o.querySelector("parsererror"))oe.warn("Failed to load SVG Icons. Falling back to Font Icons."),this.options_.experimentalSvgIcons=null;else{const c=o.documentElement;c.style.display="none",this.el_.appendChild(c),this.addClass("vjs-svg-icons-enabled")}}this.initChildren(),this.isAudio(e.nodeName.toLowerCase()==="audio"),this.controls()?this.addClass("vjs-controls-enabled"):this.addClass("vjs-controls-disabled"),this.el_.setAttribute("role","region"),this.isAudio()?this.el_.setAttribute("aria-label",this.localize("Audio Player")):this.el_.setAttribute("aria-label",this.localize("Video Player")),this.isAudio()&&this.addClass("vjs-audio"),uo&&this.addClass("vjs-touch-enabled"),Tt||this.addClass("vjs-workinghover"),be.players[this.id_]=this;const s=P2.split(".")[0];this.addClass(`vjs-v${s}`),this.userActive(!0),this.reportUserActivity(),this.one("play",a=>this.listenForUserActivity_(a)),this.on("keydown",a=>this.handleKeyDown(a)),this.on("languagechange",a=>this.handleLanguagechange(a)),this.breakpoints(this.options_.breakpoints),this.responsive(this.options_.responsive),this.on("ready",()=>{this.audioPosterMode(this.options_.audioPosterMode),this.audioOnlyMode(this.options_.audioOnlyMode)})}dispose(){this.trigger("dispose"),this.off("dispose"),lt(V,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),lt(V,"keydown",this.boundFullWindowOnEscKey_),this.styleEl_&&this.styleEl_.parentNode&&(this.styleEl_.parentNode.removeChild(this.styleEl_),this.styleEl_=null),be.players[this.id_]=null,this.tag&&this.tag.player&&(this.tag.player=null),this.el_&&this.el_.player&&(this.el_.player=null),this.tech_&&(this.tech_.dispose(),this.isPosterFromTech_=!1,this.poster_=""),this.playerElIngest_&&(this.playerElIngest_=null),this.tag&&(this.tag=null),y4(this),mt.names.forEach(e=>{const i=mt[e],n=this[i.getterName]();n&&n.off&&n.off()}),super.dispose({restoreEl:this.options_.restoreEl})}createEl(){let e=this.tag,i,n=this.playerElIngest_=e.parentNode&&e.parentNode.hasAttribute&&e.parentNode.hasAttribute("data-vjs-player");const r=this.tag.tagName.toLowerCase()==="video-js";n?i=this.el_=e.parentNode:r||(i=this.el_=super.createEl("div"));const s=vn(e);if(r){for(i=this.el_=e,e=this.tag=V.createElement("video");i.children.length;)e.appendChild(i.firstChild);Na(i,"video-js")||lr(i,"video-js"),i.appendChild(e),n=this.playerElIngest_=i,Object.keys(i).forEach(o=>{try{e[o]=i[o]}catch{}})}if(e.setAttribute("tabindex","-1"),s.tabindex="-1",Mi&&mc&&(e.setAttribute("role","application"),s.role="application"),e.removeAttribute("width"),e.removeAttribute("height"),"width"in s&&delete s.width,"height"in s&&delete s.height,Object.getOwnPropertyNames(s).forEach(function(o){r&&o==="class"||i.setAttribute(o,s[o]),r&&e.setAttribute(o,s[o])}),e.playerId=e.id,e.id+="_html5_api",e.className="vjs-tech",e.player=i.player=this,this.addClass("vjs-paused"),A.VIDEOJS_NO_DYNAMIC_STYLE!==!0){this.styleEl_=eT("vjs-styles-dimensions");const o=Mn(".vjs-styles-defaults"),l=Mn("head");l.insertBefore(this.styleEl_,o?o.nextSibling:l.firstChild)}this.fill_=!1,this.fluid_=!1,this.width(this.options_.width),this.height(this.options_.height),this.fill(this.options_.fill),this.fluid(this.options_.fluid),this.aspectRatio(this.options_.aspectRatio),this.crossOrigin(this.options_.crossOrigin||this.options_.crossorigin);const a=e.getElementsByTagName("a");for(let o=0;o"u")return this.techGet_("crossOrigin");if(e!==null&&e!=="anonymous"&&e!=="use-credentials"){oe.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${e}"`);return}this.techCall_("setCrossOrigin",e),this.posterImage&&this.posterImage.crossOrigin(e)}width(e){return this.dimension("width",e)}height(e){return this.dimension("height",e)}dimension(e,i){const n=e+"_";if(i===void 0)return this[n]||0;if(i===""||i==="auto"){this[n]=void 0,this.updateStyleEl_();return}const r=parseFloat(i);if(isNaN(r)){oe.error(`Improper value "${i}" supplied for for ${e}`);return}this[n]=r,this.updateStyleEl_()}fluid(e){if(e===void 0)return!!this.fluid_;this.fluid_=!!e,Ji(this)&&this.off(["playerreset","resize"],this.boundUpdateStyleEl_),e?(this.addClass("vjs-fluid"),this.fill(!1),G3(this,()=>{this.on(["playerreset","resize"],this.boundUpdateStyleEl_)})):this.removeClass("vjs-fluid"),this.updateStyleEl_()}fill(e){if(e===void 0)return!!this.fill_;this.fill_=!!e,e?(this.addClass("vjs-fill"),this.fluid(!1)):this.removeClass("vjs-fill")}aspectRatio(e){if(e===void 0)return this.aspectRatio_;if(!/^\d+\:\d+$/.test(e))throw new Error("Improper value supplied for aspect ratio. The format should be width:height, for example 16:9.");this.aspectRatio_=e,this.fluid(!0),this.updateStyleEl_()}updateStyleEl_(){if(A.VIDEOJS_NO_DYNAMIC_STYLE===!0){const o=typeof this.width_=="number"?this.width_:this.options_.width,l=typeof this.height_=="number"?this.height_:this.options_.height,c=this.tech_&&this.tech_.el();c&&(o>=0&&(c.width=o),l>=0&&(c.height=l));return}let e,i,n,r;this.aspectRatio_!==void 0&&this.aspectRatio_!=="auto"?n=this.aspectRatio_:this.videoWidth()>0?n=this.videoWidth()+":"+this.videoHeight():n="16:9";const s=n.split(":"),a=s[1]/s[0];this.width_!==void 0?e=this.width_:this.height_!==void 0?e=this.height_/a:e=this.videoWidth()||300,this.height_!==void 0?i=this.height_:i=e*a,/^[^a-zA-Z]/.test(this.id())?r="dimensions-"+this.id():r=this.id()+"-dimensions",this.addClass(r),tT(this.styleEl_,`
- .${r} {
- width: ${e}px;
- height: ${i}px;
- }
-
- .${r}.vjs-fluid:not(.vjs-audio-only-mode) {
- padding-top: ${a*100}%;
- }
- `)}loadTech_(e,i){this.tech_&&this.unloadTech_();const n=Fe(e),r=e.charAt(0).toLowerCase()+e.slice(1);n!=="Html5"&&this.tag&&(se.getTech("Html5").disposeMediaElement(this.tag),this.tag.player=null,this.tag=null),this.techName_=n,this.isReady_=!1;let s=this.autoplay();(typeof this.autoplay()=="string"||this.autoplay()===!0&&this.options_.normalizeAutoplay)&&(s=!1);const a={source:i,autoplay:s,nativeControlsForTouch:this.options_.nativeControlsForTouch,playerId:this.id(),techId:`${this.id()}_${r}_api`,playsinline:this.options_.playsinline,preload:this.options_.preload,loop:this.options_.loop,disablePictureInPicture:this.options_.disablePictureInPicture,muted:this.options_.muted,poster:this.poster(),language:this.language(),playerElIngest:this.playerElIngest_||!1,"vtt.js":this.options_["vtt.js"],canOverridePoster:!!this.options_.techCanOverridePoster,enableSourceset:this.options_.enableSourceset};mt.names.forEach(l=>{const c=mt[l];a[c.getterName]=this[c.privateName]}),Object.assign(a,this.options_[n]),Object.assign(a,this.options_[r]),Object.assign(a,this.options_[e.toLowerCase()]),this.tag&&(a.tag=this.tag),i&&i.src===this.cache_.src&&this.cache_.currentTime>0&&(a.startTime=this.cache_.currentTime);const o=se.getTech(e);if(!o)throw new Error(`No Tech named '${n}' exists! '${n}' should be registered using videojs.registerTech()'`);this.tech_=new o(a),this.tech_.ready(Ee(this,this.handleTechReady_),!0),hy.jsonToTextTracks(this.textTracksJson_||[],this.tech_),jT.forEach(l=>{this.on(this.tech_,l,c=>this[`handleTech${Fe(l)}_`](c))}),Object.keys(zd).forEach(l=>{this.on(this.tech_,l,c=>{if(this.tech_.playbackRate()===0&&this.tech_.seeking()){this.queuedCallbacks_.push({callback:this[`handleTech${zd[l]}_`].bind(this),event:c});return}this[`handleTech${zd[l]}_`](c)})}),this.on(this.tech_,"loadstart",l=>this.handleTechLoadStart_(l)),this.on(this.tech_,"sourceset",l=>this.handleTechSourceset_(l)),this.on(this.tech_,"waiting",l=>this.handleTechWaiting_(l)),this.on(this.tech_,"ended",l=>this.handleTechEnded_(l)),this.on(this.tech_,"seeking",l=>this.handleTechSeeking_(l)),this.on(this.tech_,"play",l=>this.handleTechPlay_(l)),this.on(this.tech_,"pause",l=>this.handleTechPause_(l)),this.on(this.tech_,"durationchange",l=>this.handleTechDurationChange_(l)),this.on(this.tech_,"fullscreenchange",(l,c)=>this.handleTechFullscreenChange_(l,c)),this.on(this.tech_,"fullscreenerror",(l,c)=>this.handleTechFullscreenError_(l,c)),this.on(this.tech_,"enterpictureinpicture",l=>this.handleTechEnterPictureInPicture_(l)),this.on(this.tech_,"leavepictureinpicture",l=>this.handleTechLeavePictureInPicture_(l)),this.on(this.tech_,"error",l=>this.handleTechError_(l)),this.on(this.tech_,"posterchange",l=>this.handleTechPosterChange_(l)),this.on(this.tech_,"textdata",l=>this.handleTechTextData_(l)),this.on(this.tech_,"ratechange",l=>this.handleTechRateChange_(l)),this.on(this.tech_,"loadedmetadata",this.boundUpdateStyleEl_),this.usingNativeControls(this.techGet_("controls")),this.controls()&&!this.usingNativeControls()&&this.addTechControlsListeners_(),this.tech_.el().parentNode!==this.el()&&(n!=="Html5"||!this.tag)&&Kh(this.tech_.el(),this.el()),this.tag&&(this.tag.player=null,this.tag=null)}unloadTech_(){mt.names.forEach(e=>{const i=mt[e];this[i.privateName]=this[i.getterName]()}),this.textTracksJson_=hy.textTracksToJson(this.tech_),this.isReady_=!1,this.tech_.dispose(),this.tech_=!1,this.isPosterFromTech_&&(this.poster_="",this.trigger("posterchange")),this.isPosterFromTech_=!1}tech(e){return e===void 0&&oe.warn(`Using the tech directly can be dangerous. I hope you know what you're doing.
-See https://github.com/videojs/video.js/issues/2617 for more info.
-`),this.tech_}addTechControlsListeners_(){this.removeTechControlsListeners_(),this.on(this.tech_,"click",this.boundHandleTechClick_),this.on(this.tech_,"dblclick",this.boundHandleTechDoubleClick_),this.on(this.tech_,"touchstart",this.boundHandleTechTouchStart_),this.on(this.tech_,"touchmove",this.boundHandleTechTouchMove_),this.on(this.tech_,"touchend",this.boundHandleTechTouchEnd_),this.on(this.tech_,"tap",this.boundHandleTechTap_)}removeTechControlsListeners_(){this.off(this.tech_,"tap",this.boundHandleTechTap_),this.off(this.tech_,"touchstart",this.boundHandleTechTouchStart_),this.off(this.tech_,"touchmove",this.boundHandleTechTouchMove_),this.off(this.tech_,"touchend",this.boundHandleTechTouchEnd_),this.off(this.tech_,"click",this.boundHandleTechClick_),this.off(this.tech_,"dblclick",this.boundHandleTechDoubleClick_)}handleTechReady_(){this.triggerReady(),this.cache_.volume&&this.techCall_("setVolume",this.cache_.volume),this.handleTechPosterChange_(),this.handleTechDurationChange_()}handleTechLoadStart_(){this.removeClass("vjs-ended","vjs-seeking"),this.error(null),this.handleTechDurationChange_(),this.paused()?(this.hasStarted(!1),this.trigger("loadstart")):this.trigger("loadstart"),this.manualAutoplay_(this.autoplay()===!0&&this.options_.normalizeAutoplay?"play":this.autoplay())}manualAutoplay_(e){if(!this.tech_||typeof e!="string")return;const i=()=>{const r=this.muted();this.muted(!0);const s=()=>{this.muted(r)};this.playTerminatedQueue_.push(s);const a=this.play();if(Ma(a))return a.catch(o=>{throw s(),new Error(`Rejection at manualAutoplay. Restoring muted value. ${o||""}`)})};let n;if(e==="any"&&!this.muted()?(n=this.play(),Ma(n)&&(n=n.catch(i))):e==="muted"&&!this.muted()?n=i():n=this.play(),!!Ma(n))return n.then(()=>{this.trigger({type:"autoplay-success",autoplay:e})}).catch(()=>{this.trigger({type:"autoplay-failure",autoplay:e})})}updateSourceCaches_(e=""){let i=e,n="";typeof i!="string"&&(i=e.src,n=e.type),this.cache_.source=this.cache_.source||{},this.cache_.sources=this.cache_.sources||[],i&&!n&&(n=T4(this,i)),this.cache_.source=xe({},e,{src:i,type:n});const r=this.cache_.sources.filter(l=>l.src&&l.src===i),s=[],a=this.$$("source"),o=[];for(let l=0;lthis.updateSourceCaches_(s);const n=this.currentSource().src,r=e.src;n&&!/^blob:/.test(n)&&/^blob:/.test(r)&&(!this.lastSource_||this.lastSource_.tech!==r&&this.lastSource_.player!==n)&&(i=()=>{}),i(r),e.src||this.tech_.any(["sourceset","loadstart"],s=>{if(s.type==="sourceset")return;const a=this.techGet_("currentSrc");this.lastSource_.tech=a,this.updateSourceCaches_(a)})}this.lastSource_={player:this.currentSource().src,tech:e.src},this.trigger({src:e.src,type:"sourceset"})}hasStarted(e){if(e===void 0)return this.hasStarted_;e!==this.hasStarted_&&(this.hasStarted_=e,this.hasStarted_?this.addClass("vjs-has-started"):this.removeClass("vjs-has-started"))}handleTechPlay_(){this.removeClass("vjs-ended","vjs-paused"),this.addClass("vjs-playing"),this.hasStarted(!0),this.trigger("play")}handleTechRateChange_(){this.tech_.playbackRate()>0&&this.cache_.lastPlaybackRate===0&&(this.queuedCallbacks_.forEach(e=>e.callback(e.event)),this.queuedCallbacks_=[]),this.cache_.lastPlaybackRate=this.tech_.playbackRate(),this.trigger("ratechange")}handleTechWaiting_(){this.addClass("vjs-waiting"),this.trigger("waiting");const e=this.currentTime(),i=()=>{e!==this.currentTime()&&(this.removeClass("vjs-waiting"),this.off("timeupdate",i))};this.on("timeupdate",i)}handleTechCanPlay_(){this.removeClass("vjs-waiting"),this.trigger("canplay")}handleTechCanPlayThrough_(){this.removeClass("vjs-waiting"),this.trigger("canplaythrough")}handleTechPlaying_(){this.removeClass("vjs-waiting"),this.trigger("playing")}handleTechSeeking_(){this.addClass("vjs-seeking"),this.trigger("seeking")}handleTechSeeked_(){this.removeClass("vjs-seeking","vjs-ended"),this.trigger("seeked")}handleTechPause_(){this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.trigger("pause")}handleTechEnded_(){this.addClass("vjs-ended"),this.removeClass("vjs-waiting"),this.options_.loop?(this.currentTime(0),this.play()):this.paused()||this.pause(),this.trigger("ended")}handleTechDurationChange_(){this.duration(this.techGet_("duration"))}handleTechClick_(e){this.controls_&&(this.options_===void 0||this.options_.userActions===void 0||this.options_.userActions.click===void 0||this.options_.userActions.click!==!1)&&(this.options_!==void 0&&this.options_.userActions!==void 0&&typeof this.options_.userActions.click=="function"?this.options_.userActions.click.call(this,e):this.paused()?Ci(this.play()):this.pause())}handleTechDoubleClick_(e){if(!this.controls_)return;Array.prototype.some.call(this.$$(".vjs-control-bar, .vjs-modal-dialog"),n=>n.contains(e.target))||(this.options_===void 0||this.options_.userActions===void 0||this.options_.userActions.doubleClick===void 0||this.options_.userActions.doubleClick!==!1)&&(this.options_!==void 0&&this.options_.userActions!==void 0&&typeof this.options_.userActions.doubleClick=="function"?this.options_.userActions.doubleClick.call(this,e):this.isFullscreen()?this.exitFullscreen():this.requestFullscreen())}handleTechTap_(){this.userActive(!this.userActive())}handleTechTouchStart_(){this.userWasActive=this.userActive()}handleTechTouchMove_(){this.userWasActive&&this.reportUserActivity()}handleTechTouchEnd_(e){e.cancelable&&e.preventDefault()}toggleFullscreenClass_(){this.isFullscreen()?this.addClass("vjs-fullscreen"):this.removeClass("vjs-fullscreen")}documentFullscreenChange_(e){const i=e.target.player;if(i&&i!==this)return;const n=this.el();let r=V[this.fsApi_.fullscreenElement]===n;!r&&n.matches&&(r=n.matches(":"+this.fsApi_.fullscreen)),this.isFullscreen(r)}handleTechFullscreenChange_(e,i){i&&(i.nativeIOSFullscreen&&(this.addClass("vjs-ios-native-fs"),this.tech_.one("webkitendfullscreen",()=>{this.removeClass("vjs-ios-native-fs")})),this.isFullscreen(i.isFullscreen))}handleTechFullscreenError_(e,i){this.trigger("fullscreenerror",i)}togglePictureInPictureClass_(){this.isInPictureInPicture()?this.addClass("vjs-picture-in-picture"):this.removeClass("vjs-picture-in-picture")}handleTechEnterPictureInPicture_(e){this.isInPictureInPicture(!0)}handleTechLeavePictureInPicture_(e){this.isInPictureInPicture(!1)}handleTechError_(){const e=this.tech_.error();e&&this.error(e)}handleTechTextData_(){let e=null;arguments.length>1&&(e=arguments[1]),this.trigger("textdata",e)}getCache(){return this.cache_}resetCache_(){this.cache_={currentTime:0,initTime:0,inactivityTimeout:this.options_.inactivityTimeout,duration:NaN,lastVolume:1,lastPlaybackRate:this.defaultPlaybackRate(),media:null,src:"",source:{},sources:[],playbackRates:[],volume:1}}techCall_(e,i){this.ready(function(){if(e in m4)return f4(this.middleware_,this.tech_,e,i);if(e in yy)return gy(this.middleware_,this.tech_,e,i);try{this.tech_&&this.tech_[e](i)}catch(n){throw oe(n),n}},!0)}techGet_(e){if(!(!this.tech_||!this.tech_.isReady_)){if(e in p4)return h4(this.middleware_,this.tech_,e);if(e in yy)return gy(this.middleware_,this.tech_,e);try{return this.tech_[e]()}catch(i){throw this.tech_[e]===void 0?(oe(`Video.js: ${e} method not defined for ${this.techName_} playback technology.`,i),i):i.name==="TypeError"?(oe(`Video.js: ${e} unavailable on ${this.techName_} playback technology element.`,i),this.tech_.isReady_=!1,i):(oe(i),i)}}}play(){return new Promise(e=>{this.play_(e)})}play_(e=Ci){this.playCallbacks_.push(e);const i=!!(!this.changingSrc_&&(this.src()||this.currentSrc())),n=!!(yc||Tt);if(this.waitToPlay_&&(this.off(["ready","loadstart"],this.waitToPlay_),this.waitToPlay_=null),!this.isReady_||!i){this.waitToPlay_=a=>{this.play_()},this.one(["ready","loadstart"],this.waitToPlay_),!i&&n&&this.load();return}const r=this.techGet_("play");n&&this.hasClass("vjs-ended")&&this.resetProgressBar_(),r===null?this.runPlayTerminatedQueue_():this.runPlayCallbacks_(r)}runPlayTerminatedQueue_(){const e=this.playTerminatedQueue_.slice(0);this.playTerminatedQueue_=[],e.forEach(function(i){i()})}runPlayCallbacks_(e){const i=this.playCallbacks_.slice(0);this.playCallbacks_=[],this.playTerminatedQueue_=[],i.forEach(function(n){n(e)})}pause(){this.techCall_("pause")}paused(){return this.techGet_("paused")!==!1}played(){return this.techGet_("played")||Oi(0,0)}scrubbing(e){if(typeof e>"u")return this.scrubbing_;this.scrubbing_=!!e,this.techCall_("setScrubbing",this.scrubbing_),e?this.addClass("vjs-scrubbing"):this.removeClass("vjs-scrubbing")}currentTime(e){if(e===void 0)return this.cache_.currentTime=this.techGet_("currentTime")||0,this.cache_.currentTime;if(e<0&&(e=0),!this.isReady_||this.changingSrc_||!this.tech_||!this.tech_.isReady_){this.cache_.initTime=e,this.off("canplay",this.boundApplyInitTime_),this.one("canplay",this.boundApplyInitTime_);return}this.techCall_("setCurrentTime",e),this.cache_.initTime=0,isFinite(e)&&(this.cache_.currentTime=Number(e))}applyInitTime_(){this.currentTime(this.cache_.initTime)}duration(e){if(e===void 0)return this.cache_.duration!==void 0?this.cache_.duration:NaN;e=parseFloat(e),e<0&&(e=1/0),e!==this.cache_.duration&&(this.cache_.duration=e,e===1/0?this.addClass("vjs-live"):this.removeClass("vjs-live"),isNaN(e)||this.trigger("durationchange"))}remainingTime(){return this.duration()-this.currentTime()}remainingTimeDisplay(){return Math.floor(this.duration())-Math.floor(this.currentTime())}buffered(){let e=this.techGet_("buffered");return(!e||!e.length)&&(e=Oi(0,0)),e}bufferedPercent(){return cT(this.buffered(),this.duration())}bufferedEnd(){const e=this.buffered(),i=this.duration();let n=e.end(e.length-1);return n>i&&(n=i),n}volume(e){let i;if(e!==void 0){i=Math.max(0,Math.min(1,e)),this.cache_.volume=i,this.techCall_("setVolume",i),i>0&&this.lastVolume_(i);return}return i=parseFloat(this.techGet_("volume")),isNaN(i)?1:i}muted(e){if(e!==void 0){this.techCall_("setMuted",e);return}return this.techGet_("muted")||!1}defaultMuted(e){return e!==void 0&&this.techCall_("setDefaultMuted",e),this.techGet_("defaultMuted")||!1}lastVolume_(e){if(e!==void 0&&e!==0){this.cache_.lastVolume=e;return}return this.cache_.lastVolume}supportsFullScreen(){return this.techGet_("supportsFullScreen")||!1}isFullscreen(e){if(e!==void 0){const i=this.isFullscreen_;this.isFullscreen_=!!e,this.isFullscreen_!==i&&this.fsApi_.prefixed&&this.trigger("fullscreenchange"),this.toggleFullscreenClass_();return}return this.isFullscreen_}requestFullscreen(e){this.isInPictureInPicture()&&this.exitPictureInPicture();const i=this;return new Promise((n,r)=>{function s(){i.off("fullscreenerror",o),i.off("fullscreenchange",a)}function a(){s(),n()}function o(c,p){s(),r(p)}i.one("fullscreenchange",a),i.one("fullscreenerror",o);const l=i.requestFullscreenHelper_(e);l&&(l.then(s,s),l.then(n,r))})}requestFullscreenHelper_(e){let i;if(this.fsApi_.prefixed||(i=this.options_.fullscreen&&this.options_.fullscreen.options||{},e!==void 0&&(i=e)),this.fsApi_.requestFullscreen){const n=this.el_[this.fsApi_.requestFullscreen](i);return n&&n.then(()=>this.isFullscreen(!0),()=>this.isFullscreen(!1)),n}else this.tech_.supportsFullScreen()&&!this.options_.preferFullWindow?this.techCall_("enterFullScreen"):this.enterFullWindow()}exitFullscreen(){const e=this;return new Promise((i,n)=>{function r(){e.off("fullscreenerror",a),e.off("fullscreenchange",s)}function s(){r(),i()}function a(l,c){r(),n(c)}e.one("fullscreenchange",s),e.one("fullscreenerror",a);const o=e.exitFullscreenHelper_();o&&(o.then(r,r),o.then(i,n))})}exitFullscreenHelper_(){if(this.fsApi_.requestFullscreen){const e=V[this.fsApi_.exitFullscreen]();return e&&Ci(e.then(()=>this.isFullscreen(!1))),e}else this.tech_.supportsFullScreen()&&!this.options_.preferFullWindow?this.techCall_("exitFullScreen"):this.exitFullWindow()}enterFullWindow(){this.isFullscreen(!0),this.isFullWindow=!0,this.docOrigOverflow=V.documentElement.style.overflow,Ht(V,"keydown",this.boundFullWindowOnEscKey_),V.documentElement.style.overflow="hidden",lr(V.body,"vjs-full-window"),this.trigger("enterFullWindow")}fullWindowOnEscKey(e){re.isEventKey(e,"Esc")&&this.isFullscreen()===!0&&(this.isFullWindow?this.exitFullWindow():this.exitFullscreen())}exitFullWindow(){this.isFullscreen(!1),this.isFullWindow=!1,lt(V,"keydown",this.boundFullWindowOnEscKey_),V.documentElement.style.overflow=this.docOrigOverflow,vc(V.body,"vjs-full-window"),this.trigger("exitFullWindow")}disablePictureInPicture(e){if(e===void 0)return this.techGet_("disablePictureInPicture");this.techCall_("setDisablePictureInPicture",e),this.options_.disablePictureInPicture=e,this.trigger("disablepictureinpicturechanged")}isInPictureInPicture(e){if(e!==void 0){this.isInPictureInPicture_=!!e,this.togglePictureInPictureClass_();return}return!!this.isInPictureInPicture_}requestPictureInPicture(){if(this.options_.enableDocumentPictureInPicture&&A.documentPictureInPicture){const e=V.createElement(this.el().tagName);return e.classList=this.el().classList,e.classList.add("vjs-pip-container"),this.posterImage&&e.appendChild(this.posterImage.el().cloneNode(!0)),this.titleBar&&e.appendChild(this.titleBar.el().cloneNode(!0)),e.appendChild(ae("p",{className:"vjs-pip-text"},{},this.localize("Playing in picture-in-picture"))),A.documentPictureInPicture.requestWindow({width:this.videoWidth(),height:this.videoHeight()}).then(i=>(Y2(i),this.el_.parentNode.insertBefore(e,this.el_),i.document.body.appendChild(this.el_),i.document.body.classList.add("vjs-pip-window"),this.player_.isInPictureInPicture(!0),this.player_.trigger("enterpictureinpicture"),i.addEventListener("pagehide",n=>{const r=n.target.querySelector(".video-js");e.parentNode.replaceChild(r,e),this.player_.isInPictureInPicture(!1),this.player_.trigger("leavepictureinpicture")}),i))}return"pictureInPictureEnabled"in V&&this.disablePictureInPicture()===!1?this.techGet_("requestPictureInPicture"):Promise.reject("No PiP mode is available")}exitPictureInPicture(){if(A.documentPictureInPicture&&A.documentPictureInPicture.window)return A.documentPictureInPicture.window.close(),Promise.resolve();if("pictureInPictureEnabled"in V)return V.exitPictureInPicture()}handleKeyDown(e){const{userActions:i}=this.options_;!i||!i.hotkeys||(r=>{const s=r.tagName.toLowerCase();if(r.isContentEditable)return!0;const a=["button","checkbox","hidden","radio","reset","submit"];return s==="input"?a.indexOf(r.type)===-1:["textarea"].indexOf(s)!==-1})(this.el_.ownerDocument.activeElement)||(typeof i.hotkeys=="function"?i.hotkeys.call(this,e):this.handleHotkeys(e))}handleHotkeys(e){const i=this.options_.userActions?this.options_.userActions.hotkeys:{},{fullscreenKey:n=a=>re.isEventKey(a,"f"),muteKey:r=a=>re.isEventKey(a,"m"),playPauseKey:s=a=>re.isEventKey(a,"k")||re.isEventKey(a,"Space")}=i;if(n.call(this,e)){e.preventDefault(),e.stopPropagation();const a=B.getComponent("FullscreenToggle");V[this.fsApi_.fullscreenEnabled]!==!1&&a.prototype.handleClick.call(this,e)}else r.call(this,e)?(e.preventDefault(),e.stopPropagation(),B.getComponent("MuteToggle").prototype.handleClick.call(this,e)):s.call(this,e)&&(e.preventDefault(),e.stopPropagation(),B.getComponent("PlayToggle").prototype.handleClick.call(this,e))}canPlayType(e){let i;for(let n=0,r=this.options_.techOrder;n[o,se.getTech(o)]).filter(([o,l])=>l?l.isSupported():(oe.error(`The "${o}" tech is undefined. Skipped browser support check for that tech.`),!1)),n=function(o,l,c){let p;return o.some(g=>l.some(v=>{if(p=c(g,v),p)return!0})),p};let r;const s=o=>(l,c)=>o(c,l),a=([o,l],c)=>{if(l.canPlaySource(c,this.options_[o.toLowerCase()]))return{source:c,tech:o}};return this.options_.sourceOrder?r=n(e,i,s(a)):r=n(i,e,a),r||!1}handleSrc_(e,i){if(typeof e>"u")return this.cache_.src||"";this.resetRetryOnError_&&this.resetRetryOnError_();const n=mT(e);if(!n.length){this.setTimeout(function(){this.error({code:4,message:this.options_.notSupportedMessage})},0);return}if(this.changingSrc_=!0,i||(this.cache_.sources=n),this.updateSourceCaches_(n[0]),c4(this,n[0],(r,s)=>{if(this.middleware_=s,i||(this.cache_.sources=n),this.updateSourceCaches_(r),this.src_(r)){if(n.length>1)return this.handleSrc_(n.slice(1));this.changingSrc_=!1,this.setTimeout(function(){this.error({code:4,message:this.options_.notSupportedMessage})},0),this.triggerReady();return}d4(s,this.tech_)}),n.length>1){const r=()=>{this.error(null),this.handleSrc_(n.slice(1),!0)},s=()=>{this.off("error",r)};this.one("error",r),this.one("playing",s),this.resetRetryOnError_=()=>{this.off("error",r),this.off("playing",s)}}}src(e){return this.handleSrc_(e,!1)}src_(e){const i=this.selectSource([e]);return i?aT(i.tech,this.techName_)?(this.ready(function(){this.tech_.constructor.prototype.hasOwnProperty("setSource")?this.techCall_("setSource",e):this.techCall_("src",e.src),this.changingSrc_=!1},!0),!1):(this.changingSrc_=!0,this.loadTech_(i.tech,i.source),this.tech_.ready(()=>{this.changingSrc_=!1}),!1):!0}load(){if(this.tech_&&this.tech_.vhs){this.src(this.currentSource());return}this.techCall_("load")}reset(){if(this.paused())this.doReset_();else{const e=this.play();Ci(e.then(()=>this.doReset_()))}}doReset_(){this.tech_&&this.tech_.clearTracks("text"),this.resetCache_(),this.poster(""),this.loadTech_(this.options_.techOrder[0],null),this.techCall_("reset"),this.resetControlBarUI_(),Ji(this)&&this.trigger("playerreset")}resetControlBarUI_(){this.resetProgressBar_(),this.resetPlaybackRate_(),this.resetVolumeBar_()}resetProgressBar_(){this.currentTime(0);const{currentTimeDisplay:e,durationDisplay:i,progressControl:n,remainingTimeDisplay:r}=this.controlBar||{},{seekBar:s}=n||{};e&&e.updateContent(),i&&i.updateContent(),r&&r.updateContent(),s&&(s.update(),s.loadProgressBar&&s.loadProgressBar.update())}resetPlaybackRate_(){this.playbackRate(this.defaultPlaybackRate()),this.handleTechRateChange_()}resetVolumeBar_(){this.volume(1),this.trigger("volumechange")}currentSources(){const e=this.currentSource(),i=[];return Object.keys(e).length!==0&&i.push(e),this.cache_.sources||i}currentSource(){return this.cache_.source||{}}currentSrc(){return this.currentSource()&&this.currentSource().src||""}currentType(){return this.currentSource()&&this.currentSource().type||""}preload(e){if(e!==void 0){this.techCall_("setPreload",e),this.options_.preload=e;return}return this.techGet_("preload")}autoplay(e){if(e===void 0)return this.options_.autoplay||!1;let i;typeof e=="string"&&/(any|play|muted)/.test(e)||e===!0&&this.options_.normalizeAutoplay?(this.options_.autoplay=e,this.manualAutoplay_(typeof e=="string"?e:"play"),i=!1):e?this.options_.autoplay=!0:this.options_.autoplay=!1,i=typeof i>"u"?this.options_.autoplay:i,this.tech_&&this.techCall_("setAutoplay",i)}playsinline(e){return e!==void 0&&(this.techCall_("setPlaysinline",e),this.options_.playsinline=e),this.techGet_("playsinline")}loop(e){if(e!==void 0){this.techCall_("setLoop",e),this.options_.loop=e;return}return this.techGet_("loop")}poster(e){if(e===void 0)return this.poster_;e||(e=""),e!==this.poster_&&(this.poster_=e,this.techCall_("setPoster",e),this.isPosterFromTech_=!1,this.trigger("posterchange"))}handleTechPosterChange_(){if((!this.poster_||this.options_.techCanOverridePoster)&&this.tech_&&this.tech_.poster){const e=this.tech_.poster()||"";e!==this.poster_&&(this.poster_=e,this.isPosterFromTech_=!0,this.trigger("posterchange"))}}controls(e){if(e===void 0)return!!this.controls_;e=!!e,this.controls_!==e&&(this.controls_=e,this.usingNativeControls()&&this.techCall_("setControls",e),this.controls_?(this.removeClass("vjs-controls-disabled"),this.addClass("vjs-controls-enabled"),this.trigger("controlsenabled"),this.usingNativeControls()||this.addTechControlsListeners_()):(this.removeClass("vjs-controls-enabled"),this.addClass("vjs-controls-disabled"),this.trigger("controlsdisabled"),this.usingNativeControls()||this.removeTechControlsListeners_()))}usingNativeControls(e){if(e===void 0)return!!this.usingNativeControls_;e=!!e,this.usingNativeControls_!==e&&(this.usingNativeControls_=e,this.usingNativeControls_?(this.addClass("vjs-using-native-controls"),this.trigger("usingnativecontrols")):(this.removeClass("vjs-using-native-controls"),this.trigger("usingcustomcontrols")))}error(e){if(e===void 0)return this.error_||null;if(Rn("beforeerror").forEach(i=>{const n=i(this,e);if(!(Ni(n)&&!Array.isArray(n)||typeof n=="string"||typeof n=="number"||n===null)){this.log.error("please return a value that MediaError expects in beforeerror hooks");return}e=n}),this.options_.suppressNotSupportedError&&e&&e.code===4){const i=function(){this.error(e)};this.options_.suppressNotSupportedError=!1,this.any(["click","touchstart"],i),this.one("loadstart",function(){this.off(["click","touchstart"],i)});return}if(e===null){this.error_=null,this.removeClass("vjs-error"),this.errorDisplay&&this.errorDisplay.close();return}this.error_=new vt(e),this.addClass("vjs-error"),oe.error(`(CODE:${this.error_.code} ${vt.errorTypes[this.error_.code]})`,this.error_.message,this.error_),this.trigger("error"),Rn("error").forEach(i=>i(this,this.error_))}reportUserActivity(e){this.userActivity_=!0}userActive(e){if(e===void 0)return this.userActive_;if(e=!!e,e!==this.userActive_){if(this.userActive_=e,this.userActive_){this.userActivity_=!0,this.removeClass("vjs-user-inactive"),this.addClass("vjs-user-active"),this.trigger("useractive");return}this.tech_&&this.tech_.one("mousemove",function(i){i.stopPropagation(),i.preventDefault()}),this.userActivity_=!1,this.removeClass("vjs-user-active"),this.addClass("vjs-user-inactive"),this.trigger("userinactive")}}listenForUserActivity_(){let e,i,n;const r=Ee(this,this.reportUserActivity),s=function(g){(g.screenX!==i||g.screenY!==n)&&(i=g.screenX,n=g.screenY,r())},a=function(){r(),this.clearInterval(e),e=this.setInterval(r,250)},o=function(g){r(),this.clearInterval(e)};this.on("mousedown",a),this.on("mousemove",s),this.on("mouseup",o),this.on("mouseleave",o);const l=this.getChild("controlBar");l&&!Tt&&!Ri&&(l.on("mouseenter",function(g){this.player().options_.inactivityTimeout!==0&&(this.player().cache_.inactivityTimeout=this.player().options_.inactivityTimeout),this.player().options_.inactivityTimeout=0}),l.on("mouseleave",function(g){this.player().options_.inactivityTimeout=this.player().cache_.inactivityTimeout})),this.on("keydown",r),this.on("keyup",r);let c;const p=function(){if(!this.userActivity_)return;this.userActivity_=!1,this.userActive(!0),this.clearTimeout(c);const g=this.options_.inactivityTimeout;g<=0||(c=this.setTimeout(function(){this.userActivity_||this.userActive(!1)},g))};this.setInterval(p,250)}playbackRate(e){if(e!==void 0){this.techCall_("setPlaybackRate",e);return}return this.tech_&&this.tech_.featuresPlaybackRate?this.cache_.lastPlaybackRate||this.techGet_("playbackRate"):1}defaultPlaybackRate(e){return e!==void 0?this.techCall_("setDefaultPlaybackRate",e):this.tech_&&this.tech_.featuresPlaybackRate?this.techGet_("defaultPlaybackRate"):1}isAudio(e){if(e!==void 0){this.isAudio_=!!e;return}return!!this.isAudio_}enableAudioOnlyUI_(){this.addClass("vjs-audio-only-mode");const e=this.children(),i=this.getChild("ControlBar"),n=i&&i.currentHeight();e.forEach(r=>{r!==i&&r.el_&&!r.hasClass("vjs-hidden")&&(r.hide(),this.audioOnlyCache_.hiddenChildren.push(r))}),this.audioOnlyCache_.playerHeight=this.currentHeight(),this.height(n),this.trigger("audioonlymodechange")}disableAudioOnlyUI_(){this.removeClass("vjs-audio-only-mode"),this.audioOnlyCache_.hiddenChildren.forEach(e=>e.show()),this.height(this.audioOnlyCache_.playerHeight),this.trigger("audioonlymodechange")}audioOnlyMode(e){if(typeof e!="boolean"||e===this.audioOnlyMode_)return this.audioOnlyMode_;if(this.audioOnlyMode_=e,e){const i=[];return this.isInPictureInPicture()&&i.push(this.exitPictureInPicture()),this.isFullscreen()&&i.push(this.exitFullscreen()),this.audioPosterMode()&&i.push(this.audioPosterMode(!1)),Promise.all(i).then(()=>this.enableAudioOnlyUI_())}return Promise.resolve().then(()=>this.disableAudioOnlyUI_())}enablePosterModeUI_(){(this.tech_&&this.tech_).hide(),this.addClass("vjs-audio-poster-mode"),this.trigger("audiopostermodechange")}disablePosterModeUI_(){(this.tech_&&this.tech_).show(),this.removeClass("vjs-audio-poster-mode"),this.trigger("audiopostermodechange")}audioPosterMode(e){return typeof e!="boolean"||e===this.audioPosterMode_?this.audioPosterMode_:(this.audioPosterMode_=e,e?this.audioOnlyMode()?this.audioOnlyMode(!1).then(()=>{this.enablePosterModeUI_()}):Promise.resolve().then(()=>{this.enablePosterModeUI_()}):Promise.resolve().then(()=>{this.disablePosterModeUI_()}))}addTextTrack(e,i,n){if(this.tech_)return this.tech_.addTextTrack(e,i,n)}addRemoteTextTrack(e,i){if(this.tech_)return this.tech_.addRemoteTextTrack(e,i)}removeRemoteTextTrack(e={}){let{track:i}=e;if(i||(i=e),this.tech_)return this.tech_.removeRemoteTextTrack(i)}getVideoPlaybackQuality(){return this.techGet_("getVideoPlaybackQuality")}videoWidth(){return this.tech_&&this.tech_.videoWidth&&this.tech_.videoWidth()||0}videoHeight(){return this.tech_&&this.tech_.videoHeight&&this.tech_.videoHeight()||0}language(e){if(e===void 0)return this.language_;this.language_!==String(e).toLowerCase()&&(this.language_=String(e).toLowerCase(),Ji(this)&&this.trigger("languagechange"))}languages(){return xe(be.prototype.options_.languages,this.languages_)}toJSON(){const e=xe(this.options_),i=e.tracks;e.tracks=[];for(let n=0;n{this.removeChild(n)}),n.open(),n}updateCurrentBreakpoint_(){if(!this.responsive())return;const e=this.currentBreakpoint(),i=this.currentWidth();for(let n=0;nthis.addRemoteTextTrack(g,!1)),this.titleBar&&this.titleBar.update({title:p,description:a||r||""}),this.ready(i)}getMedia(){if(!this.cache_.media){const e=this.poster(),i=this.currentSources(),n=Array.prototype.map.call(this.remoteTextTracks(),s=>({kind:s.kind,label:s.label,language:s.language,src:s.src})),r={src:i,textTracks:n};return e&&(r.poster=e,r.artwork=[{src:r.poster,type:Au(r.poster)}]),r}return xe(this.cache_.media)}static getTagSettings(e){const i={sources:[],tracks:[]},n=vn(e),r=n["data-setup"];if(Na(e,"vjs-fill")&&(n.fill=!0),Na(e,"vjs-fluid")&&(n.fluid=!0),r!==null){const[s,a]=RD(r||"{}");s&&oe.error(s),Object.assign(n,a)}if(Object.assign(i,n),e.hasChildNodes()){const s=e.childNodes;for(let a=0,o=s.length;atypeof i=="number")&&(this.cache_.playbackRates=e,this.trigger("playbackrateschange"))}}mt.names.forEach(function(t){const e=mt[t];be.prototype[e.getterName]=function(){return this.tech_?this.tech_[e.getterName]():(this[e.privateName]=this[e.privateName]||new e.ListClass,this[e.privateName])}});be.prototype.crossorigin=be.prototype.crossOrigin;be.players={};const ha=A.navigator;be.prototype.options_={techOrder:se.defaultTechOrder_,html5:{},enableSourceset:!0,inactivityTimeout:2e3,playbackRates:[],liveui:!1,children:["mediaLoader","posterImage","titleBar","textTrackDisplay","loadingSpinner","bigPlayButton","liveTracker","controlBar","errorDisplay","textTrackSettings","resizeManager"],language:ha&&(ha.languages&&ha.languages[0]||ha.userLanguage||ha.language)||"en",languages:{},notSupportedMessage:"No compatible source was found for this media.",normalizeAutoplay:!1,fullscreen:{options:{navigationUI:"hide"}},breakpoints:{},responsive:!1,audioOnlyMode:!1,audioPosterMode:!1};["ended","seeking","seekable","networkState","readyState"].forEach(function(t){be.prototype[t]=function(){return this.techGet_(t)}});jT.forEach(function(t){be.prototype[`handleTech${Fe(t)}_`]=function(){return this.trigger(t)}});B.registerComponent("Player",be);const ku="plugin",as="activePlugins_",Xr={},Pu=t=>Xr.hasOwnProperty(t),jl=t=>Pu(t)?Xr[t]:void 0,$T=(t,e)=>{t[as]=t[as]||{},t[as][e]=!0},Iu=(t,e,i)=>{const n=(i?"before":"")+"pluginsetup";t.trigger(n,e),t.trigger(n+":"+e.name,e)},J4=function(t,e){const i=function(){Iu(this,{name:t,plugin:e,instance:null},!0);const n=e.apply(this,arguments);return $T(this,t),Iu(this,{name:t,plugin:e,instance:n}),n};return Object.keys(e).forEach(function(n){i[n]=e[n]}),i},Ly=(t,e)=>(e.prototype.name=t,function(...i){Iu(this,{name:t,plugin:e,instance:null},!0);const n=new e(this,...i);return this[t]=()=>n,Iu(this,n.getEventHash()),n});class Lt{constructor(e){if(this.constructor===Lt)throw new Error("Plugin must be sub-classed; not directly instantiated.");this.player=e,this.log||(this.log=this.player.log.createLogger(this.name)),Vp(this),delete this.trigger,sT(this,this.constructor.defaultState),$T(e,this.name),this.dispose=this.dispose.bind(this),e.on("dispose",this.dispose)}version(){return this.constructor.VERSION}getEventHash(e={}){return e.name=this.name,e.plugin=this.constructor,e.instance=this,e}trigger(e,i={}){return Rs(this.eventBusEl_,e,this.getEventHash(i))}handleStateChanged(e){}dispose(){const{name:e,player:i}=this;this.trigger("dispose"),this.off(),i.off("dispose",this.dispose),i[as][e]=!1,this.player=this.state=null,i[e]=Ly(e,Xr[e])}static isBasic(e){const i=typeof e=="string"?jl(e):e;return typeof i=="function"&&!Lt.prototype.isPrototypeOf(i.prototype)}static registerPlugin(e,i){if(typeof e!="string")throw new Error(`Illegal plugin name, "${e}", must be a string, was ${typeof e}.`);if(Pu(e))oe.warn(`A plugin named "${e}" already exists. You may want to avoid re-registering plugins!`);else if(be.prototype.hasOwnProperty(e))throw new Error(`Illegal plugin name, "${e}", cannot share a name with an existing player method!`);if(typeof i!="function")throw new Error(`Illegal plugin for "${e}", must be a function, was ${typeof i}.`);return Xr[e]=i,e!==ku&&(Lt.isBasic(i)?be.prototype[e]=J4(e,i):be.prototype[e]=Ly(e,i)),i}static deregisterPlugin(e){if(e===ku)throw new Error("Cannot de-register base plugin.");Pu(e)&&(delete Xr[e],delete be.prototype[e])}static getPlugins(e=Object.keys(Xr)){let i;return e.forEach(n=>{const r=jl(n);r&&(i=i||{},i[n]=r)}),i}static getPluginVersion(e){const i=jl(e);return i&&i.VERSION||""}}Lt.getPlugin=jl;Lt.BASE_PLUGIN_NAME=ku;Lt.registerPlugin(ku,Lt);be.prototype.usingPlugin=function(t){return!!this[as]&&this[as][t]===!0};be.prototype.hasPlugin=function(t){return!!Pu(t)};function Z4(t,e){let i=!1;return function(...n){return i||oe.warn(t),i=!0,e.apply(this,n)}}function gi(t,e,i,n){return Z4(`${e} is deprecated and will be removed in ${t}.0; please use ${i} instead.`,n)}const VT=t=>t.indexOf("#")===0?t.slice(1):t;function M(t,e,i){let n=M.getPlayer(t);if(n)return e&&oe.warn(`Player "${t}" is already initialised. Options will not be applied.`),i&&n.ready(i),n;const r=typeof t=="string"?Mn("#"+VT(t)):t;if(!Ns(r))throw new TypeError("The element or ID supplied is not valid. (videojs)");const a=("getRootNode"in r?r.getRootNode()instanceof A.ShadowRoot:!1)?r.getRootNode():r.ownerDocument.body;(!r.ownerDocument.defaultView||!a.contains(r))&&oe.warn("The element supplied is not included in the DOM"),e=e||{},e.restoreEl===!0&&(e.restoreEl=(r.parentNode&&r.parentNode.hasAttribute("data-vjs-player")?r.parentNode:r).cloneNode(!0)),Rn("beforesetup").forEach(l=>{const c=l(r,xe(e));if(!Ni(c)||Array.isArray(c)){oe.error("please return an object in beforesetup hooks");return}e=xe(e,c)});const o=B.getComponent("Player");return n=new o(r,e,i),Rn("setup").forEach(l=>l(n)),n}M.hooks_=qi;M.hooks=Rn;M.hook=O3;M.hookOnce=N3;M.removeHook=I2;if(A.VIDEOJS_NO_DYNAMIC_STYLE!==!0&&Os()){let t=Mn(".vjs-styles-defaults");if(!t){t=eT("vjs-styles-defaults");const e=Mn("head");e&&e.insertBefore(t,e.firstChild),tT(t,`
- .video-js {
- width: 300px;
- height: 150px;
- }
-
- .vjs-fluid:not(.vjs-audio-only-mode) {
- padding-top: 56.25%
- }
- `)}}Yh(1,M);M.VERSION=P2;M.options=be.prototype.options_;M.getPlayers=()=>be.players;M.getPlayer=t=>{const e=be.players;let i;if(typeof t=="string"){const n=VT(t),r=e[n];if(r)return r;i=Mn("#"+n)}else i=t;if(Ns(i)){const{player:n,playerId:r}=i;if(n||e[r])return n||e[r]}};M.getAllPlayers=()=>Object.keys(be.players).map(t=>be.players[t]).filter(Boolean);M.players=be.players;M.getComponent=B.getComponent;M.registerComponent=(t,e)=>(se.isTech(e)&&oe.warn(`The ${t} tech was registered as a component. It should instead be registered using videojs.registerTech(name, tech)`),B.registerComponent.call(B,t,e));M.getTech=se.getTech;M.registerTech=se.registerTech;M.use=u4;Object.defineProperty(M,"middleware",{value:{},writeable:!1,enumerable:!0});Object.defineProperty(M.middleware,"TERMINATOR",{value:Du,writeable:!1,enumerable:!0});M.browser=F3;M.obj=B3;M.mergeOptions=gi(9,"videojs.mergeOptions","videojs.obj.merge",xe);M.defineLazyProperty=gi(9,"videojs.defineLazyProperty","videojs.obj.defineLazyProperty",fc);M.bind=gi(9,"videojs.bind","native Function.prototype.bind",Ee);M.registerPlugin=Lt.registerPlugin;M.deregisterPlugin=Lt.deregisterPlugin;M.plugin=(t,e)=>(oe.warn("videojs.plugin() is deprecated; use videojs.registerPlugin() instead"),Lt.registerPlugin(t,e));M.getPlugins=Lt.getPlugins;M.getPlugin=Lt.getPlugin;M.getPluginVersion=Lt.getPluginVersion;M.addLanguage=function(t,e){return t=(""+t).toLowerCase(),M.options.languages=xe(M.options.languages,{[t]:e}),M.options.languages[t]};M.log=oe;M.createLogger=L2;M.time=J3;M.createTimeRange=gi(9,"videojs.createTimeRange","videojs.time.createTimeRanges",Oi);M.createTimeRanges=gi(9,"videojs.createTimeRanges","videojs.time.createTimeRanges",Oi);M.formatTime=gi(9,"videojs.formatTime","videojs.time.formatTime",gr);M.setFormatTime=gi(9,"videojs.setFormatTime","videojs.time.setFormatTime",lT);M.resetFormatTime=gi(9,"videojs.resetFormatTime","videojs.time.resetFormatTime",uT);M.parseUrl=gi(9,"videojs.parseUrl","videojs.url.parseUrl",qp);M.isCrossOrigin=gi(9,"videojs.isCrossOrigin","videojs.url.isCrossOrigin",Cc);M.EventTarget=ri;M.any=$p;M.on=Ht;M.one=Ec;M.off=lt;M.trigger=Rs;M.xhr=O1;M.TextTrack=Eo;M.AudioTrack=fT;M.VideoTrack=pT;["isEl","isTextNode","createEl","hasClass","addClass","removeClass","toggleClass","setAttributes","getAttributes","emptyEl","appendContent","insertContent"].forEach(t=>{M[t]=function(){return oe.warn(`videojs.${t}() is deprecated; use videojs.dom.${t}() instead`),J2[t].apply(null,arguments)}});M.computedStyle=gi(9,"videojs.computedStyle","videojs.dom.computedStyle",Cs);M.dom=J2;M.fn=W3;M.num=k4;M.str=Q3;M.url=o4;/*! @name videojs-contrib-quality-levels @version 4.0.0 @license Apache-2.0 */class eP{constructor(e){let i=this;return i.id=e.id,i.label=i.id,i.width=e.width,i.height=e.height,i.bitrate=e.bandwidth,i.frameRate=e.frameRate,i.enabled_=e.enabled,Object.defineProperty(i,"enabled",{get(){return i.enabled_()},set(n){i.enabled_(n)}}),i}}class Lu extends M.EventTarget{constructor(){super();let e=this;return e.levels_=[],e.selectedIndex_=-1,Object.defineProperty(e,"selectedIndex",{get(){return e.selectedIndex_}}),Object.defineProperty(e,"length",{get(){return e.levels_.length}}),e[Symbol.iterator]=()=>e.levels_.values(),e}addQualityLevel(e){let i=this.getQualityLevelById(e.id);if(i)return i;const n=this.levels_.length;return i=new eP(e),""+n in this||Object.defineProperty(this,n,{get(){return this.levels_[n]}}),this.levels_.push(i),this.trigger({qualityLevel:i,type:"addqualitylevel"}),i}removeQualityLevel(e){let i=null;for(let n=0,r=this.length;nn&&this.selectedIndex_--;break}return i&&this.trigger({qualityLevel:e,type:"removequalitylevel"}),i}getQualityLevelById(e){for(let i=0,n=this.length;in,t.qualityLevels.VERSION=zT,n},HT=function(t){return tP(this,M.obj.merge({},t))};M.registerPlugin("qualityLevels",HT);HT.VERSION=zT;/*! @name @videojs/http-streaming @version 3.7.0 @license Apache-2.0 */const Ft=CA,Ou=(t,e)=>e&&e.responseURL&&t!==e.responseURL?e.responseURL:t,si=t=>M.log.debug?M.log.debug.bind(M,"VHS:",`${t} >`):function(){};function ve(...t){const e=M.obj||M;return(e.merge||e.mergeOptions).apply(e,t)}function ot(...t){const e=M.time||M;return(e.createTimeRanges||e.createTimeRanges).apply(e,t)}function iP(t){let e="";for(let i=0;i ${r})`}return e||"empty"}const Bn=1/30,wi=Bn*3,qT=function(t,e){const i=[];let n;if(t&&t.length)for(n=0;n=e})},xl=function(t,e){return qT(t,function(i){return i-Bn>=e})},nP=function(t){if(t.length<2)return ot();const e=[];for(let i=1;i{const e=[];if(!t||!t.length)return"";for(let i=0;i "+t.end(i));return e.join(", ")},sP=function(t,e,i=1){return((t.length?t.end(t.length-1):0)-e)/i},nr=t=>{const e=[];for(let i=0;is)){if(e>r&&e<=s){i+=s-e;continue}i+=s-r}}return i},cm=(t,e)=>{if(!e.preload)return e.duration;let i=0;return(e.parts||[]).forEach(function(n){i+=n.duration}),(e.preloadHints||[]).forEach(function(n){n.type==="PART"&&(i+=t.partTargetDuration)}),i},af=t=>(t.segments||[]).reduce((e,i,n)=>(i.parts?i.parts.forEach(function(r,s){e.push({duration:r.duration,segmentIndex:n,partIndex:s,part:r,segment:i})}):e.push({duration:i.duration,segmentIndex:n,partIndex:null,segment:i,part:null}),e),[]),GT=t=>{const e=t.segments&&t.segments.length&&t.segments[t.segments.length-1];return e&&e.parts||[]},XT=({preloadSegment:t})=>{if(!t)return;const{parts:e,preloadHints:i}=t;let n=(i||[]).reduce((r,s)=>r+(s.type==="PART"?1:0),0);return n+=e&&e.length?e.length:0,n},KT=(t,e)=>{if(e.endList)return 0;if(t&&t.suggestedPresentationDelay)return t.suggestedPresentationDelay;const i=GT(e).length>0;return i&&e.serverControl&&e.serverControl.partHoldBack?e.serverControl.partHoldBack:i&&e.partTargetDuration?e.partTargetDuration*3:e.serverControl&&e.serverControl.holdBack?e.serverControl.holdBack:e.targetDuration?e.targetDuration*3:0},oP=function(t,e){let i=0,n=e-t.mediaSequence,r=t.segments[n];if(r){if(typeof r.start<"u")return{result:r.start,precise:!0};if(typeof r.end<"u")return{result:r.end-r.duration,precise:!0}}for(;n--;){if(r=t.segments[n],typeof r.end<"u")return{result:i+r.end,precise:!0};if(i+=cm(t,r),typeof r.start<"u")return{result:i+r.start,precise:!0}}return{result:i,precise:!1}},lP=function(t,e){let i=0,n,r=e-t.mediaSequence;for(;r"u"&&(e=t.mediaSequence+t.segments.length),e"u"){if(t.totalDuration)return t.totalDuration;if(!t.endList)return A.Infinity}return QT(t,e,i)},Ba=function({defaultDuration:t,durationList:e,startIndex:i,endIndex:n}){let r=0;if(i>n&&([i,n]=[n,i]),i<0){for(let s=i;s0)for(let c=l-1;c>=0;c--){const p=o[c];if(a+=p.duration,s){if(a<0)continue}else if(a+Bn<=0)continue;return{partIndex:p.partIndex,segmentIndex:p.segmentIndex,startTime:r-Ba({defaultDuration:t.targetDuration,durationList:o,startIndex:l,endIndex:c})}}return{partIndex:o[0]&&o[0].partIndex||null,segmentIndex:o[0]&&o[0].segmentIndex||0,startTime:e}}if(l<0){for(let c=l;c<0;c++)if(a-=t.targetDuration,a<0)return{partIndex:o[0]&&o[0].partIndex||null,segmentIndex:o[0]&&o[0].segmentIndex||0,startTime:e};l=0}for(let c=l;c0)continue}else if(a-Bn>=0)continue;return{partIndex:p.partIndex,segmentIndex:p.segmentIndex,startTime:r+Ba({defaultDuration:t.targetDuration,durationList:o,startIndex:l,endIndex:c})}}return{segmentIndex:o[o.length-1].segmentIndex,partIndex:o[o.length-1].partIndex,startTime:e}},ZT=function(t){return t.excludeUntil&&t.excludeUntil>Date.now()},dm=function(t){return t.excludeUntil&&t.excludeUntil===1/0},Ac=function(t){const e=ZT(t);return!t.disabled&&!e},dP=function(t){return t.disabled},hP=function(t){for(let e=0;e{if(t.playlists.length===1)return!0;const i=e.attributes.BANDWIDTH||Number.MAX_VALUE;return t.playlists.filter(n=>Ac(n)?(n.attributes.BANDWIDTH||0)!t&&!e||!t&&e||t&&!e?!1:!!(t===e||t.id&&e.id&&t.id===e.id||t.resolvedUri&&e.resolvedUri&&t.resolvedUri===e.resolvedUri||t.uri&&e.uri&&t.uri===e.uri),Ny=function(t,e){const i=t&&t.mediaGroups&&t.mediaGroups.AUDIO||{};let n=!1;for(const r in i){for(const s in i[r])if(n=e(i[r][s]),n)break;if(n)break}return!!n},Do=t=>{if(!t||!t.playlists||!t.playlists.length)return Ny(t,i=>i.playlists&&i.playlists.length||i.uri);for(let e=0;ej1(s))||Ny(t,s=>hm(i,s))))return!1}return!0};var Dt={liveEdgeDelay:KT,duration:YT,seekable:uP,getMediaInfoForTime:cP,isEnabled:Ac,isDisabled:dP,isExcluded:ZT,isIncompatible:dm,playlistEnd:JT,isAes:hP,hasAttribute:ex,estimateSegmentRequestTime:fP,isLowestEnabledRendition:of,isAudioOnly:Do,playlistMatch:hm,segmentDurationWithParts:cm};const{log:tx}=M,fm=(t,e)=>`${t}-${e}`,pP=(t,e,i)=>`placeholder-uri-${t}-${e}-${i}`,mP=({onwarn:t,oninfo:e,manifestString:i,customTagParsers:n=[],customTagMappers:r=[],llhls:s})=>{const a=new LA;t&&a.on("warn",t),e&&a.on("info",e),n.forEach(c=>a.addParser(c)),r.forEach(c=>a.addTagMapper(c)),a.push(i),a.end();const o=a.manifest;if(s||(["preloadSegment","skip","serverControl","renditionReports","partInf","partTargetDuration"].forEach(function(c){o.hasOwnProperty(c)&&delete o[c]}),o.segments&&o.segments.forEach(function(c){["parts","preloadHints"].forEach(function(p){c.hasOwnProperty(p)&&delete c[p]})})),!o.targetDuration){let c=10;o.segments&&o.segments.length&&(c=o.segments.reduce((p,g)=>Math.max(p,g.duration),0)),t&&t(`manifest has no targetDuration defaulting to ${c}`),o.targetDuration=c}const l=GT(o);if(l.length&&!o.partTargetDuration){const c=l.reduce((p,g)=>Math.max(p,g.duration),0);t&&(t(`manifest has no partTargetDuration defaulting to ${c}`),tx.error("LL-HLS manifest has parts but lacks required #EXT-X-PART-INF:PART-TARGET value. See https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis-09#section-4.4.3.7. Playback is not guaranteed.")),o.partTargetDuration=c}return o},Us=(t,e)=>{t.mediaGroups&&["AUDIO","SUBTITLES"].forEach(i=>{if(t.mediaGroups[i])for(const n in t.mediaGroups[i])for(const r in t.mediaGroups[i][n]){const s=t.mediaGroups[i][n][r];e(s,i,n,r)}})},ix=({playlist:t,uri:e,id:i})=>{t.id=i,t.playlistErrors_=0,e&&(t.uri=e),t.attributes=t.attributes||{}},gP=t=>{let e=t.playlists.length;for(;e--;){const i=t.playlists[e];ix({playlist:i,id:fm(e,i.uri)}),i.resolvedUri=Ft(t.uri,i.uri),t.playlists[i.id]=i,t.playlists[i.uri]=i,i.attributes.BANDWIDTH||tx.warn("Invalid playlist STREAM-INF detected. Missing BANDWIDTH attribute.")}},yP=t=>{Us(t,e=>{e.uri&&(e.resolvedUri=Ft(t.uri,e.uri))})},vP=(t,e)=>{const i=fm(0,e),n={mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:A.location.href,resolvedUri:A.location.href,playlists:[{uri:e,id:i,resolvedUri:e,attributes:{}}]};return n.playlists[i]=n.playlists[0],n.playlists[e]=n.playlists[0],n},nx=(t,e,i=pP)=>{t.uri=e;for(let r=0;r{if(!r.playlists||!r.playlists.length){if(n&&s==="AUDIO"&&!r.uri)for(let l=0;l(r.set(s.id,s),r),new Map)}processDateRange(e){this.pendingDateRanges_.delete(e.id),this.processedDateRanges_.set(e.id,e)}getDateRangesToProcess(){if(this.offset_===null)return[];const e={},i=[];this.pendingDateRanges_.forEach((n,r)=>{if(!this.processedDateRanges_.has(r)&&(n.startTime=n.startDate.getTime()/1e3-this.offset_,n.processDateRange=()=>this.processDateRange(n),i.push(n),!!n.class))if(e[n.class]){const s=e[n.class].push(n);n.classListIndex=s-1}else e[n.class]=[n],n.classListIndex=0});for(const n of i){const r=e[n.class]||[];n.endDate?n.endTime=n.endDate.getTime()/1e3-this.offset_:n.endOnNext&&r[n.classListIndex+1]?n.endTime=r[n.classListIndex+1].startTime:n.duration?n.endTime=n.startTime+n.duration:n.plannedDuration?n.endTime=n.startTime+n.plannedDuration:n.endTime=n.startTime}return i}trimProcessedDateRanges_(e){new Map(this.processedDateRanges_).forEach((n,r)=>{n.startDate.getTime(){if(e.endList||!e.serverControl)return t;const i={};if(e.serverControl.canBlockReload){const{preloadSegment:n}=e;let r=e.mediaSequence+e.segments.length;if(n){const s=n.parts||[],a=XT(e)-1;a>-1&&a!==s.length-1&&(i._HLS_part=a),(a>-1||s.length)&&r--}i._HLS_msn=r}if(e.serverControl&&e.serverControl.canSkipUntil&&(i._HLS_skip=e.serverControl.canSkipDateranges?"v2":"YES"),Object.keys(i).length){const n=new A.URL(t);["_HLS_skip","_HLS_msn","_HLS_part"].forEach(function(r){i.hasOwnProperty(r)&&n.searchParams.set(r,i[r])}),t=n.toString()}return t},xP=(t,e)=>{if(!t)return e;const i=ve(t,e);if(t.preloadHints&&!e.preloadHints&&delete i.preloadHints,t.parts&&!e.parts)delete i.parts;else if(t.parts&&e.parts)for(let n=0;n{const n=t.slice(),r=e.slice();i=i||0;const s=[];let a;for(let o=0;o{!t.resolvedUri&&t.uri&&(t.resolvedUri=Ft(e,t.uri)),t.key&&!t.key.resolvedUri&&(t.key.resolvedUri=Ft(e,t.key.uri)),t.map&&!t.map.resolvedUri&&(t.map.resolvedUri=Ft(e,t.map.uri)),t.map&&t.map.key&&!t.map.key.resolvedUri&&(t.map.key.resolvedUri=Ft(e,t.map.key.uri)),t.parts&&t.parts.length&&t.parts.forEach(i=>{i.resolvedUri||(i.resolvedUri=Ft(e,i.uri))}),t.preloadHints&&t.preloadHints.length&&t.preloadHints.forEach(i=>{i.resolvedUri||(i.resolvedUri=Ft(e,i.uri))})},sx=function(t){const e=t.segments||[],i=t.preloadSegment;if(i&&i.parts&&i.parts.length){if(i.preloadHints){for(let n=0;nt===e||t.segments&&e.segments&&t.segments.length===e.segments.length&&t.endList===e.endList&&t.mediaSequence===e.mediaSequence&&t.preloadSegment===e.preloadSegment,lf=(t,e,i=ax)=>{const n=ve(t,{}),r=n.playlists[e.id];if(!r||i(r,e))return null;e.segments=sx(e);const s=ve(r,e);if(s.preloadSegment&&!e.preloadSegment&&delete s.preloadSegment,r.segments){if(e.skip){e.segments=e.segments||[];for(let a=0;a{rx(a,s.resolvedUri)});for(let a=0;a{if(a.playlists)for(let p=0;p{const i=t.segments||[],n=i[i.length-1],r=n&&n.parts&&n.parts[n.parts.length-1],s=r&&r.duration||n&&n.duration;return e&&s?s*1e3:(t.partTargetDuration||t.targetDuration||10)*500};class Qr extends _P{constructor(e,i,n={}){if(super(),!e)throw new Error("A non-empty playlist URL or object is required");this.logger_=si("PlaylistLoader");const{withCredentials:r=!1}=n;this.src=e,this.vhs_=i,this.withCredentials=r,this.addDateRangesToTextTrack_=n.addDateRangesToTextTrack;const s=i.options_;this.customTagParsers=s&&s.customTagParsers||[],this.customTagMappers=s&&s.customTagMappers||[],this.llhls=s&&s.llhls,this.dateRangesStorage_=new Ry,this.state="HAVE_NOTHING",this.handleMediaupdatetimeout_=this.handleMediaupdatetimeout_.bind(this),this.on("mediaupdatetimeout",this.handleMediaupdatetimeout_),this.on("loadedplaylist",this.handleLoadedPlaylist_.bind(this))}handleLoadedPlaylist_(){const e=this.media();if(!e)return;this.dateRangesStorage_.setOffset(e.segments),this.dateRangesStorage_.setPendingDateRanges(e.dateRanges);const i=this.dateRangesStorage_.getDateRangesToProcess();!i.length||!this.addDateRangesToTextTrack_||this.addDateRangesToTextTrack_(i)}handleMediaupdatetimeout_(){if(this.state!=="HAVE_METADATA")return;const e=this.media();let i=Ft(this.main.uri,e.uri);this.llhls&&(i=TP(i,e)),this.state="HAVE_CURRENT_METADATA",this.request=this.vhs_.xhr({uri:i,withCredentials:this.withCredentials},(n,r)=>{if(this.request){if(n)return this.playlistRequestError(this.request,this.media(),"HAVE_METADATA");this.haveMetadata({playlistString:this.request.responseText,url:this.media().uri,id:this.media().id})}})}playlistRequestError(e,i,n){const{uri:r,id:s}=i;this.request=null,n&&(this.state=n),this.error={playlist:this.main.playlists[s],status:e.status,message:`HLS playlist request error at URL: ${r}.`,responseText:e.responseText,code:e.status>=500?4:2},this.trigger("error")}parseManifest_({url:e,manifestString:i}){return mP({onwarn:({message:n})=>this.logger_(`m3u8-parser warn for ${e}: ${n}`),oninfo:({message:n})=>this.logger_(`m3u8-parser info for ${e}: ${n}`),manifestString:i,customTagParsers:this.customTagParsers,customTagMappers:this.customTagMappers,llhls:this.llhls})}haveMetadata({playlistString:e,playlistObject:i,url:n,id:r}){this.request=null,this.state="HAVE_METADATA";const s=i||this.parseManifest_({url:n,manifestString:e});s.lastRequest=Date.now(),ix({playlist:s,uri:n,id:r});const a=lf(this.main,s);this.targetDuration=s.partTargetDuration||s.targetDuration,this.pendingMedia_=null,a?(this.main=a,this.media_=this.main.playlists[r]):this.trigger("playlistunchanged"),this.updateMediaUpdateTimeout_(uf(this.media(),!!a)),this.trigger("loadedplaylist")}dispose(){this.trigger("dispose"),this.stopRequest(),A.clearTimeout(this.mediaUpdateTimeout),A.clearTimeout(this.finalRenditionTimeout),this.dateRangesStorage_=new Ry,this.off()}stopRequest(){if(this.request){const e=this.request;this.request=null,e.onreadystatechange=null,e.abort()}}media(e,i){if(!e)return this.media_;if(this.state==="HAVE_NOTHING")throw new Error("Cannot switch media playlist from "+this.state);if(typeof e=="string"){if(!this.main.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.main.playlists[e]}if(A.clearTimeout(this.finalRenditionTimeout),i){const a=(e.partTargetDuration||e.targetDuration)/2*1e3||5e3;this.finalRenditionTimeout=A.setTimeout(this.media.bind(this,e,!1),a);return}const n=this.state,r=!this.media_||e.id!==this.media_.id,s=this.main.playlists[e.id];if(s&&s.endList||e.endList&&e.segments.length){this.request&&(this.request.onreadystatechange=null,this.request.abort(),this.request=null),this.state="HAVE_METADATA",this.media_=e,r&&(this.trigger("mediachanging"),n==="HAVE_MAIN_MANIFEST"?this.trigger("loadedmetadata"):this.trigger("mediachange"));return}if(this.updateMediaUpdateTimeout_(uf(e,!0)),!!r){if(this.state="SWITCHING_MEDIA",this.request){if(e.resolvedUri===this.request.url)return;this.request.onreadystatechange=null,this.request.abort(),this.request=null}this.media_&&this.trigger("mediachanging"),this.pendingMedia_=e,this.request=this.vhs_.xhr({uri:e.resolvedUri,withCredentials:this.withCredentials},(a,o)=>{if(this.request){if(e.lastRequest=Date.now(),e.resolvedUri=Ou(e.resolvedUri,o),a)return this.playlistRequestError(this.request,e,n);this.haveMetadata({playlistString:o.responseText,url:e.uri,id:e.id}),n==="HAVE_MAIN_MANIFEST"?this.trigger("loadedmetadata"):this.trigger("mediachange")}})}}pause(){this.mediaUpdateTimeout&&(A.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null),this.stopRequest(),this.state==="HAVE_NOTHING"&&(this.started=!1),this.state==="SWITCHING_MEDIA"?this.media_?this.state="HAVE_METADATA":this.state="HAVE_MAIN_MANIFEST":this.state==="HAVE_CURRENT_METADATA"&&(this.state="HAVE_METADATA")}load(e){this.mediaUpdateTimeout&&(A.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null);const i=this.media();if(e){const n=i?(i.partTargetDuration||i.targetDuration)/2*1e3:5e3;this.mediaUpdateTimeout=A.setTimeout(()=>{this.mediaUpdateTimeout=null,this.load()},n);return}if(!this.started){this.start();return}i&&!i.endList?this.trigger("mediaupdatetimeout"):this.trigger("loadedplaylist")}updateMediaUpdateTimeout_(e){this.mediaUpdateTimeout&&(A.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null),!(!this.media()||this.media().endList)&&(this.mediaUpdateTimeout=A.setTimeout(()=>{this.mediaUpdateTimeout=null,this.trigger("mediaupdatetimeout"),this.updateMediaUpdateTimeout_(e)},e))}start(){if(this.started=!0,typeof this.src=="object"){this.src.uri||(this.src.uri=A.location.href),this.src.resolvedUri=this.src.uri,setTimeout(()=>{this.setupInitialPlaylist(this.src)},0);return}this.request=this.vhs_.xhr({uri:this.src,withCredentials:this.withCredentials},(e,i)=>{if(!this.request)return;if(this.request=null,e)return this.error={status:i.status,message:`HLS playlist request error at URL: ${this.src}.`,responseText:i.responseText,code:2},this.state==="HAVE_NOTHING"&&(this.started=!1),this.trigger("error");this.src=Ou(this.src,i);const n=this.parseManifest_({manifestString:i.responseText,url:this.src});this.setupInitialPlaylist(n)})}srcUri(){return typeof this.src=="string"?this.src:this.src.uri}setupInitialPlaylist(e){if(this.state="HAVE_MAIN_MANIFEST",e.playlists){this.main=e,nx(this.main,this.srcUri()),e.playlists.forEach(n=>{n.segments=sx(n),n.segments.forEach(r=>{rx(r,n.resolvedUri)})}),this.trigger("loadedplaylist"),this.request||this.media(this.main.playlists[0]);return}const i=this.srcUri()||A.location.href;this.main=vP(e,i),this.haveMetadata({playlistObject:e,url:i,id:this.main.playlists[0].id}),this.trigger("loadedmetadata")}}const{xhr:EP}=M,cf=function(t,e,i,n){const r=t.responseType==="arraybuffer"?t.response:t.responseText;!e&&r&&(t.responseTime=Date.now(),t.roundTripTime=t.responseTime-t.requestTime,t.bytesReceived=r.byteLength||r.length,t.bandwidth||(t.bandwidth=Math.floor(t.bytesReceived/t.roundTripTime*8*1e3))),i.headers&&(t.responseHeaders=i.headers),e&&e.code==="ETIMEDOUT"&&(t.timedout=!0),!e&&!t.aborted&&i.statusCode!==200&&i.statusCode!==206&&i.statusCode!==0&&(e=new Error("XHR Failed with a response of: "+(t&&(r||t.responseText)))),n(e,t)},bP=(t,e)=>{if(!t||!t.size)return;let i=e;return t.forEach(n=>{i=n(i)}),i},CP=(t,e,i,n)=>{!t||!t.size||t.forEach(r=>{r(e,i,n)})},ox=function(){const t=function e(i,n){i=ve({timeout:45e3},i);const r=e.beforeRequest||M.Vhs.xhr.beforeRequest,s=e._requestCallbackSet||M.Vhs.xhr._requestCallbackSet||new Set,a=e._responseCallbackSet||M.Vhs.xhr._responseCallbackSet;r&&typeof r=="function"&&(M.log.warn("beforeRequest is deprecated, use onRequest instead."),s.add(r));const o=M.Vhs.xhr.original===!0?EP:M.Vhs.xhr,l=bP(s,i);s.delete(r);const c=o(l||i,function(g,v){return CP(a,c,g,v),cf(c,g,v,n)}),p=c.abort;return c.abort=function(){return c.aborted=!0,p.apply(c,arguments)},c.uri=i.uri,c.requestTime=Date.now(),c};return t.original=!0,t},wP=function(t){let e;const i=t.offset;return typeof t.offset=="bigint"||typeof t.length=="bigint"?e=A.BigInt(t.offset)+A.BigInt(t.length)-A.BigInt(1):e=t.offset+t.length-1,"bytes="+i+"-"+e},df=function(t){const e={};return t.byterange&&(e.Range=wP(t.byterange)),e},DP=function(t,e){return t.start(e)+"-"+t.end(e)},AP=function(t,e){const i=t.toString(16);return"00".substring(0,2-i.length)+i+(e%2?" ":"")},kP=function(t){return t>=32&&t<126?String.fromCharCode(t):"."},lx=function(t){const e={};return Object.keys(t).forEach(i=>{const n=t[i];V1(n)?e[i]={bytes:n.buffer,byteOffset:n.byteOffset,byteLength:n.byteLength}:e[i]=n}),e},Nu=function(t){const e=t.byterange||{length:1/0,offset:0};return[e.length,e.offset,t.resolvedUri].join(",")},ux=function(t){return t.resolvedUri},cx=t=>{const e=Array.prototype.slice.call(t),i=16;let n="",r,s;for(let a=0;acx(t),IP=t=>{let e="",i;for(i=0;i{if(!e.dateTimeObject)return null;const i=e.videoTimingInfo.transmuxerPrependedSeconds,r=e.videoTimingInfo.transmuxedPresentationStart+i,s=t-r;return new Date(e.dateTimeObject.getTime()+s*1e3)},NP=t=>t.transmuxedPresentationEnd-t.transmuxedPresentationStart-t.transmuxerPrependedSeconds,RP=(t,e)=>{let i;try{i=new Date(t)}catch{return null}if(!e||!e.segments||e.segments.length===0)return null;let n=e.segments[0];if(io?null:(i>new Date(s)&&(n=r),{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:Dt.duration(e,e.mediaSequence+e.segments.indexOf(n)),type:n.videoTimingInfo?"accurate":"estimate"})},MP=(t,e)=>{if(!e||!e.segments||e.segments.length===0)return null;let i=0,n;for(let s=0;si){if(t>i+r.duration*dx)return null;n=r}return{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:i-n.duration,type:n.videoTimingInfo?"accurate":"estimate"}},BP=(t,e)=>{let i,n;try{i=new Date(t),n=new Date(e)}catch{}const r=i.getTime();return(n.getTime()-r)/1e3},FP=t=>{if(!t.segments||t.segments.length===0)return!1;for(let e=0;e{if(!i)throw new Error("getProgramTime: callback must be provided");if(!t||e===void 0)return i({message:"getProgramTime: playlist and time must be provided"});const n=MP(e,t);if(!n)return i({message:"valid programTime was not found"});if(n.type==="estimate")return i({message:"Accurate programTime could not be determined. Please seek to e.seekTime and try again",seekTime:n.estimatedStart});const r={mediaSeconds:e},s=OP(e,n.segment);return s&&(r.programDateTime=s.toISOString()),i(null,r)},hx=({programTime:t,playlist:e,retryCount:i=2,seekTo:n,pauseAfterSeek:r=!0,tech:s,callback:a})=>{if(!a)throw new Error("seekToProgramTime: callback must be provided");if(typeof t>"u"||!e||!n)return a({message:"seekToProgramTime: programTime, seekTo and playlist must be provided"});if(!e.endList&&!s.hasStarted_)return a({message:"player must be playing a live stream to start buffering"});if(!FP(e))return a({message:"programDateTime tags must be provided in the manifest "+e.resolvedUri});const o=RP(t,e);if(!o)return a({message:`${t} was not found in the stream`});const l=o.segment,c=BP(l.dateTimeObject,t);if(o.type==="estimate"){if(i===0)return a({message:`${t} is not buffered yet. Try again`});n(o.estimatedStart+c),s.one("seeked",()=>{hx({programTime:t,playlist:e,retryCount:i-1,seekTo:n,pauseAfterSeek:r,tech:s,callback:a})});return}const p=l.start+c,g=()=>a(null,s.currentTime());s.one("seeked",g),r&&s.pause(),n(p)},Hd=(t,e)=>{if(t.readyState===4)return e()},jP=(t,e,i)=>{let n=[],r,s=!1;const a=function(p,g,v,S){return g.abort(),s=!0,i(p,g,v,S)},o=function(p,g){if(s)return;if(p)return a(p,g,"",n);const v=g.responseText.substring(n&&n.byteLength||0,g.responseText.length);if(n=HA(n,z1(v,!0)),r=r||xa(n),n.length<10||r&&n.lengtha(p,g,"",n));const S=Lp(n);return S==="ts"&&n.length<188?Hd(g,()=>a(p,g,"",n)):!S&&n.length<376?Hd(g,()=>a(p,g,"",n)):a(null,g,S,n)},c=e({uri:t,beforeSend(p){p.overrideMimeType("text/plain; charset=x-user-defined"),p.addEventListener("progress",function({total:g,loaded:v}){return cf(p,null,{statusCode:p.status},o)})}},function(p,g){return cf(c,p,g,o)});return c},{EventTarget:$P}=M,My=function(t,e){if(!ax(t,e)||t.sidx&&e.sidx&&(t.sidx.offset!==e.sidx.offset||t.sidx.length!==e.sidx.length))return!1;if(!t.sidx&&e.sidx||t.sidx&&!e.sidx||t.segments&&!e.segments||!t.segments&&e.segments)return!1;if(!t.segments&&!e.segments)return!0;for(let i=0;i{const r=n.attributes.NAME||i;return`placeholder-uri-${t}-${e}-${r}`},zP=({mainXml:t,srcUrl:e,clientOffset:i,sidxMapping:n,previousManifest:r})=>{const s=d3(t,{manifestUri:e,clientOffset:i,sidxMapping:n,previousManifest:r});return nx(s,e,VP),s},HP=(t,e)=>{Us(t,(i,n,r,s)=>{s in e.mediaGroups[n][r]||delete t.mediaGroups[n][r][s]})},qP=(t,e,i)=>{let n=!0,r=ve(t,{duration:e.duration,minimumUpdatePeriod:e.minimumUpdatePeriod,timelineStarts:e.timelineStarts});for(let s=0;s{if(s.playlists&&s.playlists.length){const c=s.playlists[0].id,p=lf(r,s.playlists[0],My);p&&(r=p,l in r.mediaGroups[a][o]||(r.mediaGroups[a][o][l]=s),r.mediaGroups[a][o][l].playlists[0]=r.playlists[c],n=!1)}}),HP(r,e),e.minimumUpdatePeriod!==t.minimumUpdatePeriod&&(n=!1),n?null:r},WP=(t,e)=>(!t.map&&!e.map||!!(t.map&&e.map&&t.map.byterange.offset===e.map.byterange.offset&&t.map.byterange.length===e.map.byterange.length))&&t.uri===e.uri&&t.byterange.offset===e.byterange.offset&&t.byterange.length===e.byterange.length,By=(t,e)=>{const i={};for(const n in t){const s=t[n].sidx;if(s){const a=cc(s);if(!e[a])break;const o=e[a].sidxInfo;WP(o,s)&&(i[a]=e[a])}}return i},GP=(t,e)=>{let n=By(t.playlists,e);return Us(t,(r,s,a,o)=>{if(r.playlists&&r.playlists.length){const l=r.playlists;n=ve(n,By(l,e))}}),n};class hf extends $P{constructor(e,i,n={},r){super(),this.mainPlaylistLoader_=r||this,r||(this.isMain_=!0);const{withCredentials:s=!1}=n;if(this.vhs_=i,this.withCredentials=s,this.addMetadataToTextTrack=n.addMetadataToTextTrack,!e)throw new Error("A non-empty playlist URL or object is required");this.on("minimumUpdatePeriod",()=>{this.refreshXml_()}),this.on("mediaupdatetimeout",()=>{this.media().attributes.serviceLocation||this.refreshMedia_(this.media().id)}),this.state="HAVE_NOTHING",this.loadedPlaylists_={},this.logger_=si("DashPlaylistLoader"),this.isMain_?(this.mainPlaylistLoader_.srcUrl=e,this.mainPlaylistLoader_.sidxMapping_={}):this.childPlaylist_=e}requestErrored_(e,i,n){if(!this.request)return!0;if(this.request=null,e)return this.error=typeof e=="object"&&!(e instanceof Error)?e:{status:i.status,message:"DASH request error at URL: "+i.uri,response:i.response,code:2},n&&(this.state=n),this.trigger("error"),!0}addSidxSegments_(e,i,n){const r=e.sidx&&cc(e.sidx);if(!e.sidx||!r||this.mainPlaylistLoader_.sidxMapping_[r]){this.mediaRequest_=A.setTimeout(()=>n(!1),0);return}const s=Ou(e.sidx.resolvedUri),a=(o,l)=>{if(this.requestErrored_(o,l,i))return;const c=this.mainPlaylistLoader_.sidxMapping_;let p;try{p=y3(J(l.response).subarray(8))}catch(g){this.requestErrored_(g,l,i);return}return c[r]={sidxInfo:e.sidx,sidx:p},kp(e,p,e.sidx.resolvedUri),n(!0)};this.request=jP(s,this.vhs_.xhr,(o,l,c,p)=>{if(o)return a(o,l);if(!c||c!=="mp4")return a({status:l.status,message:`Unsupported ${c||"unknown"} container type for sidx segment at URL: ${s}`,response:"",playlist:e,internal:!0,playlistExclusionDuration:1/0,code:2},l);const{offset:g,length:v}=e.sidx.byterange;if(p.length>=v+g)return a(o,{response:p.subarray(g,g+v),status:l.status,uri:l.uri});this.request=this.vhs_.xhr({uri:s,responseType:"arraybuffer",headers:df({byterange:e.sidx.byterange})},a)})}dispose(){this.trigger("dispose"),this.stopRequest(),this.loadedPlaylists_={},A.clearTimeout(this.minimumUpdatePeriodTimeout_),A.clearTimeout(this.mediaRequest_),A.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null,this.mediaRequest_=null,this.minimumUpdatePeriodTimeout_=null,this.mainPlaylistLoader_.createMupOnMedia_&&(this.off("loadedmetadata",this.mainPlaylistLoader_.createMupOnMedia_),this.mainPlaylistLoader_.createMupOnMedia_=null),this.off()}hasPendingRequest(){return this.request||this.mediaRequest_}stopRequest(){if(this.request){const e=this.request;this.request=null,e.onreadystatechange=null,e.abort()}}media(e){if(!e)return this.media_;if(this.state==="HAVE_NOTHING")throw new Error("Cannot switch media playlist from "+this.state);const i=this.state;if(typeof e=="string"){if(!this.mainPlaylistLoader_.main.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.mainPlaylistLoader_.main.playlists[e]}const n=!this.media_||e.id!==this.media_.id;if(n&&this.loadedPlaylists_[e.id]&&this.loadedPlaylists_[e.id].endList){this.state="HAVE_METADATA",this.media_=e,n&&(this.trigger("mediachanging"),this.trigger("mediachange"));return}n&&(this.media_&&this.trigger("mediachanging"),this.addSidxSegments_(e,i,r=>{this.haveMetadata({startingState:i,playlist:e})}))}haveMetadata({startingState:e,playlist:i}){this.state="HAVE_METADATA",this.loadedPlaylists_[i.id]=i,this.mediaRequest_=null,this.refreshMedia_(i.id),e==="HAVE_MAIN_MANIFEST"?this.trigger("loadedmetadata"):this.trigger("mediachange")}pause(){this.mainPlaylistLoader_.createMupOnMedia_&&(this.off("loadedmetadata",this.mainPlaylistLoader_.createMupOnMedia_),this.mainPlaylistLoader_.createMupOnMedia_=null),this.stopRequest(),A.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null,this.isMain_&&(A.clearTimeout(this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_),this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_=null),this.state==="HAVE_NOTHING"&&(this.started=!1)}load(e){A.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null;const i=this.media();if(e){const n=i?i.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=A.setTimeout(()=>this.load(),n);return}if(!this.started){this.start();return}i&&!i.endList?(this.isMain_&&!this.minimumUpdatePeriodTimeout_&&(this.trigger("minimumUpdatePeriod"),this.updateMinimumUpdatePeriodTimeout_()),this.trigger("mediaupdatetimeout")):this.trigger("loadedplaylist")}start(){if(this.started=!0,!this.isMain_){this.mediaRequest_=A.setTimeout(()=>this.haveMain_(),0);return}this.requestMain_((e,i)=>{this.haveMain_(),!this.hasPendingRequest()&&!this.media_&&this.media(this.mainPlaylistLoader_.main.playlists[0])})}requestMain_(e){this.request=this.vhs_.xhr({uri:this.mainPlaylistLoader_.srcUrl,withCredentials:this.withCredentials},(i,n)=>{if(this.requestErrored_(i,n)){this.state==="HAVE_NOTHING"&&(this.started=!1);return}const r=n.responseText!==this.mainPlaylistLoader_.mainXml_;if(this.mainPlaylistLoader_.mainXml_=n.responseText,n.responseHeaders&&n.responseHeaders.date?this.mainLoaded_=Date.parse(n.responseHeaders.date):this.mainLoaded_=Date.now(),this.mainPlaylistLoader_.srcUrl=Ou(this.mainPlaylistLoader_.srcUrl,n),r){this.handleMain_(),this.syncClientServerClock_(()=>e(n,r));return}return e(n,r)})}syncClientServerClock_(e){const i=h3(this.mainPlaylistLoader_.mainXml_);if(i===null)return this.mainPlaylistLoader_.clientOffset_=this.mainLoaded_-Date.now(),e();if(i.method==="DIRECT")return this.mainPlaylistLoader_.clientOffset_=i.value-Date.now(),e();this.request=this.vhs_.xhr({uri:Ft(this.mainPlaylistLoader_.srcUrl,i.value),method:i.method,withCredentials:this.withCredentials},(n,r)=>{if(!this.request)return;if(n)return this.mainPlaylistLoader_.clientOffset_=this.mainLoaded_-Date.now(),e();let s;i.method==="HEAD"?!r.responseHeaders||!r.responseHeaders.date?s=this.mainLoaded_:s=Date.parse(r.responseHeaders.date):s=Date.parse(r.responseText),this.mainPlaylistLoader_.clientOffset_=s-Date.now(),e()})}haveMain_(){this.state="HAVE_MAIN_MANIFEST",this.isMain_?this.trigger("loadedplaylist"):this.media_||this.media(this.childPlaylist_)}handleMain_(){this.mediaRequest_=null;const e=this.mainPlaylistLoader_.main;let i=zP({mainXml:this.mainPlaylistLoader_.mainXml_,srcUrl:this.mainPlaylistLoader_.srcUrl,clientOffset:this.mainPlaylistLoader_.clientOffset_,sidxMapping:this.mainPlaylistLoader_.sidxMapping_,previousManifest:e});e&&(i=qP(e,i,this.mainPlaylistLoader_.sidxMapping_)),this.mainPlaylistLoader_.main=i||e;const n=this.mainPlaylistLoader_.main.locations&&this.mainPlaylistLoader_.main.locations[0];return n&&n!==this.mainPlaylistLoader_.srcUrl&&(this.mainPlaylistLoader_.srcUrl=n),(!e||i&&i.minimumUpdatePeriod!==e.minimumUpdatePeriod)&&this.updateMinimumUpdatePeriodTimeout_(),this.addEventStreamToMetadataTrack_(i),!!i}updateMinimumUpdatePeriodTimeout_(){const e=this.mainPlaylistLoader_;e.createMupOnMedia_&&(e.off("loadedmetadata",e.createMupOnMedia_),e.createMupOnMedia_=null),e.minimumUpdatePeriodTimeout_&&(A.clearTimeout(e.minimumUpdatePeriodTimeout_),e.minimumUpdatePeriodTimeout_=null);let i=e.main&&e.main.minimumUpdatePeriod;if(i===0&&(e.media()?i=e.media().targetDuration*1e3:(e.createMupOnMedia_=e.updateMinimumUpdatePeriodTimeout_,e.one("loadedmetadata",e.createMupOnMedia_))),typeof i!="number"||i<=0){i<0&&this.logger_(`found invalid minimumUpdatePeriod of ${i}, not setting a timeout`);return}this.createMUPTimeout_(i)}createMUPTimeout_(e){const i=this.mainPlaylistLoader_;i.minimumUpdatePeriodTimeout_=A.setTimeout(()=>{i.minimumUpdatePeriodTimeout_=null,i.trigger("minimumUpdatePeriod"),i.createMUPTimeout_(e)},e)}refreshXml_(){this.requestMain_((e,i)=>{i&&(this.media_&&(this.media_=this.mainPlaylistLoader_.main.playlists[this.media_.id]),this.mainPlaylistLoader_.sidxMapping_=GP(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.sidxMapping_),this.addSidxSegments_(this.media(),this.state,n=>{this.refreshMedia_(this.media().id)}))})}refreshMedia_(e){if(!e)throw new Error("refreshMedia_ must take a media id");this.media_&&this.isMain_&&this.handleMain_();const i=this.mainPlaylistLoader_.main.playlists,n=!this.media_||this.media_!==i[e];if(n?this.media_=i[e]:this.trigger("playlistunchanged"),!this.mediaUpdateTimeout){const r=()=>{this.media().endList||(this.mediaUpdateTimeout=A.setTimeout(()=>{this.trigger("mediaupdatetimeout"),r()},uf(this.media(),!!n)))};r()}this.trigger("loadedplaylist")}addEventStreamToMetadataTrack_(e){if(e&&this.mainPlaylistLoader_.main.eventStream){const i=this.mainPlaylistLoader_.main.eventStream.map(n=>({cueTime:n.start,frames:[{data:n.messageData}]}));this.addMetadataToTextTrack("EventStream",i,this.mainPlaylistLoader_.main.duration)}}}var Qe={GOAL_BUFFER_LENGTH:30,MAX_GOAL_BUFFER_LENGTH:60,BACK_BUFFER_LENGTH:30,GOAL_BUFFER_LENGTH_RATE:1,INITIAL_BANDWIDTH:4194304,BANDWIDTH_VARIANCE:1.2,BUFFER_LOW_WATER_LINE:0,MAX_BUFFER_LOW_WATER_LINE:30,EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:16,BUFFER_LOW_WATER_LINE_RATE:1,BUFFER_HIGH_WATER_LINE:30};const XP=t=>{const e=new Uint8Array(new ArrayBuffer(t.length));for(let i=0;i-1):!1},this.trigger=function(d){var f,h,m,y;if(f=u[d],!!f)if(arguments.length===2)for(m=f.length,h=0;h"u")){for(u in Q)Q.hasOwnProperty(u)&&(Q[u]=[u.charCodeAt(0),u.charCodeAt(1),u.charCodeAt(2),u.charCodeAt(3)]);ce=new Uint8Array([105,115,111,109]),ue=new Uint8Array([97,118,99,49]),dt=new Uint8Array([0,0,0,1]),Ce=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),H=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),ee={video:Ce,audio:H},Te=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),fe=new Uint8Array([0,0,0,0,0,0,0,0]),Ui=new Uint8Array([0,0,0,0,0,0,0,0]),yi=Ui,xr=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),vi=Ui,te=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}})(),o=function(u){var d=[],f=0,h,m,y;for(h=1;h>>1,u.samplingfrequencyindex<<7|u.channelcount<<3,6,1,2]))},p=function(){return o(Q.ftyp,ce,dt,ce,ue)},N=function(u){return o(Q.hdlr,ee[u])},g=function(u){return o(Q.mdat,u)},L=function(u){var d=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,u.duration>>>24&255,u.duration>>>16&255,u.duration>>>8&255,u.duration&255,85,196,0,0]);return u.samplerate&&(d[12]=u.samplerate>>>24&255,d[13]=u.samplerate>>>16&255,d[14]=u.samplerate>>>8&255,d[15]=u.samplerate&255),o(Q.mdhd,d)},k=function(u){return o(Q.mdia,L(u),N(u.type),S(u))},v=function(u){return o(Q.mfhd,new Uint8Array([0,0,0,0,(u&4278190080)>>24,(u&16711680)>>16,(u&65280)>>8,u&255]))},S=function(u){return o(Q.minf,u.type==="video"?o(Q.vmhd,te):o(Q.smhd,fe),l(),$(u))},_=function(u,d){for(var f=[],h=d.length;h--;)f[h]=Y(d[h]);return o.apply(null,[Q.moof,v(u)].concat(f))},w=function(u){for(var d=u.length,f=[];d--;)f[d]=T(u[d]);return o.apply(null,[Q.moov,x(4294967295)].concat(f).concat(I(u)))},I=function(u){for(var d=u.length,f=[];d--;)f[d]=ne(u[d]);return o.apply(null,[Q.mvex].concat(f))},x=function(u){var d=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(u&4278190080)>>24,(u&16711680)>>16,(u&65280)>>8,u&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return o(Q.mvhd,d)},F=function(u){var d=u.samples||[],f=new Uint8Array(4+d.length),h,m;for(m=0;m>>8),y.push(h[b].byteLength&255),y=y.concat(Array.prototype.slice.call(h[b]));for(b=0;b>>8),E.push(m[b].byteLength&255),E=E.concat(Array.prototype.slice.call(m[b]));if(D=[Q.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(f.width&65280)>>8,f.width&255,(f.height&65280)>>8,f.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o(Q.avcC,new Uint8Array([1,f.profileIdc,f.profileCompatibility,f.levelIdc,255].concat([h.length],y,[m.length],E))),o(Q.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]))],f.sarRatio){var P=f.sarRatio[0],O=f.sarRatio[1];D.push(o(Q.pasp,new Uint8Array([(P&4278190080)>>24,(P&16711680)>>16,(P&65280)>>8,P&255,(O&4278190080)>>24,(O&16711680)>>16,(O&65280)>>8,O&255])))}return o.apply(null,D)},d=function(f){return o(Q.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(f.channelcount&65280)>>8,f.channelcount&255,(f.samplesize&65280)>>8,f.samplesize&255,0,0,0,0,(f.samplerate&65280)>>8,f.samplerate&255,0,0]),c(f))}}(),C=function(u){var d=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(u.id&4278190080)>>24,(u.id&16711680)>>16,(u.id&65280)>>8,u.id&255,0,0,0,0,(u.duration&4278190080)>>24,(u.duration&16711680)>>16,(u.duration&65280)>>8,u.duration&255,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,(u.width&65280)>>8,u.width&255,0,0,(u.height&65280)>>8,u.height&255,0,0]);return o(Q.tkhd,d)},Y=function(u){var d,f,h,m,y,E,b;return d=o(Q.tfhd,new Uint8Array([0,0,0,58,(u.id&4278190080)>>24,(u.id&16711680)>>16,(u.id&65280)>>8,u.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),E=Math.floor(u.baseMediaDecodeTime/a),b=Math.floor(u.baseMediaDecodeTime%a),f=o(Q.tfdt,new Uint8Array([1,0,0,0,E>>>24&255,E>>>16&255,E>>>8&255,E&255,b>>>24&255,b>>>16&255,b>>>8&255,b&255])),y=92,u.type==="audio"?(h=he(u,y),o(Q.traf,d,f,h)):(m=F(u),h=he(u,m.length+y),o(Q.traf,d,f,h,m))},T=function(u){return u.duration=u.duration||4294967295,o(Q.trak,C(u),k(u))},ne=function(u){var d=new Uint8Array([0,0,0,0,(u.id&4278190080)>>24,(u.id&16711680)>>16,(u.id&65280)>>8,u.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return u.type!=="video"&&(d[d.length-1]=0),o(Q.trex,d)},function(){var u,d,f;f=function(h,m){var y=0,E=0,b=0,D=0;return h.length&&(h[0].duration!==void 0&&(y=1),h[0].size!==void 0&&(E=2),h[0].flags!==void 0&&(b=4),h[0].compositionTimeOffset!==void 0&&(D=8)),[0,0,y|E|b|D,1,(h.length&4278190080)>>>24,(h.length&16711680)>>>16,(h.length&65280)>>>8,h.length&255,(m&4278190080)>>>24,(m&16711680)>>>16,(m&65280)>>>8,m&255]},d=function(h,m){var y,E,b,D,P,O;for(D=h.samples||[],m+=20+16*D.length,b=f(D,m),E=new Uint8Array(b.length+D.length*16),E.set(b),y=b.length,O=0;O>>24,E[y++]=(P.duration&16711680)>>>16,E[y++]=(P.duration&65280)>>>8,E[y++]=P.duration&255,E[y++]=(P.size&4278190080)>>>24,E[y++]=(P.size&16711680)>>>16,E[y++]=(P.size&65280)>>>8,E[y++]=P.size&255,E[y++]=P.flags.isLeading<<2|P.flags.dependsOn,E[y++]=P.flags.isDependedOn<<6|P.flags.hasRedundancy<<4|P.flags.paddingValue<<1|P.flags.isNonSyncSample,E[y++]=P.flags.degradationPriority&61440,E[y++]=P.flags.degradationPriority&15,E[y++]=(P.compositionTimeOffset&4278190080)>>>24,E[y++]=(P.compositionTimeOffset&16711680)>>>16,E[y++]=(P.compositionTimeOffset&65280)>>>8,E[y++]=P.compositionTimeOffset&255;return o(Q.trun,E)},u=function(h,m){var y,E,b,D,P,O;for(D=h.samples||[],m+=20+8*D.length,b=f(D,m),y=new Uint8Array(b.length+D.length*8),y.set(b),E=b.length,O=0;O>>24,y[E++]=(P.duration&16711680)>>>16,y[E++]=(P.duration&65280)>>>8,y[E++]=P.duration&255,y[E++]=(P.size&4278190080)>>>24,y[E++]=(P.size&16711680)>>>16,y[E++]=(P.size&65280)>>>8,y[E++]=P.size&255;return o(Q.trun,y)},he=function(h,m){return h.type==="audio"?u(h,m):d(h,m)}}();var Sr={ftyp:p,mdat:g,moof:_,moov:w,initSegment:function(u){var d=p(),f=w(u),h;return h=new Uint8Array(d.byteLength+f.byteLength),h.set(d),h.set(f,d.byteLength),h}},Vx=function(u){var d,f,h=[],m=[];for(m.byteLength=0,m.nalCount=0,m.duration=0,h.byteLength=0,d=0;d1&&(d=u.shift(),u.byteLength-=d.byteLength,u.nalCount-=d.nalCount,u[0][0].dts=d.dts,u[0][0].pts=d.pts,u[0][0].duration+=d.duration),u},qx=function(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}}},gm=function(u,d){var f=qx();return f.dataOffset=d,f.compositionTimeOffset=u.pts-u.dts,f.duration=u.duration,f.size=4*u.length,f.size+=u.byteLength,u.keyFrame&&(f.flags.dependsOn=2,f.flags.isNonSyncSample=0),f},Wx=function(u,d){var f,h,m,y,E,b=d||0,D=[];for(f=0;fko.ONE_SECOND_IN_TS/2))){for(P=Zx()[u.samplerate],P||(P=d[0].data),O=0;O=f?u:(d.minSegmentDts=1/0,u.filter(function(h){return h.dts>=f?(d.minSegmentDts=Math.min(d.minSegmentDts,h.dts),d.minSegmentPts=d.minSegmentDts,!0):!1}))},nS=function(u){var d,f,h=[];for(d=0;d=this.virtualRowCount&&typeof this.beforeRowOverflow=="function"&&this.beforeRowOverflow(u),this.rows.length>0&&(this.rows.push(""),this.rowIdx++);this.rows.length>this.virtualRowCount;)this.rows.shift(),this.rowIdx--},ji.prototype.isEmpty=function(){return this.rows.length===0?!0:this.rows.length===1?this.rows[0]==="":!1},ji.prototype.addText=function(u){this.rows[this.rowIdx]+=u},ji.prototype.backspace=function(){if(!this.isEmpty()){var u=this.rows[this.rowIdx];this.rows[this.rowIdx]=u.substr(0,u.length-1)}};var Lo=function(u,d,f){this.serviceNum=u,this.text="",this.currentWindow=new ji(-1),this.windows=[],this.stream=f,typeof d=="string"&&this.createTextDecoder(d)};Lo.prototype.init=function(u,d){this.startPts=u;for(var f=0;f<8;f++)this.windows[f]=new ji(f),typeof d=="function"&&(this.windows[f].beforeRowOverflow=d)},Lo.prototype.setCurrentWindow=function(u){this.currentWindow=this.windows[u]},Lo.prototype.createTextDecoder=function(u){if(typeof TextDecoder>"u")this.stream.trigger("log",{level:"warn",message:"The `encoding` option is unsupported without TextDecoder support"});else try{this.textDecoder_=new TextDecoder(u)}catch(d){this.stream.trigger("log",{level:"warn",message:"TextDecoder could not be created with "+u+" encoding. "+d})}};var _e=function(u){u=u||{},_e.prototype.init.call(this);var d=this,f=u.captionServices||{},h={},m;Object.keys(f).forEach(y=>{m=f[y],/^SERVICE/.test(y)&&(h[y]=m.encoding)}),this.serviceEncodings=h,this.current708Packet=null,this.services={},this.push=function(y){y.type===3?(d.new708Packet(),d.add708Bytes(y)):(d.current708Packet===null&&d.new708Packet(),d.add708Bytes(y))}};_e.prototype=new Rc,_e.prototype.new708Packet=function(){this.current708Packet!==null&&this.push708Packet(),this.current708Packet={data:[],ptsVals:[]}},_e.prototype.add708Bytes=function(u){var d=u.ccData,f=d>>>8,h=d&255;this.current708Packet.ptsVals.push(u.pts),this.current708Packet.data.push(f),this.current708Packet.data.push(h)},_e.prototype.push708Packet=function(){var u=this.current708Packet,d=u.data,f=null,h=null,m=0,y=d[m++];for(u.seq=y>>6,u.sizeCode=y&63;m>5,h=y&31,f===7&&h>0&&(y=d[m++],f=y),this.pushServiceBlock(f,m,h),h>0&&(m+=h-1)},_e.prototype.pushServiceBlock=function(u,d,f){var h,m=d,y=this.current708Packet.data,E=this.services[u];for(E||(E=this.initService(u,m));m("0"+(Z&255).toString(16)).slice(-2)).join("")}if(m?(R=[b,D],u++):R=[b],d.textDecoder_&&!h)O=d.textDecoder_.decode(new Uint8Array(R));else if(m){const U=z(R);O=String.fromCharCode(parseInt(U,16))}else O=yS(E|b);return P.pendingNewLine&&!P.isEmpty()&&P.newLine(this.getPts(u)),P.pendingNewLine=!1,P.addText(O),u},_e.prototype.multiByteCharacter=function(u,d){var f=this.current708Packet.data,h=f[u+1],m=f[u+2];return Io(h)&&Io(m)&&(u=this.handleText(++u,d,{isMultiByte:!0})),u},_e.prototype.setCurrentWindow=function(u,d){var f=this.current708Packet.data,h=f[u],m=h&7;return d.setCurrentWindow(m),u},_e.prototype.defineWindow=function(u,d){var f=this.current708Packet.data,h=f[u],m=h&7;d.setCurrentWindow(m);var y=d.currentWindow;return h=f[++u],y.visible=(h&32)>>5,y.rowLock=(h&16)>>4,y.columnLock=(h&8)>>3,y.priority=h&7,h=f[++u],y.relativePositioning=(h&128)>>7,y.anchorVertical=h&127,h=f[++u],y.anchorHorizontal=h,h=f[++u],y.anchorPoint=(h&240)>>4,y.rowCount=h&15,h=f[++u],y.columnCount=h&63,h=f[++u],y.windowStyle=(h&56)>>3,y.penStyle=h&7,y.virtualRowCount=y.rowCount+1,u},_e.prototype.setWindowAttributes=function(u,d){var f=this.current708Packet.data,h=f[u],m=d.currentWindow.winAttr;return h=f[++u],m.fillOpacity=(h&192)>>6,m.fillRed=(h&48)>>4,m.fillGreen=(h&12)>>2,m.fillBlue=h&3,h=f[++u],m.borderType=(h&192)>>6,m.borderRed=(h&48)>>4,m.borderGreen=(h&12)>>2,m.borderBlue=h&3,h=f[++u],m.borderType+=(h&128)>>5,m.wordWrap=(h&64)>>6,m.printDirection=(h&48)>>4,m.scrollDirection=(h&12)>>2,m.justify=h&3,h=f[++u],m.effectSpeed=(h&240)>>4,m.effectDirection=(h&12)>>2,m.displayEffect=h&3,u},_e.prototype.flushDisplayed=function(u,d){for(var f=[],h=0;h<8;h++)d.windows[h].visible&&!d.windows[h].isEmpty()&&f.push(d.windows[h].getText());d.endPts=u,d.text=f.join(`
-
-`),this.pushCaption(d),d.startPts=u},_e.prototype.pushCaption=function(u){u.text!==""&&(this.trigger("data",{startPts:u.startPts,endPts:u.endPts,text:u.text,stream:"cc708_"+u.serviceNum}),u.text="",u.startPts=u.endPts)},_e.prototype.displayWindows=function(u,d){var f=this.current708Packet.data,h=f[++u],m=this.getPts(u);this.flushDisplayed(m,d);for(var y=0;y<8;y++)h&1<>4,m.offset=(h&12)>>2,m.penSize=h&3,h=f[++u],m.italics=(h&128)>>7,m.underline=(h&64)>>6,m.edgeType=(h&56)>>3,m.fontStyle=h&7,u},_e.prototype.setPenColor=function(u,d){var f=this.current708Packet.data,h=f[u],m=d.currentWindow.penColor;return h=f[++u],m.fgOpacity=(h&192)>>6,m.fgRed=(h&48)>>4,m.fgGreen=(h&12)>>2,m.fgBlue=h&3,h=f[++u],m.bgOpacity=(h&192)>>6,m.bgRed=(h&48)>>4,m.bgGreen=(h&12)>>2,m.bgBlue=h&3,h=f[++u],m.edgeRed=(h&48)>>4,m.edgeGreen=(h&12)>>2,m.edgeBlue=h&3,u},_e.prototype.setPenLocation=function(u,d){var f=this.current708Packet.data,h=f[u],m=d.currentWindow.penLoc;return d.currentWindow.pendingNewLine=!0,h=f[++u],m.row=h&15,h=f[++u],m.column=h&63,u},_e.prototype.reset=function(u,d){var f=this.getPts(u);return this.flushDisplayed(f,d),this.initService(d.serviceNum,u)};var vS={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496},Oo=function(u){return u===null?"":(u=vS[u]||u,String.fromCharCode(u))},No=14,_S=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],zn=function(){for(var u=[],d=No+1;d--;)u.push({text:"",indent:0,offset:0});return u},ke=function(u,d){ke.prototype.init.call(this),this.field_=u||0,this.dataChannel_=d||0,this.name_="CC"+((this.field_<<1|this.dataChannel_)+1),this.setConstants(),this.reset(),this.push=function(f){var h,m,y,E,b;if(h=f.ccData&32639,h===this.lastControlCode_){this.lastControlCode_=null;return}if((h&61440)===4096?this.lastControlCode_=h:h!==this.PADDING_&&(this.lastControlCode_=null),y=h>>>8,E=h&255,h!==this.PADDING_)if(h===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(h===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(f.pts),this.flushDisplayed(f.pts),m=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=m,this.startPts_=f.pts;else if(h===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(f.pts);else if(h===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(f.pts);else if(h===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(f.pts);else if(h===this.CARRIAGE_RETURN_)this.clearFormatting(f.pts),this.flushDisplayed(f.pts),this.shiftRowsUp_(),this.startPts_=f.pts;else if(h===this.BACKSPACE_)this.mode_==="popOn"?this.nonDisplayed_[this.row_].text=this.nonDisplayed_[this.row_].text.slice(0,-1):this.displayed_[this.row_].text=this.displayed_[this.row_].text.slice(0,-1);else if(h===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(f.pts),this.displayed_=zn();else if(h===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=zn();else if(h===this.RESUME_DIRECT_CAPTIONING_)this.mode_!=="paintOn"&&(this.flushDisplayed(f.pts),this.displayed_=zn()),this.mode_="paintOn",this.startPts_=f.pts;else if(this.isSpecialCharacter(y,E))y=(y&3)<<8,b=Oo(y|E),this[this.mode_](f.pts,b),this.column_++;else if(this.isExtCharacter(y,E))this.mode_==="popOn"?this.nonDisplayed_[this.row_].text=this.nonDisplayed_[this.row_].text.slice(0,-1):this.displayed_[this.row_].text=this.displayed_[this.row_].text.slice(0,-1),y=(y&3)<<8,b=Oo(y|E),this[this.mode_](f.pts,b),this.column_++;else if(this.isMidRowCode(y,E))this.clearFormatting(f.pts),this[this.mode_](f.pts," "),this.column_++,(E&14)===14&&this.addFormatting(f.pts,["i"]),(E&1)===1&&this.addFormatting(f.pts,["u"]);else if(this.isOffsetControlCode(y,E)){const P=E&3;this.nonDisplayed_[this.row_].offset=P,this.column_+=P}else if(this.isPAC(y,E)){var D=_S.indexOf(h&7968);if(this.mode_==="rollUp"&&(D-this.rollUpRows_+1<0&&(D=this.rollUpRows_-1),this.setRollUp(f.pts,D)),D!==this.row_&&(this.clearFormatting(f.pts),this.row_=D),E&1&&this.formatting_.indexOf("u")===-1&&this.addFormatting(f.pts,["u"]),(h&16)===16){const P=(h&14)>>1;this.column_=P*4,this.nonDisplayed_[this.row_].indent+=P}this.isColorPAC(E)&&(E&14)===14&&this.addFormatting(f.pts,["i"])}else this.isNormalChar(y)&&(E===0&&(E=null),b=Oo(y),b+=Oo(E),this[this.mode_](f.pts,b),this.column_+=b.length)}};ke.prototype=new Rc,ke.prototype.flushDisplayed=function(u){const d=h=>{this.trigger("log",{level:"warn",message:"Skipping a malformed 608 caption at index "+h+"."})},f=[];this.displayed_.forEach((h,m)=>{if(h&&h.text&&h.text.length){try{h.text=h.text.trim()}catch{d(m)}h.text.length&&f.push({text:h.text,line:m+1,position:10+Math.min(70,h.indent*10)+h.offset*2.5})}else h==null&&d(m)}),f.length&&this.trigger("data",{startPts:this.startPts_,endPts:u,content:f,stream:this.name_})},ke.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=zn(),this.nonDisplayed_=zn(),this.lastControlCode_=null,this.column_=0,this.row_=No,this.rollUpRows_=2,this.formatting_=[]},ke.prototype.setConstants=function(){this.dataChannel_===0?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):this.dataChannel_===1&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=this.CONTROL_|32,this.END_OF_CAPTION_=this.CONTROL_|47,this.ROLL_UP_2_ROWS_=this.CONTROL_|37,this.ROLL_UP_3_ROWS_=this.CONTROL_|38,this.ROLL_UP_4_ROWS_=this.CONTROL_|39,this.CARRIAGE_RETURN_=this.CONTROL_|45,this.RESUME_DIRECT_CAPTIONING_=this.CONTROL_|41,this.BACKSPACE_=this.CONTROL_|33,this.ERASE_DISPLAYED_MEMORY_=this.CONTROL_|44,this.ERASE_NON_DISPLAYED_MEMORY_=this.CONTROL_|46},ke.prototype.isSpecialCharacter=function(u,d){return u===this.EXT_&&d>=48&&d<=63},ke.prototype.isExtCharacter=function(u,d){return(u===this.EXT_+1||u===this.EXT_+2)&&d>=32&&d<=63},ke.prototype.isMidRowCode=function(u,d){return u===this.EXT_&&d>=32&&d<=47},ke.prototype.isOffsetControlCode=function(u,d){return u===this.OFFSET_&&d>=33&&d<=35},ke.prototype.isPAC=function(u,d){return u>=this.BASE_&&u=64&&d<=127},ke.prototype.isColorPAC=function(u){return u>=64&&u<=79||u>=96&&u<=127},ke.prototype.isNormalChar=function(u){return u>=32&&u<=127},ke.prototype.setRollUp=function(u,d){if(this.mode_!=="rollUp"&&(this.row_=No,this.mode_="rollUp",this.flushDisplayed(u),this.nonDisplayed_=zn(),this.displayed_=zn()),d!==void 0&&d!==this.row_)for(var f=0;f"},"");this[this.mode_](u,f)},ke.prototype.clearFormatting=function(u){if(this.formatting_.length){var d=this.formatting_.reverse().reduce(function(f,h){return f+""+h+">"},"");this.formatting_=[],this[this.mode_](u,d)}},ke.prototype.popOn=function(u,d){var f=this.nonDisplayed_[this.row_].text;f+=d,this.nonDisplayed_[this.row_].text=f},ke.prototype.rollUp=function(u,d){var f=this.displayed_[this.row_].text;f+=d,this.displayed_[this.row_].text=f},ke.prototype.shiftRowsUp_=function(){var u;for(u=0;ud&&(f=-1);Math.abs(d-u)>SS;)u+=f*xS;return u},Bc=function(u){var d,f;Bc.prototype.init.call(this),this.type_=u||Em,this.push=function(h){this.type_!==Em&&h.type!==this.type_||(f===void 0&&(f=h.dts),h.dts=Mc(h.dts,f),h.pts=Mc(h.pts,f),d=h.dts,this.trigger("data",h))},this.flush=function(){f=d,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.discontinuity=function(){f=void 0,d=void 0},this.reset=function(){this.discontinuity(),this.trigger("reset")}};Bc.prototype=new TS;var bm={TimestampRolloverStream:Bc,handleRollover:Mc},ES=(u,d,f)=>{if(!u)return-1;for(var h=f;h";u.data[0]===Bo.Utf8&&(f=Mo(u.data,0,d),!(f<0)&&(u.mimeType=$s(u.data,d,f),d=f+1,u.pictureType=u.data[d],d++,h=Mo(u.data,0,d),!(h<0)&&(u.description=js(u.data,d,h),d=h+1,u.mimeType===m?u.url=$s(u.data,d,u.data.length):u.pictureData=u.data.subarray(d,u.data.length))))},"T*":function(u){u.data[0]===Bo.Utf8&&(u.value=js(u.data,1,u.data.length).replace(/\0*$/,""),u.values=u.value.split("\0"))},TXXX:function(u){var d;u.data[0]===Bo.Utf8&&(d=Mo(u.data,0,1),d!==-1&&(u.description=js(u.data,1,d),u.value=js(u.data,d+1,u.data.length).replace(/\0*$/,""),u.data=u.value))},"W*":function(u){u.url=$s(u.data,0,u.data.length).replace(/\0.*$/,"")},WXXX:function(u){var d;u.data[0]===Bo.Utf8&&(d=Mo(u.data,0,1),d!==-1&&(u.description=js(u.data,1,d),u.url=$s(u.data,d+1,u.data.length).replace(/\0.*$/,"")))},PRIV:function(u){var d;for(d=0;d>>2;Z*=4,Z+=U[7]&3,O.timeStamp=Z,b.pts===void 0&&b.dts===void 0&&(b.pts=O.timeStamp,b.dts=O.timeStamp),this.trigger("timestamp",O)}b.frames.push(O),D+=10,D+=P}while(D>>4>1&&(E+=m[E]+1),y.pid===0)y.type="pat",u(m.subarray(E),y),this.trigger("data",y);else if(y.pid===this.pmtPid)for(y.type="pmt",u(m.subarray(E),y),this.trigger("data",y);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else this.programMapTable===void 0?this.packetsWaitingForPmt.push([m,E,y]):this.processPes_(m,E,y)},this.processPes_=function(m,y,E){E.pid===this.programMapTable.video?E.streamType=ai.H264_STREAM_TYPE:E.pid===this.programMapTable.audio?E.streamType=ai.ADTS_STREAM_TYPE:E.streamType=this.programMapTable["timed-metadata"][E.pid],E.type="pes",E.data=m.subarray(y),this.trigger("data",E)}},Hs.prototype=new Fc,Hs.STREAM_TYPES={h264:27,adts:15},jo=function(){var u=this,d=!1,f={data:[],size:0},h={data:[],size:0},m={data:[],size:0},y,E=function(D,P){var O;const R=D[0]<<16|D[1]<<8|D[2];P.data=new Uint8Array,R===1&&(P.packetLength=6+(D[4]<<8|D[5]),P.dataAlignmentIndicator=(D[6]&4)!==0,O=D[7],O&192&&(P.pts=(D[9]&14)<<27|(D[10]&255)<<20|(D[11]&254)<<12|(D[12]&255)<<5|(D[13]&254)>>>3,P.pts*=4,P.pts+=(D[13]&6)>>>1,P.dts=P.pts,O&64&&(P.dts=(D[14]&14)<<27|(D[15]&255)<<20|(D[16]&254)<<12|(D[17]&255)<<5|(D[18]&254)>>>3,P.dts*=4,P.dts+=(D[18]&6)>>>1)),P.data=D.subarray(9+D[8]))},b=function(D,P,O){var R=new Uint8Array(D.size),z={type:P},U=0,Z=0,ie=!1,qe;if(!(!D.data.length||D.size<9)){for(z.trackId=D.data[0].pid,U=0;U>5,D=((d[m+6]&3)+1)*1024,P=D*LS/Am[(d[m+2]&60)>>>2],d.byteLength-m>>6&3)+1,channelcount:(d[m+2]&1)<<2|(d[m+3]&192)>>>6,samplerate:Am[(d[m+2]&60)>>>2],samplingfrequencyindex:(d[m+2]&60)>>>2,samplesize:16,data:d.subarray(m+7+E,m+y)}),f++,m+=y}typeof O=="number"&&(this.skipWarn_(O,m),O=null),d=d.subarray(m)}},this.flush=function(){f=0,this.trigger("done")},this.reset=function(){d=void 0,this.trigger("reset")},this.endTimeline=function(){d=void 0,this.trigger("endedtimeline")}},$o.prototype=new IS;var OS=$o,km;km=function(u){var d=u.byteLength,f=0,h=0;this.length=function(){return 8*d},this.bitsAvailable=function(){return 8*d+h},this.loadWord=function(){var m=u.byteLength-d,y=new Uint8Array(4),E=Math.min(4,d);if(E===0)throw new Error("no bytes available");y.set(u.subarray(m,m+E)),f=new DataView(y.buffer).getUint32(0),h=E*8,d-=E},this.skipBits=function(m){var y;h>m?(f<<=m,h-=m):(m-=h,y=Math.floor(m/8),m-=y*8,d-=y,this.loadWord(),f<<=m,h-=m)},this.readBits=function(m){var y=Math.min(h,m),E=f>>>32-y;return h-=y,h>0?f<<=y:d>0&&this.loadWord(),y=m-y,y>0?E<>>m)return f<<=m,h-=m,m;return this.loadWord(),m+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var m=this.skipLeadingZeros();return this.readBits(m+1)-1},this.readExpGolomb=function(){var m=this.readUnsignedExpGolomb();return 1&m?1+m>>>1:-1*(m>>>1)},this.readBoolean=function(){return this.readBits(1)===1},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()};var NS=km,Pm=i,RS=NS,Vo,qs,Im;qs=function(){var u=0,d,f;qs.prototype.init.call(this),this.push=function(h){var m;f?(m=new Uint8Array(f.byteLength+h.data.byteLength),m.set(f),m.set(h.data,f.byteLength),f=m):f=h.data;for(var y=f.byteLength;u3&&this.trigger("data",f.subarray(u+3)),f=null,u=0,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")}},qs.prototype=new Pm,Im={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},Vo=function(){var u=new qs,d,f,h,m,y,E,b;Vo.prototype.init.call(this),d=this,this.push=function(D){D.type==="video"&&(f=D.trackId,h=D.pts,m=D.dts,u.push(D))},u.on("data",function(D){var P={trackId:f,pts:h,dts:m,data:D,nalUnitTypeCode:D[0]&31};switch(P.nalUnitTypeCode){case 5:P.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:P.nalUnitType="sei_rbsp",P.escapedRBSP=y(D.subarray(1));break;case 7:P.nalUnitType="seq_parameter_set_rbsp",P.escapedRBSP=y(D.subarray(1)),P.config=E(P.escapedRBSP);break;case 8:P.nalUnitType="pic_parameter_set_rbsp";break;case 9:P.nalUnitType="access_unit_delimiter_rbsp";break}d.trigger("data",P)}),u.on("done",function(){d.trigger("done")}),u.on("partialdone",function(){d.trigger("partialdone")}),u.on("reset",function(){d.trigger("reset")}),u.on("endedtimeline",function(){d.trigger("endedtimeline")}),this.flush=function(){u.flush()},this.partialFlush=function(){u.partialFlush()},this.reset=function(){u.reset()},this.endTimeline=function(){u.endTimeline()},b=function(D,P){var O=8,R=8,z,U;for(z=0;z>4;return f=f>=0?f:0,m?f+20:f+10},Om=function(u,d){return u.length-d<10||u[d]!==73||u[d+1]!==68||u[d+2]!==51?d:(d+=Lm(u,d),Om(u,d))},FS=function(u){var d=Om(u,0);return u.length>=d+2&&(u[d]&255)===255&&(u[d+1]&240)===240&&(u[d+1]&22)===16},Nm=function(u){return u[0]<<21|u[1]<<14|u[2]<<7|u[3]},US=function(u,d,f){var h,m="";for(h=d;h>5,h=u[d+4]<<3,m=u[d+3]&6144;return m|h|f},VS=function(u,d){return u[d]===73&&u[d+1]===68&&u[d+2]===51?"timed-metadata":u[d]&!0&&(u[d+1]&240)===240?"audio":null},zS=function(u){for(var d=0;d+5>>2]}return null},HS=function(u){var d,f,h,m;d=10,u[5]&64&&(d+=4,d+=Nm(u.subarray(10,14)));do{if(f=Nm(u.subarray(d+4,d+8)),f<1)return null;if(m=String.fromCharCode(u[d],u[d+1],u[d+2],u[d+3]),m==="PRIV"){h=u.subarray(d+10,d+f+10);for(var y=0;y>>2;return D*=4,D+=b[7]&3,D}break}}d+=10,d+=f}while(d=3;){if(u[m]===73&&u[m+1]===68&&u[m+2]===51){if(u.length-m<10||(h=Rm.parseId3TagSize(u,m),m+h>u.length))break;E={type:"timed-metadata",data:u.subarray(m,m+h)},this.trigger("data",E),m+=h;continue}else if((u[m]&255)===255&&(u[m+1]&240)===240){if(u.length-m<7||(h=Rm.parseAdtsSize(u,m),m+h>u.length))break;b={type:"audio",data:u.subarray(m,m+h),pts:d,dts:d},this.trigger("data",b),m+=h;continue}m++}y=u.length-m,y>0?u=u.subarray(m):u=new Uint8Array},this.reset=function(){u=new Uint8Array,this.trigger("reset")},this.endTimeline=function(){u=new Uint8Array,this.trigger("endedtimeline")}},zo.prototype=new qS;var WS=zo,GS=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],XS=GS,KS=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],QS=KS,Ho=i,Ws=Sr,Gs=Qx,qo=sS,oi=cS,$i=PS,Wo=we,Mm=OS,YS=MS.H264Stream,JS=WS,ZS=Vc.isLikelyAacData,eE=we.ONE_SECOND_IN_TS,zc=XS,Hc=QS,Xs,br,Go,Hn,tE=function(u,d){d.stream=u,this.trigger("log",d)},Bm=function(u,d){for(var f=Object.keys(d),h=0;h=-P&&R<=D&&(!z||O>R)&&(z=Z,O=R)));return z?z.gop:null},this.alignGopsAtStart_=function(b){var D,P,O,R,z,U,Z,ie;for(z=b.byteLength,U=b.nalCount,Z=b.duration,D=P=0;DO.pts){D++;continue}P++,z-=R.byteLength,U-=R.nalCount,Z-=R.duration}return P===0?b:P===b.length?null:(ie=b.slice(P),ie.byteLength=z,ie.duration=Z,ie.nalCount=U,ie.pts=ie[0].pts,ie.dts=ie[0].dts,ie)},this.alignGopsAtEnd_=function(b){var D,P,O,R,z,U;for(D=m.length-1,P=b.length-1,z=null,U=!1;D>=0&&P>=0;){if(O=m[D],R=b[P],O.pts===R.pts){U=!0;break}if(O.pts>R.pts){D--;continue}D===m.length-1&&(z=P),P--}if(!U&&z===null)return null;var Z;if(U?Z=P:Z=z,Z===0)return b;var ie=b.slice(Z),qe=ie.reduce(function(Gt,Wn){return Gt.byteLength+=Wn.byteLength,Gt.duration+=Wn.duration,Gt.nalCount+=Wn.nalCount,Gt},{byteLength:0,duration:0,nalCount:0});return ie.byteLength=qe.byteLength,ie.duration=qe.duration,ie.nalCount=qe.nalCount,ie.pts=ie[0].pts,ie.dts=ie[0].dts,ie},this.alignGopsWith=function(b){m=b}},Xs.prototype=new Ho,Hn=function(u,d){this.numberOfTracks=0,this.metadataStream=d,u=u||{},typeof u.remux<"u"?this.remuxTracks=!!u.remux:this.remuxTracks=!0,typeof u.keepOriginalTimestamps=="boolean"?this.keepOriginalTimestamps=u.keepOriginalTimestamps:this.keepOriginalTimestamps=!1,this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,Hn.prototype.init.call(this),this.push=function(f){if(f.content||f.text)return this.pendingCaptions.push(f);if(f.frames)return this.pendingMetadata.push(f);this.pendingTracks.push(f.track),this.pendingBytes+=f.boxes.byteLength,f.track.type==="video"&&(this.videoTrack=f.track,this.pendingBoxes.push(f.boxes)),f.track.type==="audio"&&(this.audioTrack=f.track,this.pendingBoxes.unshift(f.boxes))}},Hn.prototype=new Ho,Hn.prototype.flush=function(u){var d=0,f={captions:[],captionStreams:{},metadata:[],info:{}},h,m,y,E=0,b;if(this.pendingTracks.length=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0);return}}if(this.videoTrack?(E=this.videoTrack.timelineStartInfo.pts,Hc.forEach(function(D){f.info[D]=this.videoTrack[D]},this)):this.audioTrack&&(E=this.audioTrack.timelineStartInfo.pts,zc.forEach(function(D){f.info[D]=this.audioTrack[D]},this)),this.videoTrack||this.audioTrack){for(this.pendingTracks.length===1?f.type=this.pendingTracks[0].type:f.type="combined",this.emittedTracks+=this.pendingTracks.length,y=Ws.initSegment(this.pendingTracks),f.initSegment=new Uint8Array(y.byteLength),f.initSegment.set(y),f.data=new Uint8Array(this.pendingBytes),b=0;b=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)},Hn.prototype.setRemux=function(u){this.remuxTracks=u},Go=function(u){var d=this,f=!0,h,m;Go.prototype.init.call(this),u=u||{},this.baseMediaDecodeTime=u.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var y={};this.transmuxPipeline_=y,y.type="aac",y.metadataStream=new $i.MetadataStream,y.aacStream=new JS,y.audioTimestampRolloverStream=new $i.TimestampRolloverStream("audio"),y.timedMetadataTimestampRolloverStream=new $i.TimestampRolloverStream("timed-metadata"),y.adtsStream=new Mm,y.coalesceStream=new Hn(u,y.metadataStream),y.headOfPipeline=y.aacStream,y.aacStream.pipe(y.audioTimestampRolloverStream).pipe(y.adtsStream),y.aacStream.pipe(y.timedMetadataTimestampRolloverStream).pipe(y.metadataStream).pipe(y.coalesceStream),y.metadataStream.on("timestamp",function(E){y.aacStream.setTimestamp(E.timeStamp)}),y.aacStream.on("data",function(E){E.type!=="timed-metadata"&&E.type!=="audio"||y.audioSegmentStream||(m=m||{timelineStartInfo:{baseMediaDecodeTime:d.baseMediaDecodeTime},codec:"adts",type:"audio"},y.coalesceStream.numberOfTracks++,y.audioSegmentStream=new br(m,u),y.audioSegmentStream.on("log",d.getLogTrigger_("audioSegmentStream")),y.audioSegmentStream.on("timingInfo",d.trigger.bind(d,"audioTimingInfo")),y.adtsStream.pipe(y.audioSegmentStream).pipe(y.coalesceStream),d.trigger("trackinfo",{hasAudio:!!m,hasVideo:!!h}))}),y.coalesceStream.on("data",this.trigger.bind(this,"data")),y.coalesceStream.on("done",this.trigger.bind(this,"done")),Bm(this,y)},this.setupTsPipeline=function(){var y={};this.transmuxPipeline_=y,y.type="ts",y.metadataStream=new $i.MetadataStream,y.packetStream=new $i.TransportPacketStream,y.parseStream=new $i.TransportParseStream,y.elementaryStream=new $i.ElementaryStream,y.timestampRolloverStream=new $i.TimestampRolloverStream,y.adtsStream=new Mm,y.h264Stream=new YS,y.captionStream=new $i.CaptionStream(u),y.coalesceStream=new Hn(u,y.metadataStream),y.headOfPipeline=y.packetStream,y.packetStream.pipe(y.parseStream).pipe(y.elementaryStream).pipe(y.timestampRolloverStream),y.timestampRolloverStream.pipe(y.h264Stream),y.timestampRolloverStream.pipe(y.adtsStream),y.timestampRolloverStream.pipe(y.metadataStream).pipe(y.coalesceStream),y.h264Stream.pipe(y.captionStream).pipe(y.coalesceStream),y.elementaryStream.on("data",function(E){var b;if(E.type==="metadata"){for(b=E.tracks.length;b--;)!h&&E.tracks[b].type==="video"?(h=E.tracks[b],h.timelineStartInfo.baseMediaDecodeTime=d.baseMediaDecodeTime):!m&&E.tracks[b].type==="audio"&&(m=E.tracks[b],m.timelineStartInfo.baseMediaDecodeTime=d.baseMediaDecodeTime);h&&!y.videoSegmentStream&&(y.coalesceStream.numberOfTracks++,y.videoSegmentStream=new Xs(h,u),y.videoSegmentStream.on("log",d.getLogTrigger_("videoSegmentStream")),y.videoSegmentStream.on("timelineStartInfo",function(D){m&&!u.keepOriginalTimestamps&&(m.timelineStartInfo=D,y.audioSegmentStream.setEarliestDts(D.dts-d.baseMediaDecodeTime))}),y.videoSegmentStream.on("processedGopsInfo",d.trigger.bind(d,"gopInfo")),y.videoSegmentStream.on("segmentTimingInfo",d.trigger.bind(d,"videoSegmentTimingInfo")),y.videoSegmentStream.on("baseMediaDecodeTime",function(D){m&&y.audioSegmentStream.setVideoBaseMediaDecodeTime(D)}),y.videoSegmentStream.on("timingInfo",d.trigger.bind(d,"videoTimingInfo")),y.h264Stream.pipe(y.videoSegmentStream).pipe(y.coalesceStream)),m&&!y.audioSegmentStream&&(y.coalesceStream.numberOfTracks++,y.audioSegmentStream=new br(m,u),y.audioSegmentStream.on("log",d.getLogTrigger_("audioSegmentStream")),y.audioSegmentStream.on("timingInfo",d.trigger.bind(d,"audioTimingInfo")),y.audioSegmentStream.on("segmentTimingInfo",d.trigger.bind(d,"audioSegmentTimingInfo")),y.adtsStream.pipe(y.audioSegmentStream).pipe(y.coalesceStream)),d.trigger("trackinfo",{hasAudio:!!m,hasVideo:!!h})}}),y.coalesceStream.on("data",this.trigger.bind(this,"data")),y.coalesceStream.on("id3Frame",function(E){E.dispatchType=y.metadataStream.dispatchType,d.trigger("id3Frame",E)}),y.coalesceStream.on("caption",this.trigger.bind(this,"caption")),y.coalesceStream.on("done",this.trigger.bind(this,"done")),Bm(this,y)},this.setBaseMediaDecodeTime=function(y){var E=this.transmuxPipeline_;u.keepOriginalTimestamps||(this.baseMediaDecodeTime=y),m&&(m.timelineStartInfo.dts=void 0,m.timelineStartInfo.pts=void 0,oi.clearDtsInfo(m),E.audioTimestampRolloverStream&&E.audioTimestampRolloverStream.discontinuity()),h&&(E.videoSegmentStream&&(E.videoSegmentStream.gopCache_=[]),h.timelineStartInfo.dts=void 0,h.timelineStartInfo.pts=void 0,oi.clearDtsInfo(h),E.captionStream.reset()),E.timestampRolloverStream&&E.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(y){m&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(y)},this.setRemux=function(y){var E=this.transmuxPipeline_;u.remux=y,E&&E.coalesceStream&&E.coalesceStream.setRemux(y)},this.alignGopsWith=function(y){h&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(y)},this.getLogTrigger_=function(y){var E=this;return function(b){b.stream=y,E.trigger("log",b)}},this.push=function(y){if(f){var E=ZS(y);E&&this.transmuxPipeline_.type!=="aac"?this.setupAacPipeline():!E&&this.transmuxPipeline_.type!=="ts"&&this.setupTsPipeline(),f=!1}this.transmuxPipeline_.headOfPipeline.push(y)},this.flush=function(){f=!0,this.transmuxPipeline_.headOfPipeline.flush()},this.endTimeline=function(){this.transmuxPipeline_.headOfPipeline.endTimeline()},this.reset=function(){this.transmuxPipeline_.headOfPipeline&&this.transmuxPipeline_.headOfPipeline.reset()},this.resetCaptions=function(){this.transmuxPipeline_.captionStream&&this.transmuxPipeline_.captionStream.reset()}},Go.prototype=new Ho;var iE={Transmuxer:Go,VideoSegmentStream:Xs,AudioSegmentStream:br,AUDIO_PROPERTIES:zc,VIDEO_PROPERTIES:Hc,generateSegmentTimingInfo:qc},nE=function(u){return u>>>0},rE=function(u){return("00"+u.toString(16)).slice(-2)},Xo={toUnsigned:nE,toHexString:rE},sE=function(u){var d="";return d+=String.fromCharCode(u[0]),d+=String.fromCharCode(u[1]),d+=String.fromCharCode(u[2]),d+=String.fromCharCode(u[3]),d},Um=sE,aE=Xo.toUnsigned,oE=Um,jm=function(u,d){var f=[],h,m,y,E,b;if(!d.length)return null;for(h=0;h1?h+m:u.byteLength,y===d[0]&&(d.length===1?f.push(u.subarray(h+8,E)):(b=jm(u.subarray(h+8,E),d.slice(1)),b.length&&(f=f.concat(b)))),h=E;return f},$m=jm,lE=Xo.toUnsigned,uE=s.getUint64,cE=function(u){var d={version:u[0],flags:new Uint8Array(u.subarray(1,4))};return d.version===1?d.baseMediaDecodeTime=uE(u.subarray(4)):d.baseMediaDecodeTime=lE(u[4]<<24|u[5]<<16|u[6]<<8|u[7]),d},Vm=cE,dE=function(u){return{isLeading:(u[0]&12)>>>2,dependsOn:u[0]&3,isDependedOn:(u[1]&192)>>>6,hasRedundancy:(u[1]&48)>>>4,paddingValue:(u[1]&14)>>>1,isNonSyncSample:u[1]&1,degradationPriority:u[2]<<8|u[3]}},hE=dE,zm=hE,fE=function(u){var d={version:u[0],flags:new Uint8Array(u.subarray(1,4)),samples:[]},f=new DataView(u.buffer,u.byteOffset,u.byteLength),h=d.flags[2]&1,m=d.flags[2]&4,y=d.flags[1]&1,E=d.flags[1]&2,b=d.flags[1]&4,D=d.flags[1]&8,P=f.getUint32(4),O=8,R;for(h&&(d.dataOffset=f.getInt32(O),O+=4),m&&P&&(R={flags:zm(u.subarray(O,O+4))},O+=4,y&&(R.duration=f.getUint32(O),O+=4),E&&(R.size=f.getUint32(O),O+=4),D&&(d.version===1?R.compositionTimeOffset=f.getInt32(O):R.compositionTimeOffset=f.getUint32(O),O+=4),d.samples.push(R),P--);P--;)R={},y&&(R.duration=f.getUint32(O),O+=4),E&&(R.size=f.getUint32(O),O+=4),b&&(R.flags=zm(u.subarray(O,O+4)),O+=4),D&&(d.version===1?R.compositionTimeOffset=f.getInt32(O):R.compositionTimeOffset=f.getUint32(O),O+=4),d.samples.push(R);return d},Hm=fE,pE=function(u){var d=new DataView(u.buffer,u.byteOffset,u.byteLength),f={version:u[0],flags:new Uint8Array(u.subarray(1,4)),trackId:d.getUint32(4)},h=f.flags[2]&1,m=f.flags[2]&2,y=f.flags[2]&8,E=f.flags[2]&16,b=f.flags[2]&32,D=f.flags[0]&65536,P=f.flags[0]&131072,O;return O=8,h&&(O+=4,f.baseDataOffset=d.getUint32(12),O+=4),m&&(f.sampleDescriptionIndex=d.getUint32(O),O+=4),y&&(f.defaultSampleDuration=d.getUint32(O),O+=4),E&&(f.defaultSampleSize=d.getUint32(O),O+=4),b&&(f.defaultSampleFlags=d.getUint32(O)),D&&(f.durationIsEmpty=!0),!h&&P&&(f.baseDataOffsetIsMoof=!0),f},qm=pE,Ks;typeof window<"u"?Ks=window:typeof t<"u"?Ks=t:typeof self<"u"?Ks=self:Ks={};var Wm=Ks,mE=xm.discardEmulationPreventionBytes,gE=Sm.CaptionStream,Qs=$m,yE=Vm,vE=Hm,_E=qm,Gm=Wm,TE=function(u,d){for(var f=u,h=0;h0?yE(z[0]).baseMediaDecodeTime:0,Z=Qs(D,["trun"]),ie,qe;d===R&&Z.length>0&&(ie=SE(Z,U,O),qe=xE(b,ie,R),m[R]||(m[R]={seiNals:[],logs:[]}),m[R].seiNals=m[R].seiNals.concat(qe.seiNals),m[R].logs=m[R].logs.concat(qe.logs))}),m},bE=function(u,d,f){var h;if(d===null)return null;h=EE(u,d);var m=h[d]||{};return{seiNals:m.seiNals,logs:m.logs,timescale:f}},CE=function(){var u=!1,d,f,h,m,y,E;this.isInitialized=function(){return u},this.init=function(b){d=new gE,u=!0,E=b?b.isPartial:!1,d.on("data",function(D){D.startTime=D.startPts/m,D.endTime=D.endPts/m,y.captions.push(D),y.captionStreams[D.stream]=!0}),d.on("log",function(D){y.logs.push(D)})},this.isNewInit=function(b,D){return b&&b.length===0||D&&typeof D=="object"&&Object.keys(D).length===0?!1:h!==b[0]||m!==D[h]},this.parse=function(b,D,P){var O;if(this.isInitialized()){if(!D||!P)return null;if(this.isNewInit(D,P))h=D[0],m=P[h];else if(h===null||!m)return f.push(b),null}else return null;for(;f.length>0;){var R=f.shift();this.parse(R,D,P)}return O=bE(b,h,m),O&&O.logs&&(y.logs=y.logs.concat(O.logs)),O===null||!O.seiNals?y.logs.length?{logs:y.logs,captions:[],captionStreams:[]}:null:(this.pushNals(O.seiNals),this.flushStream(),y)},this.pushNals=function(b){if(!this.isInitialized()||!b||b.length===0)return null;b.forEach(function(D){d.push(D)})},this.flushStream=function(){if(!this.isInitialized())return null;E?d.partialFlush():d.flush()},this.clearParsedCaptions=function(){y.captions=[],y.captionStreams={},y.logs=[]},this.resetCaptionStream=function(){if(!this.isInitialized())return null;d.reset()},this.clearAllCaptions=function(){this.clearParsedCaptions(),this.resetCaptionStream()},this.reset=function(){f=[],h=null,m=null,y?this.clearParsedCaptions():y={captions:[],captionStreams:{},logs:[]},this.resetCaptionStream()},this.reset()},wE=CE,DE=function(u){for(var d=0,f=String.fromCharCode(u[d]),h="";f!=="\0";)h+=f,d++,f=String.fromCharCode(u[d]);return h+=f,h},AE={uint8ToCString:DE},Ko=AE.uint8ToCString,kE=s.getUint64,PE=function(u){var d=4,f=u[0],h,m,y,E,b,D,P,O;if(f===0){h=Ko(u.subarray(d)),d+=h.length,m=Ko(u.subarray(d)),d+=m.length;var R=new DataView(u.buffer);y=R.getUint32(d),d+=4,b=R.getUint32(d),d+=4,D=R.getUint32(d),d+=4,P=R.getUint32(d),d+=4}else if(f===1){var R=new DataView(u.buffer);y=R.getUint32(d),d+=4,E=kE(u.subarray(d)),d+=8,D=R.getUint32(d),d+=4,P=R.getUint32(d),d+=4,h=Ko(u.subarray(d)),d+=h.length,m=Ko(u.subarray(d)),d+=m.length}O=new Uint8Array(u.subarray(d,u.byteLength));var z={scheme_id_uri:h,value:m,timescale:y||1,presentation_time:E,presentation_time_delta:b,event_duration:D,id:P,message_data:O};return LE(f,z)?z:void 0},IE=function(u,d,f,h){return u||u===0?u/d:h+f/d},LE=function(u,d){var f=d.scheme_id_uri!=="\0",h=u===0&&Xm(d.presentation_time_delta)&&f,m=u===1&&Xm(d.presentation_time)&&f;return!(u>1)&&h||m},Xm=function(u){return u!==void 0||u!==null},OE={parseEmsgBox:PE,scaleTime:IE},Qo=Xo.toUnsigned,Ys=Xo.toHexString,Ue=$m,Cr=Um,Wc=OE,NE=qm,RE=Hm,ME=Vm,BE=s.getUint64,Km,Qm,Ym,Jm,Zm,Gc,eg,Xc=Wm,FE=wm.parseId3Frames;Km=function(u){var d={},f=Ue(u,["moov","trak"]);return f.reduce(function(h,m){var y,E,b,D,P;return y=Ue(m,["tkhd"])[0],!y||(E=y[0],b=E===0?12:20,D=Qo(y[b]<<24|y[b+1]<<16|y[b+2]<<8|y[b+3]),P=Ue(m,["mdia","mdhd"])[0],!P)?null:(E=P[0],b=E===0?12:20,h[D]=Qo(P[b]<<24|P[b+1]<<16|P[b+2]<<8|P[b+3]),h)},d)},Qm=function(u,d){var f;f=Ue(d,["moof","traf"]);var h=f.reduce(function(m,y){var E=Ue(y,["tfhd"])[0],b=Qo(E[4]<<24|E[5]<<16|E[6]<<8|E[7]),D=u[b]||9e4,P=Ue(y,["tfdt"])[0],O=new DataView(P.buffer,P.byteOffset,P.byteLength),R;P[0]===1?R=BE(P.subarray(4,12)):R=O.getUint32(4);let z;return typeof R=="bigint"?z=R/Xc.BigInt(D):typeof R=="number"&&!isNaN(R)&&(z=R/D),z11?(m.codec+=".",m.codec+=Ys(U[9]),m.codec+=Ys(U[10]),m.codec+=Ys(U[11])):m.codec="avc1.4d400d"):/^mp4[a,v]$/i.test(m.codec)?(U=z.subarray(28),Z=Cr(U.subarray(4,8)),Z==="esds"&&U.length>20&&U[19]!==0?(m.codec+="."+Ys(U[19]),m.codec+="."+Ys(U[20]>>>2&63).replace(/^0/,"")):m.codec="mp4a.40.2"):m.codec=m.codec.toLowerCase())}var ie=Ue(h,["mdia","mdhd"])[0];ie&&(m.timescale=Gc(ie)),f.push(m)}),f},eg=function(u,d=0){var f=Ue(u,["emsg"]);return f.map(h=>{var m=Wc.parseEmsgBox(new Uint8Array(h)),y=FE(m.message_data);return{cueTime:Wc.scaleTime(m.presentation_time,m.timescale,m.presentation_time_delta,d),duration:Wc.scaleTime(m.event_duration,m.timescale),frames:y}})};var Kc={findBox:Ue,parseType:Cr,timescale:Km,startTime:Qm,compositionStartTime:Ym,videoTrackIds:Jm,tracks:Zm,getTimescaleFromMediaHeader:Gc,getEmsgID3:eg},Qc=Ro,tg=function(u){var d=u[1]&31;return d<<=8,d|=u[2],d},Yo=function(u){return!!(u[1]&64)},Jo=function(u){var d=0;return(u[3]&48)>>>4>1&&(d+=u[4]+1),d},UE=function(u,d){var f=tg(u);return f===0?"pat":f===d?"pmt":d?"pes":null},jE=function(u){var d=Yo(u),f=4+Jo(u);return d&&(f+=u[f]+1),(u[f+10]&31)<<8|u[f+11]},$E=function(u){var d={},f=Yo(u),h=4+Jo(u);if(f&&(h+=u[h]+1),!!(u[h+5]&1)){var m,y,E;m=(u[h+1]&15)<<8|u[h+2],y=3+m-4,E=(u[h+10]&15)<<8|u[h+11];for(var b=12+E;b=u.byteLength)return null;var h=null,m;return m=u[f+7],m&192&&(h={},h.pts=(u[f+9]&14)<<27|(u[f+10]&255)<<20|(u[f+11]&254)<<12|(u[f+12]&255)<<5|(u[f+13]&254)>>>3,h.pts*=4,h.pts+=(u[f+13]&6)>>>1,h.dts=h.pts,m&64&&(h.dts=(u[f+14]&14)<<27|(u[f+15]&255)<<20|(u[f+16]&254)<<12|(u[f+17]&255)<<5|(u[f+18]&254)>>>3,h.dts*=4,h.dts+=(u[f+18]&6)>>>1)),h},Yc=function(u){switch(u){case 5:return"slice_layer_without_partitioning_rbsp_idr";case 6:return"sei_rbsp";case 7:return"seq_parameter_set_rbsp";case 8:return"pic_parameter_set_rbsp";case 9:return"access_unit_delimiter_rbsp";default:return null}},HE=function(u){for(var d=4+Jo(u),f=u.subarray(d),h=0,m=0,y=!1,E;m3&&(E=Yc(f[m+3]&31),E==="slice_layer_without_partitioning_rbsp_idr"&&(y=!0)),y},qE={parseType:UE,parsePat:jE,parsePmt:$E,parsePayloadUnitStartIndicator:Yo,parsePesType:VE,parsePesTime:zE,videoPacketContainsKeyFrame:HE},ig=Ro,wr=bm.handleRollover,me={};me.ts=qE,me.aac=Vc;var qn=we.ONE_SECOND_IN_TS,ht=188,_i=71,WE=function(u,d){for(var f=0,h=ht,m,y;h=0;){if(u[h]===_i&&(u[m]===_i||m===u.byteLength)){switch(y=u.subarray(h,m),E=me.ts.parseType(y,d.pid),E){case"pes":b=me.ts.parsePesType(y,d.table),D=me.ts.parsePayloadUnitStartIndicator(y),b==="audio"&&D&&(P=me.ts.parsePesTime(y),P&&(P.type="audio",f.audio.push(P),O=!0));break}if(O)break;h-=ht,m-=ht;continue}h--,m--}},GE=function(u,d,f){for(var h=0,m=ht,y,E,b,D,P,O,R,z,U=!1,Z={data:[],size:0};m=0;){if(u[h]===_i&&u[m]===_i){switch(y=u.subarray(h,m),E=me.ts.parseType(y,d.pid),E){case"pes":b=me.ts.parsePesType(y,d.table),D=me.ts.parsePayloadUnitStartIndicator(y),b==="video"&&D&&(P=me.ts.parsePesTime(y),P&&(P.type="video",f.video.push(P),U=!0));break}if(U)break;h-=ht,m-=ht;continue}h--,m--}},XE=function(u,d){if(u.audio&&u.audio.length){var f=d;(typeof f>"u"||isNaN(f))&&(f=u.audio[0].dts),u.audio.forEach(function(y){y.dts=wr(y.dts,f),y.pts=wr(y.pts,f),y.dtsTime=y.dts/qn,y.ptsTime=y.pts/qn})}if(u.video&&u.video.length){var h=d;if((typeof h>"u"||isNaN(h))&&(h=u.video[0].dts),u.video.forEach(function(y){y.dts=wr(y.dts,h),y.pts=wr(y.pts,h),y.dtsTime=y.dts/qn,y.ptsTime=y.pts/qn}),u.firstKeyFrame){var m=u.firstKeyFrame;m.dts=wr(m.dts,h),m.pts=wr(m.pts,h),m.dtsTime=m.dts/qn,m.ptsTime=m.pts/qn}}},KE=function(u){for(var d=!1,f=0,h=null,m=null,y=0,E=0,b;u.length-E>=3;){var D=me.aac.parseType(u,E);switch(D){case"timed-metadata":if(u.length-E<10){d=!0;break}if(y=me.aac.parseId3TagSize(u,E),y>u.length){d=!0;break}m===null&&(b=u.subarray(E,E+y),m=me.aac.parseAacTimestamp(b)),E+=y;break;case"audio":if(u.length-E<7){d=!0;break}if(y=me.aac.parseAdtsSize(u,E),y>u.length){d=!0;break}h===null&&(b=u.subarray(E,E+y),h=me.aac.parseSampleRate(b)),f++,E+=y;break;default:E++;break}if(d)return null}if(h===null||m===null)return null;var P=qn/h,O={audio:[{type:"audio",dts:m,pts:m},{type:"audio",dts:m+f*1024*P,pts:m+f*1024*P}]};return O},QE=function(u){var d={pid:null,table:null},f={};WE(u,d);for(var h in d.table)if(d.table.hasOwnProperty(h)){var m=d.table[h];switch(m){case ig.H264_STREAM_TYPE:f.video=[],GE(u,d,f),f.video.length===0&&delete f.video;break;case ig.ADTS_STREAM_TYPE:f.audio=[],ng(u,d,f),f.audio.length===0&&delete f.audio;break}}return f},YE=function(u,d){var f=me.aac.isLikelyAacData(u),h;return f?h=KE(u):h=QE(u),!h||!h.audio&&!h.video?null:(XE(h,d),h)},JE={inspect:YE,parseAudioPes_:ng};const ZE=function(u,d){d.on("data",function(f){const h=f.initSegment;f.initSegment={data:h.buffer,byteOffset:h.byteOffset,byteLength:h.byteLength};const m=f.data;f.data=m.buffer,u.postMessage({action:"data",segment:f,byteOffset:m.byteOffset,byteLength:m.byteLength},[f.data])}),d.on("done",function(f){u.postMessage({action:"done"})}),d.on("gopInfo",function(f){u.postMessage({action:"gopInfo",gopInfo:f})}),d.on("videoSegmentTimingInfo",function(f){const h={start:{decode:we.videoTsToSeconds(f.start.dts),presentation:we.videoTsToSeconds(f.start.pts)},end:{decode:we.videoTsToSeconds(f.end.dts),presentation:we.videoTsToSeconds(f.end.pts)},baseMediaDecodeTime:we.videoTsToSeconds(f.baseMediaDecodeTime)};f.prependedContentDuration&&(h.prependedContentDuration=we.videoTsToSeconds(f.prependedContentDuration)),u.postMessage({action:"videoSegmentTimingInfo",videoSegmentTimingInfo:h})}),d.on("audioSegmentTimingInfo",function(f){const h={start:{decode:we.videoTsToSeconds(f.start.dts),presentation:we.videoTsToSeconds(f.start.pts)},end:{decode:we.videoTsToSeconds(f.end.dts),presentation:we.videoTsToSeconds(f.end.pts)},baseMediaDecodeTime:we.videoTsToSeconds(f.baseMediaDecodeTime)};f.prependedContentDuration&&(h.prependedContentDuration=we.videoTsToSeconds(f.prependedContentDuration)),u.postMessage({action:"audioSegmentTimingInfo",audioSegmentTimingInfo:h})}),d.on("id3Frame",function(f){u.postMessage({action:"id3Frame",id3Frame:f})}),d.on("caption",function(f){u.postMessage({action:"caption",caption:f})}),d.on("trackinfo",function(f){u.postMessage({action:"trackinfo",trackInfo:f})}),d.on("audioTimingInfo",function(f){u.postMessage({action:"audioTimingInfo",audioTimingInfo:{start:we.videoTsToSeconds(f.start),end:we.videoTsToSeconds(f.end)}})}),d.on("videoTimingInfo",function(f){u.postMessage({action:"videoTimingInfo",videoTimingInfo:{start:we.videoTsToSeconds(f.start),end:we.videoTsToSeconds(f.end)}})}),d.on("log",function(f){u.postMessage({action:"log",log:f})})};class rg{constructor(d,f){this.options=f||{},this.self=d,this.init()}init(){this.transmuxer&&this.transmuxer.dispose(),this.transmuxer=new iE.Transmuxer(this.options),ZE(this.self,this.transmuxer)}pushMp4Captions(d){this.captionParser||(this.captionParser=new wE,this.captionParser.init());const f=new Uint8Array(d.data,d.byteOffset,d.byteLength),h=this.captionParser.parse(f,d.trackIds,d.timescales);this.self.postMessage({action:"mp4Captions",captions:h&&h.captions||[],logs:h&&h.logs||[],data:f.buffer},[f.buffer])}probeMp4StartTime({timescales:d,data:f}){const h=Kc.startTime(d,f);this.self.postMessage({action:"probeMp4StartTime",startTime:h,data:f},[f.buffer])}probeMp4Tracks({data:d}){const f=Kc.tracks(d);this.self.postMessage({action:"probeMp4Tracks",tracks:f,data:d},[d.buffer])}probeEmsgID3({data:d,offset:f}){const h=Kc.getEmsgID3(d,f);this.self.postMessage({action:"probeEmsgID3",id3Frames:h,emsgData:d},[d.buffer])}probeTs({data:d,baseStartTime:f}){const h=typeof f=="number"&&!isNaN(f)?f*we.ONE_SECOND_IN_TS:void 0,m=JE.inspect(d,h);let y=null;m&&(y={hasVideo:m.video&&m.video.length===2||!1,hasAudio:m.audio&&m.audio.length===2||!1},y.hasVideo&&(y.videoStart=m.video[0].ptsTime),y.hasAudio&&(y.audioStart=m.audio[0].ptsTime)),this.self.postMessage({action:"probeTs",result:y,data:d},[d.buffer])}clearAllMp4Captions(){this.captionParser&&this.captionParser.clearAllCaptions()}clearParsedMp4Captions(){this.captionParser&&this.captionParser.clearParsedCaptions()}push(d){const f=new Uint8Array(d.data,d.byteOffset,d.byteLength);this.transmuxer.push(f)}reset(){this.transmuxer.reset()}setTimestampOffset(d){const f=d.timestampOffset||0;this.transmuxer.setBaseMediaDecodeTime(Math.round(we.secondsToVideoTs(f)))}setAudioAppendStart(d){this.transmuxer.setAudioAppendStart(Math.ceil(we.secondsToVideoTs(d.appendStart)))}setRemux(d){this.transmuxer.setRemux(d.remux)}flush(d){this.transmuxer.flush(),self.postMessage({action:"done",type:"transmuxed"})}endTimeline(){this.transmuxer.endTimeline(),self.postMessage({action:"endedtimeline",type:"transmuxed"})}alignGopsWith(d){this.transmuxer.alignGopsWith(d.gopsToAlignWith.slice())}}self.onmessage=function(u){if(u.data.action==="init"&&u.data.options){this.messageHandlers=new rg(self,u.data.options);return}this.messageHandlers||(this.messageHandlers=new rg(self)),u.data&&u.data.action&&u.data.action!=="init"&&this.messageHandlers[u.data.action]&&this.messageHandlers[u.data.action](u.data)}}));var YP=px(QP);const JP=(t,e,i)=>{const{type:n,initSegment:r,captions:s,captionStreams:a,metadata:o,videoFrameDtsTime:l,videoFramePtsTime:c}=t.data.segment;e.buffer.push({captions:s,captionStreams:a,metadata:o});const p=t.data.segment.boxes||{data:t.data.segment.data},g={type:n,data:new Uint8Array(p.data,p.data.byteOffset,p.data.byteLength),initSegment:new Uint8Array(r.data,r.byteOffset,r.byteLength)};typeof l<"u"&&(g.videoFrameDtsTime=l),typeof c<"u"&&(g.videoFramePtsTime=c),i(g)},ZP=({transmuxedData:t,callback:e})=>{t.buffer=[],e(t)},eI=(t,e)=>{e.gopInfo=t.data.gopInfo},yx=t=>{const{transmuxer:e,bytes:i,audioAppendStart:n,gopsToAlignWith:r,remux:s,onData:a,onTrackInfo:o,onAudioTimingInfo:l,onVideoTimingInfo:c,onVideoSegmentTimingInfo:p,onAudioSegmentTimingInfo:g,onId3:v,onCaptions:S,onDone:_,onEndedTimeline:w,onTransmuxerLog:I,isEndOfTimeline:x}=t,T={buffer:[]};let C=x;const k=L=>{e.currentTransmux===t&&(L.data.action==="data"&&JP(L,T,a),L.data.action==="trackinfo"&&o(L.data.trackInfo),L.data.action==="gopInfo"&&eI(L,T),L.data.action==="audioTimingInfo"&&l(L.data.audioTimingInfo),L.data.action==="videoTimingInfo"&&c(L.data.videoTimingInfo),L.data.action==="videoSegmentTimingInfo"&&p(L.data.videoSegmentTimingInfo),L.data.action==="audioSegmentTimingInfo"&&g(L.data.audioSegmentTimingInfo),L.data.action==="id3Frame"&&v([L.data.id3Frame],L.data.id3Frame.dispatchType),L.data.action==="caption"&&S(L.data.caption),L.data.action==="endedtimeline"&&(C=!1,w()),L.data.action==="log"&&I(L.data.log),L.data.type==="transmuxed"&&(C||(e.onmessage=null,ZP({transmuxedData:T,callback:_}),vx(e))))};if(e.onmessage=k,n&&e.postMessage({action:"setAudioAppendStart",appendStart:n}),Array.isArray(r)&&e.postMessage({action:"alignGopsWith",gopsToAlignWith:r}),typeof s<"u"&&e.postMessage({action:"setRemux",remux:s}),i.byteLength){const L=i instanceof ArrayBuffer?i:i.buffer,N=i instanceof ArrayBuffer?0:i.byteOffset;e.postMessage({action:"push",data:L,byteOffset:N,byteLength:i.byteLength},[L])}x&&e.postMessage({action:"endTimeline"}),e.postMessage({action:"flush"})},vx=t=>{t.currentTransmux=null,t.transmuxQueue.length&&(t.currentTransmux=t.transmuxQueue.shift(),typeof t.currentTransmux=="function"?t.currentTransmux():yx(t.currentTransmux))},Fy=(t,e)=>{t.postMessage({action:e}),vx(t)},_x=(t,e)=>{if(!e.currentTransmux){e.currentTransmux=t,Fy(e,t);return}e.transmuxQueue.push(Fy.bind(null,e,t))},tI=t=>{_x("reset",t)},iI=t=>{_x("endTimeline",t)},Tx=t=>{if(!t.transmuxer.currentTransmux){t.transmuxer.currentTransmux=t,yx(t);return}t.transmuxer.transmuxQueue.push(t)},nI=t=>{const e=new YP;e.currentTransmux=null,e.transmuxQueue=[];const i=e.terminate;return e.terminate=()=>(e.currentTransmux=null,e.transmuxQueue.length=0,i.call(e)),e.postMessage({action:"init",options:t}),e};var qd={reset:tI,endTimeline:iI,transmux:Tx,createTransmuxer:nI};const Fa=function(t){const e=t.transmuxer,i=t.endAction||t.action,n=t.callback,r=rn({},t,{endAction:null,transmuxer:null,callback:null}),s=a=>{a.data.action===i&&(e.removeEventListener("message",s),a.data.data&&(a.data.data=new Uint8Array(a.data.data,t.byteOffset||0,t.byteLength||a.data.data.byteLength),t.data&&(t.data=a.data.data)),n(a.data))};if(e.addEventListener("message",s),t.data){const a=t.data instanceof ArrayBuffer;r.byteOffset=a?0:t.data.byteOffset,r.byteLength=t.data.byteLength;const o=[a?t.data:t.data.buffer];e.postMessage(r,o)}else e.postMessage(r)},Di={FAILURE:2,TIMEOUT:-101,ABORTED:-102},ff=t=>{t.forEach(e=>{e.abort()})},rI=t=>({bandwidth:t.bandwidth,bytesReceived:t.bytesReceived||0,roundTripTime:t.roundTripTime||0}),sI=t=>{const e=t.target,n={bandwidth:1/0,bytesReceived:0,roundTripTime:Date.now()-e.requestTime||0};return n.bytesReceived=t.loaded,n.bandwidth=Math.floor(n.bytesReceived/n.roundTripTime*8*1e3),n},pm=(t,e)=>e.timedout?{status:e.status,message:"HLS request timed-out at URL: "+e.uri,code:Di.TIMEOUT,xhr:e}:e.aborted?{status:e.status,message:"HLS request aborted at URL: "+e.uri,code:Di.ABORTED,xhr:e}:t?{status:e.status,message:"HLS request errored at URL: "+e.uri,code:Di.FAILURE,xhr:e}:e.responseType==="arraybuffer"&&e.response.byteLength===0?{status:e.status,message:"Empty HLS response at URL: "+e.uri,code:Di.FAILURE,xhr:e}:null,Uy=(t,e,i)=>(n,r)=>{const s=r.response,a=pm(n,r);if(a)return i(a,t);if(s.byteLength!==16)return i({status:r.status,message:"Invalid HLS key at URL: "+r.uri,code:Di.FAILURE,xhr:r},t);const o=new DataView(s),l=new Uint32Array([o.getUint32(0),o.getUint32(4),o.getUint32(8),o.getUint32(12)]);for(let c=0;c{const i=Lp(t.map.bytes);if(i!=="mp4"){const n=t.map.resolvedUri||t.map.uri;return e({internal:!0,message:`Found unsupported ${i||"unknown"} container for initialization segment at URL: ${n}`,code:Di.FAILURE})}Fa({action:"probeMp4Tracks",data:t.map.bytes,transmuxer:t.transmuxer,callback:({tracks:n,data:r})=>(t.map.bytes=r,n.forEach(function(s){t.map.tracks=t.map.tracks||{},!t.map.tracks[s.type]&&(t.map.tracks[s.type]=s,typeof s.id=="number"&&s.timescale&&(t.map.timescales=t.map.timescales||{},t.map.timescales[s.id]=s.timescale))}),e(null))})},aI=({segment:t,finishProcessingFn:e})=>(i,n)=>{const r=pm(i,n);if(r)return e(r,t);const s=new Uint8Array(n.response);if(t.map.key)return t.map.encryptedBytes=s,e(null,t);t.map.bytes=s,xx(t,function(a){if(a)return a.xhr=n,a.status=n.status,e(a,t);e(null,t)})},oI=({segment:t,finishProcessingFn:e,responseType:i})=>(n,r)=>{const s=pm(n,r);if(s)return e(s,t);const a=i==="arraybuffer"||!r.responseText?r.response:XP(r.responseText.substring(t.lastReachedChar||0));return t.stats=rI(r),t.key?t.encryptedBytes=new Uint8Array(a):t.bytes=new Uint8Array(a),e(null,t)},lI=({segment:t,bytes:e,trackInfoFn:i,timingInfoFn:n,videoSegmentTimingInfoFn:r,audioSegmentTimingInfoFn:s,id3Fn:a,captionsFn:o,isEndOfTimeline:l,endedTimelineFn:c,dataFn:p,doneFn:g,onTransmuxerLog:v})=>{const S=t.map&&t.map.tracks||{},_=!!(S.audio&&S.video);let w=n.bind(null,t,"audio","start");const I=n.bind(null,t,"audio","end");let x=n.bind(null,t,"video","start");const T=n.bind(null,t,"video","end"),C=()=>Tx({bytes:e,transmuxer:t.transmuxer,audioAppendStart:t.audioAppendStart,gopsToAlignWith:t.gopsToAlignWith,remux:_,onData:k=>{k.type=k.type==="combined"?"video":k.type,p(t,k)},onTrackInfo:k=>{i&&(_&&(k.isMuxed=!0),i(t,k))},onAudioTimingInfo:k=>{w&&typeof k.start<"u"&&(w(k.start),w=null),I&&typeof k.end<"u"&&I(k.end)},onVideoTimingInfo:k=>{x&&typeof k.start<"u"&&(x(k.start),x=null),T&&typeof k.end<"u"&&T(k.end)},onVideoSegmentTimingInfo:k=>{r(k)},onAudioSegmentTimingInfo:k=>{s(k)},onId3:(k,L)=>{a(t,k,L)},onCaptions:k=>{o(t,[k])},isEndOfTimeline:l,onEndedTimeline:()=>{c()},onTransmuxerLog:v,onDone:k=>{g&&(k.type=k.type==="combined"?"video":k.type,g(null,t,k))}});Fa({action:"probeTs",transmuxer:t.transmuxer,data:e,baseStartTime:t.baseStartTime,callback:k=>{t.bytes=e=k.data;const L=k.result;L&&(i(t,{hasAudio:L.hasAudio,hasVideo:L.hasVideo,isMuxed:_}),i=null),C()}})},Sx=({segment:t,bytes:e,trackInfoFn:i,timingInfoFn:n,videoSegmentTimingInfoFn:r,audioSegmentTimingInfoFn:s,id3Fn:a,captionsFn:o,isEndOfTimeline:l,endedTimelineFn:c,dataFn:p,doneFn:g,onTransmuxerLog:v})=>{let S=new Uint8Array(e);if(L3(S)){t.isFmp4=!0;const{tracks:_}=t.map,w={isFmp4:!0,hasVideo:!!_.video,hasAudio:!!_.audio};_.audio&&_.audio.codec&&_.audio.codec!=="enca"&&(w.audioCodec=_.audio.codec),_.video&&_.video.codec&&_.video.codec!=="encv"&&(w.videoCodec=_.video.codec),_.video&&_.audio&&(w.isMuxed=!0),i(t,w);const I=(x,T)=>{p(t,{data:S,type:w.hasAudio&&!w.isMuxed?"audio":"video"}),T&&T.length&&a(t,T),x&&x.length&&o(t,x),g(null,t,{})};Fa({action:"probeMp4StartTime",timescales:t.map.timescales,data:S,transmuxer:t.transmuxer,callback:({data:x,startTime:T})=>{e=x.buffer,t.bytes=S=x,w.hasAudio&&!w.isMuxed&&n(t,"audio","start",T),w.hasVideo&&n(t,"video","start",T),Fa({action:"probeEmsgID3",data:S,transmuxer:t.transmuxer,offset:T,callback:({emsgData:C,id3Frames:k})=>{if(e=C.buffer,t.bytes=S=C,!_.video||!C.byteLength||!t.transmuxer){I(void 0,k);return}Fa({action:"pushMp4Captions",endAction:"mp4Captions",transmuxer:t.transmuxer,data:S,timescales:t.map.timescales,trackIds:[_.video.id],callback:L=>{e=L.data.buffer,t.bytes=S=L.data,L.logs.forEach(function(N){v(ve(N,{stream:"mp4CaptionParser"}))}),I(L.captions,k)}})}})}});return}if(!t.transmuxer){g(null,t,{});return}if(typeof t.container>"u"&&(t.container=Lp(S)),t.container!=="ts"&&t.container!=="aac"){i(t,{hasAudio:!1,hasVideo:!1}),g(null,t,{});return}lI({segment:t,bytes:e,trackInfoFn:i,timingInfoFn:n,videoSegmentTimingInfoFn:r,audioSegmentTimingInfoFn:s,id3Fn:a,captionsFn:o,isEndOfTimeline:l,endedTimelineFn:c,dataFn:p,doneFn:g,onTransmuxerLog:v})},Ex=function({id:t,key:e,encryptedBytes:i,decryptionWorker:n},r){const s=o=>{if(o.data.source===t){n.removeEventListener("message",s);const l=o.data.decrypted;r(new Uint8Array(l.bytes,l.byteOffset,l.byteLength))}};n.addEventListener("message",s);let a;e.bytes.slice?a=e.bytes.slice():a=new Uint32Array(Array.prototype.slice.call(e.bytes)),n.postMessage(lx({source:t,encrypted:i,key:a,iv:e.iv}),[i.buffer,a.buffer])},uI=({decryptionWorker:t,segment:e,trackInfoFn:i,timingInfoFn:n,videoSegmentTimingInfoFn:r,audioSegmentTimingInfoFn:s,id3Fn:a,captionsFn:o,isEndOfTimeline:l,endedTimelineFn:c,dataFn:p,doneFn:g,onTransmuxerLog:v})=>{Ex({id:e.requestId,key:e.key,encryptedBytes:e.encryptedBytes,decryptionWorker:t},S=>{e.bytes=S,Sx({segment:e,bytes:e.bytes,trackInfoFn:i,timingInfoFn:n,videoSegmentTimingInfoFn:r,audioSegmentTimingInfoFn:s,id3Fn:a,captionsFn:o,isEndOfTimeline:l,endedTimelineFn:c,dataFn:p,doneFn:g,onTransmuxerLog:v})})},cI=({activeXhrs:t,decryptionWorker:e,trackInfoFn:i,timingInfoFn:n,videoSegmentTimingInfoFn:r,audioSegmentTimingInfoFn:s,id3Fn:a,captionsFn:o,isEndOfTimeline:l,endedTimelineFn:c,dataFn:p,doneFn:g,onTransmuxerLog:v})=>{let S=0,_=!1;return(w,I)=>{if(!_){if(w)return _=!0,ff(t),g(w,I);if(S+=1,S===t.length){const x=function(){if(I.encryptedBytes)return uI({decryptionWorker:e,segment:I,trackInfoFn:i,timingInfoFn:n,videoSegmentTimingInfoFn:r,audioSegmentTimingInfoFn:s,id3Fn:a,captionsFn:o,isEndOfTimeline:l,endedTimelineFn:c,dataFn:p,doneFn:g,onTransmuxerLog:v});Sx({segment:I,bytes:I.bytes,trackInfoFn:i,timingInfoFn:n,videoSegmentTimingInfoFn:r,audioSegmentTimingInfoFn:s,id3Fn:a,captionsFn:o,isEndOfTimeline:l,endedTimelineFn:c,dataFn:p,doneFn:g,onTransmuxerLog:v})};if(I.endOfAllRequests=Date.now(),I.map&&I.map.encryptedBytes&&!I.map.bytes)return Ex({decryptionWorker:e,id:I.requestId+"-init",encryptedBytes:I.map.encryptedBytes,key:I.map.key},T=>{I.map.bytes=T,xx(I,C=>{if(C)return ff(t),g(C,I);x()})});x()}}}},dI=({loadendState:t,abortFn:e})=>i=>{i.target.aborted&&e&&!t.calledAbortFn&&(e(),t.calledAbortFn=!0)},hI=({segment:t,progressFn:e,trackInfoFn:i,timingInfoFn:n,videoSegmentTimingInfoFn:r,audioSegmentTimingInfoFn:s,id3Fn:a,captionsFn:o,isEndOfTimeline:l,endedTimelineFn:c,dataFn:p})=>g=>{if(!g.target.aborted)return t.stats=ve(t.stats,sI(g)),!t.stats.firstBytesReceivedAt&&t.stats.bytesReceived&&(t.stats.firstBytesReceivedAt=Date.now()),e(g,t)},fI=({xhr:t,xhrOptions:e,decryptionWorker:i,segment:n,abortFn:r,progressFn:s,trackInfoFn:a,timingInfoFn:o,videoSegmentTimingInfoFn:l,audioSegmentTimingInfoFn:c,id3Fn:p,captionsFn:g,isEndOfTimeline:v,endedTimelineFn:S,dataFn:_,doneFn:w,onTransmuxerLog:I})=>{const x=[],T=cI({activeXhrs:x,decryptionWorker:i,trackInfoFn:a,timingInfoFn:o,videoSegmentTimingInfoFn:l,audioSegmentTimingInfoFn:c,id3Fn:p,captionsFn:g,isEndOfTimeline:v,endedTimelineFn:S,dataFn:_,doneFn:w,onTransmuxerLog:I});if(n.key&&!n.key.bytes){const F=[n.key];n.map&&!n.map.bytes&&n.map.key&&n.map.key.resolvedUri===n.key.resolvedUri&&F.push(n.map.key);const $=ve(e,{uri:n.key.resolvedUri,responseType:"arraybuffer"}),K=Uy(n,F,T),Y=t($,K);x.push(Y)}if(n.map&&!n.map.bytes){if(n.map.key&&(!n.key||n.key.resolvedUri!==n.map.key.resolvedUri)){const ne=ve(e,{uri:n.map.key.resolvedUri,responseType:"arraybuffer"}),he=Uy(n,[n.map.key],T),Q=t(ne,he);x.push(Q)}const $=ve(e,{uri:n.map.resolvedUri,responseType:"arraybuffer",headers:df(n.map)}),K=aI({segment:n,finishProcessingFn:T}),Y=t($,K);x.push(Y)}const C=ve(e,{uri:n.part&&n.part.resolvedUri||n.resolvedUri,responseType:"arraybuffer",headers:df(n)}),k=oI({segment:n,finishProcessingFn:T,responseType:C.responseType}),L=t(C,k);L.addEventListener("progress",hI({segment:n,progressFn:s,trackInfoFn:a,timingInfoFn:o,videoSegmentTimingInfoFn:l,audioSegmentTimingInfoFn:c,id3Fn:p,captionsFn:g,isEndOfTimeline:v,endedTimelineFn:S,dataFn:_})),x.push(L);const N={};return x.forEach(F=>{F.addEventListener("loadend",dI({loadendState:N,abortFn:r}))}),()=>ff(x)},pI=si("CodecUtils"),mI=function(t){const e=t.attributes||{};if(e.CODECS)return Si(e.CODECS)},bx=(t,e)=>{const i=e.attributes||{};return t&&t.mediaGroups&&t.mediaGroups.AUDIO&&i.AUDIO&&t.mediaGroups.AUDIO[i.AUDIO]},gI=(t,e)=>{if(!bx(t,e))return!0;const i=e.attributes||{},n=t.mediaGroups.AUDIO[i.AUDIO];for(const r in n)if(!n[r].uri&&!n[r].playlists)return!0;return!1},Ru=function(t){const e={};return t.forEach(({mediaType:i,type:n,details:r})=>{e[i]=e[i]||[],e[i].push(U1(`${n}${r}`))}),Object.keys(e).forEach(function(i){if(e[i].length>1){pI(`multiple ${i} codecs found as attributes: ${e[i].join(", ")}. Setting playlist codecs to null so that we wait for mux.js to probe segments for real codecs.`),e[i]=null;return}e[i]=e[i][0]}),e},jy=function(t){let e=0;return t.audio&&e++,t.video&&e++,e},Ua=function(t,e){const i=e.attributes||{},n=Ru(mI(e)||[]);if(bx(t,e)&&!n.audio&&!gI(t,e)){const r=Ru(NA(t,i.AUDIO)||[]);r.audio&&(n.audio=r.audio)}return n},Sl=si("PlaylistSelector"),$y=function(t){if(!t||!t.playlist)return;const e=t.playlist;return JSON.stringify({id:e.id,bandwidth:t.bandwidth,width:t.width,height:t.height,codecs:e.attributes&&e.attributes.CODECS||""})},Mu=function(t,e){if(!t)return"";const i=A.getComputedStyle(t);return i?i[e]:""},os=function(t,e){const i=t.slice();t.sort(function(n,r){const s=e(n,r);return s===0?i.indexOf(n)-i.indexOf(r):s})},mm=function(t,e){let i,n;return t.attributes.BANDWIDTH&&(i=t.attributes.BANDWIDTH),i=i||A.Number.MAX_VALUE,e.attributes.BANDWIDTH&&(n=e.attributes.BANDWIDTH),n=n||A.Number.MAX_VALUE,i-n},yI=function(t,e){let i,n;return t.attributes.RESOLUTION&&t.attributes.RESOLUTION.width&&(i=t.attributes.RESOLUTION.width),i=i||A.Number.MAX_VALUE,e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width&&(n=e.attributes.RESOLUTION.width),n=n||A.Number.MAX_VALUE,i===n&&t.attributes.BANDWIDTH&&e.attributes.BANDWIDTH?t.attributes.BANDWIDTH-e.attributes.BANDWIDTH:i-n};let Cx=function(t,e,i,n,r,s){if(!t)return;const a={bandwidth:e,width:i,height:n,limitRenditionByPlayerDimensions:r};let o=t.playlists;Dt.isAudioOnly(t)&&(o=s.getAudioTrackPlaylists_(),a.audioOnly=!0);let l=o.map(L=>{let N;const F=L.attributes&&L.attributes.RESOLUTION&&L.attributes.RESOLUTION.width,$=L.attributes&&L.attributes.RESOLUTION&&L.attributes.RESOLUTION.height;return N=L.attributes&&L.attributes.BANDWIDTH,N=N||A.Number.MAX_VALUE,{bandwidth:N,width:F,height:$,playlist:L}});os(l,(L,N)=>L.bandwidth-N.bandwidth),l=l.filter(L=>!Dt.isIncompatible(L.playlist));let c=l.filter(L=>Dt.isEnabled(L.playlist));c.length||(c=l.filter(L=>!Dt.isDisabled(L.playlist)));const p=c.filter(L=>L.bandwidth*Qe.BANDWIDTH_VARIANCEL.bandwidth===g.bandwidth)[0];if(r===!1){const L=v||c[0]||l[0];if(L&&L.playlist){let N="sortedPlaylistReps";return v&&(N="bandwidthBestRep"),c[0]&&(N="enabledPlaylistReps"),Sl(`choosing ${$y(L)} using ${N} with options`,a),L.playlist}return Sl("could not choose a playlist with options",a),null}const S=p.filter(L=>L.width&&L.height);os(S,(L,N)=>L.width-N.width);const _=S.filter(L=>L.width===i&&L.height===n);g=_[_.length-1];const w=_.filter(L=>L.bandwidth===g.bandwidth)[0];let I,x,T;w||(I=S.filter(L=>L.width>i||L.height>n),x=I.filter(L=>L.width===I[0].width&&L.height===I[0].height),g=x[x.length-1],T=x.filter(L=>L.bandwidth===g.bandwidth)[0]);let C;if(s.leastPixelDiffSelector){const L=S.map(N=>(N.pixelDiff=Math.abs(N.width-i)+Math.abs(N.height-n),N));os(L,(N,F)=>N.pixelDiff===F.pixelDiff?F.bandwidth-N.bandwidth:N.pixelDiff-F.pixelDiff),C=L[0]}const k=C||T||w||v||c[0]||l[0];if(k&&k.playlist){let L="sortedPlaylistReps";return C?L="leastPixelDiffRep":T?L="resolutionPlusOneRep":w?L="resolutionBestRep":v?L="bandwidthBestRep":c[0]&&(L="enabledPlaylistReps"),Sl(`choosing ${$y(k)} using ${L} with options`,a),k.playlist}return Sl("could not choose a playlist with options",a),null};const Vy=function(){const t=this.useDevicePixelRatio&&A.devicePixelRatio||1;return Cx(this.playlists.main,this.systemBandwidth,parseInt(Mu(this.tech_.el(),"width"),10)*t,parseInt(Mu(this.tech_.el(),"height"),10)*t,this.limitRenditionByPlayerDimensions,this.playlistController_)},vI=function(t){let e=-1,i=-1;if(t<0||t>1)throw new Error("Moving average bandwidth decay must be between 0 and 1.");return function(){const n=this.useDevicePixelRatio&&A.devicePixelRatio||1;return e<0&&(e=this.systemBandwidth,i=this.systemBandwidth),this.systemBandwidth>0&&this.systemBandwidth!==i&&(e=t*this.systemBandwidth+(1-t)*e,i=this.systemBandwidth),Cx(this.playlists.main,e,parseInt(Mu(this.tech_.el(),"width"),10)*n,parseInt(Mu(this.tech_.el(),"height"),10)*n,this.limitRenditionByPlayerDimensions,this.playlistController_)}},_I=function(t){const{main:e,currentTime:i,bandwidth:n,duration:r,segmentDuration:s,timeUntilRebuffer:a,currentTimeline:o,syncController:l}=t,c=e.playlists.filter(_=>!Dt.isIncompatible(_));let p=c.filter(Dt.isEnabled);p.length||(p=c.filter(_=>!Dt.isDisabled(_)));const v=p.filter(Dt.hasAttribute.bind(null,"BANDWIDTH")).map(_=>{const I=l.getSyncPoint(_,r,o,i)?1:2,T=Dt.estimateSegmentRequestTime(s,n,_)*I-a;return{playlist:_,rebufferingImpact:T}}),S=v.filter(_=>_.rebufferingImpact<=0);return os(S,(_,w)=>mm(w.playlist,_.playlist)),S.length?S[0]:(os(v,(_,w)=>_.rebufferingImpact-w.rebufferingImpact),v[0]||null)},TI=function(){const t=this.playlists.main.playlists.filter(Dt.isEnabled);return os(t,(i,n)=>mm(i,n)),t.filter(i=>!!Ua(this.playlists.main,i).video)[0]||null},xI=t=>{let e=0,i;return t.bytes&&(i=new Uint8Array(t.bytes),t.segments.forEach(n=>{i.set(n,e),e+=n.byteLength})),i},SI=function(t,e,i){if(!t[i]){e.trigger({type:"usage",name:"vhs-608"});let n=i;/^cc708_/.test(i)&&(n="SERVICE"+i.split("_")[1]);const r=e.textTracks().getTrackById(n);if(r)t[i]=r;else{const s=e.options_.vhs&&e.options_.vhs.captionServices||{};let a=i,o=i,l=!1;const c=s[n];c&&(a=c.label,o=c.language,l=c.default),t[i]=e.addRemoteTextTrack({kind:"captions",id:n,default:l,label:a,language:o},!1).track}}},EI=function({inbandTextTracks:t,captionArray:e,timestampOffset:i}){if(!e)return;const n=A.WebKitDataCue||A.VTTCue;e.forEach(r=>{const s=r.stream;r.content?r.content.forEach(a=>{const o=new n(r.startTime+i,r.endTime+i,a.text);o.line=a.line,o.align="left",o.position=a.position,o.positionAlign="line-left",t[s].addCue(o)}):t[s].addCue(new n(r.startTime+i,r.endTime+i,r.text))})},bI=function(t){Object.defineProperties(t.frame,{id:{get(){return M.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),t.value.key}},value:{get(){return M.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),t.value.data}},privateData:{get(){return M.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),t.value.data}}})},CI=({inbandTextTracks:t,metadataArray:e,timestampOffset:i,videoDuration:n})=>{if(!e)return;const r=A.WebKitDataCue||A.VTTCue,s=t.metadataTrack_;if(!s||(e.forEach(p=>{const g=p.cueTime+i;typeof g!="number"||A.isNaN(g)||g<0||!(g<1/0)||!p.frames||!p.frames.length||p.frames.forEach(v=>{const S=new r(g,g,v.value||v.url||v.data||"");S.frame=v,S.value=v,bI(S),s.addCue(S)})}),!s.cues||!s.cues.length))return;const a=s.cues,o=[];for(let p=0;p{const v=p[g.startTime]||[];return v.push(g),p[g.startTime]=v,p},{}),c=Object.keys(l).sort((p,g)=>Number(p)-Number(g));c.forEach((p,g)=>{const v=l[p],S=isFinite(n)?n:0,_=Number(c[g+1])||S;v.forEach(w=>{w.endTime=_})})},wI={id:"ID",class:"CLASS",startDate:"START-DATE",duration:"DURATION",endDate:"END-DATE",endOnNext:"END-ON-NEXT",plannedDuration:"PLANNED-DURATION",scte35Out:"SCTE35-OUT",scte35In:"SCTE35-IN"},DI=new Set(["id","class","startDate","duration","endDate","endOnNext","startTime","endTime","processDateRange"]),AI=({inbandTextTracks:t,dateRanges:e})=>{const i=t.metadataTrack_;if(!i)return;const n=A.WebKitDataCue||A.VTTCue;e.forEach(r=>{for(const s of Object.keys(r)){if(DI.has(s))continue;const a=new n(r.startTime,r.endTime,"");a.id=r.id,a.type="com.apple.quicktime.HLS",a.value={key:wI[s],data:r[s]},(s==="scte35Out"||s==="scte35In")&&(a.value.data=new Uint8Array(a.value.data.match(/[\da-f]{2}/gi)).buffer),i.addCue(a)}r.processDateRange()})},zy=(t,e,i)=>{t.metadataTrack_||(t.metadataTrack_=i.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track,M.browser.IS_ANY_SAFARI||(t.metadataTrack_.inBandMetadataTrackDispatchType=e))},Ea=function(t,e,i){let n,r;if(i&&i.cues)for(n=i.cues.length;n--;)r=i.cues[n],r.startTime>=t&&r.endTime<=e&&i.removeCue(r)},kI=function(t){const e=t.cues;if(!e)return;const i={};for(let n=e.length-1;n>=0;n--){const r=e[n],s=`${r.startTime}-${r.endTime}-${r.text}`;i[s]?t.removeCue(r):i[s]=r}},PI=(t,e,i)=>{if(typeof e>"u"||e===null||!t.length)return[];const n=Math.ceil((e-i+3)*xu.ONE_SECOND_IN_TS);let r;for(r=0;rn);r++);return t.slice(r)},II=(t,e,i)=>{if(!e.length)return t;if(i)return e.slice();const n=e[0].pts;let r=0;for(r;r=n);r++);return t.slice(0,r).concat(e)},LI=(t,e,i,n)=>{const r=Math.ceil((e-n)*xu.ONE_SECOND_IN_TS),s=Math.ceil((i-n)*xu.ONE_SECOND_IN_TS),a=t.slice();let o=t.length;for(;o--&&!(t[o].pts<=s););if(o===-1)return a;let l=o+1;for(;l--&&!(t[l].pts<=r););return l=Math.max(l,0),a.splice(l,o-l+1),a},OI=function(t,e){if(!t&&!e||!t&&e||t&&!e)return!1;if(t===e)return!0;const i=Object.keys(t).sort(),n=Object.keys(e).sort();if(i.length!==n.length)return!1;for(let r=0;ri))return s}return n.length===0?0:n[n.length-1]},fa=1,RI=500,Hy=t=>typeof t=="number"&&isFinite(t),El=1/60,MI=(t,e,i)=>t!=="main"||!e||!i?null:!i.hasAudio&&!i.hasVideo?"Neither audio nor video found in segment.":e.hasVideo&&!i.hasVideo?"Only audio found in segment when we expected video. We can't switch to audio only from a stream that had video. To get rid of this message, please add codec information to the manifest.":!e.hasVideo&&i.hasVideo?"Video found in segment when we expected only audio. We can't switch to a stream with video from an audio only stream. To get rid of this message, please add codec information to the manifest.":null,BI=(t,e,i)=>{let n=e-Qe.BACK_BUFFER_LENGTH;t.length&&(n=Math.max(n,t.start(0)));const r=e-i;return Math.min(r,n)},Nr=t=>{const{startOfSegment:e,duration:i,segment:n,part:r,playlist:{mediaSequence:s,id:a,segments:o=[]},mediaIndex:l,partIndex:c,timeline:p}=t,g=o.length-1;let v="mediaIndex/partIndex increment";t.getMediaInfoForTime?v=`getMediaInfoForTime (${t.getMediaInfoForTime})`:t.isSyncRequest&&(v="getSyncSegmentCandidate (isSyncRequest)"),t.independent&&(v+=` with independent ${t.independent}`);const S=typeof c=="number",_=t.segment.uri?"segment":"pre-segment",w=S?XT({preloadSegment:n})-1:0;return`${_} [${s+l}/${s+g}]`+(S?` part [${c}/${w}]`:"")+` segment start/end [${n.start} => ${n.end}]`+(S?` part start/end [${r.start} => ${r.end}]`:"")+` startOfSegment [${e}] duration [${i}] timeline [${p}] selected by [${v}] playlist [${a}]`},qy=t=>`${t}TimingInfo`,Wy=(t,e)=>t.length?t.end(t.length-1):e,FI=({segmentTimeline:t,currentTimeline:e,startOfSegment:i,buffered:n,calculateTimestampOffsetForEachSegment:r,overrideCheck:s})=>r?Wy(n,i):!s&&t===e?null:t{if(e===i)return!1;if(n==="audio"){const s=t.lastTimelineChange({type:"main"});return!s||s.to!==i}if(n==="main"&&r){const s=t.pendingTimelineChange({type:"audio"});return!(s&&s.to===i)}return!1},UI=t=>{let e=0;return["video","audio"].forEach(function(i){const n=t[`${i}TimingInfo`];if(!n)return;const{start:r,end:s}=n;let a;typeof r=="bigint"||typeof s=="bigint"?a=A.BigInt(s)-A.BigInt(r):typeof r=="number"&&typeof s=="number"&&(a=s-r),typeof a<"u"&&a>e&&(e=a)}),typeof e=="bigint"&&et?Math.round(t)>e+Bn:!1,jI=(t,e)=>{if(e!=="hls")return null;const i=UI({audioTimingInfo:t.audioTimingInfo,videoTimingInfo:t.videoTimingInfo});if(!i)return null;const n=t.playlist.targetDuration,r=Xy({segmentDuration:i,maxDuration:n*2}),s=Xy({segmentDuration:i,maxDuration:n}),a=`Segment with index ${t.mediaIndex} from playlist ${t.playlist.id} has a duration of ${i} when the reported duration is ${t.duration} and the target duration is ${n}. For HLS content, a duration in excess of the target duration may result in playback issues. See the HLS specification section on EXT-X-TARGETDURATION for more details: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.3.1`;return r||s?{severity:r?"warn":"info",message:a}:null};class pf extends M.EventTarget{constructor(e,i={}){if(super(),!e)throw new TypeError("Initialization settings are required");if(typeof e.currentTime!="function")throw new TypeError("No currentTime getter specified");if(!e.mediaSource)throw new TypeError("No MediaSource specified");this.bandwidth=e.bandwidth,this.throughput={rate:0,count:0},this.roundTrip=NaN,this.resetStats_(),this.mediaIndex=null,this.partIndex=null,this.hasPlayed_=e.hasPlayed,this.currentTime_=e.currentTime,this.seekable_=e.seekable,this.seeking_=e.seeking,this.duration_=e.duration,this.mediaSource_=e.mediaSource,this.vhs_=e.vhs,this.loaderType_=e.loaderType,this.currentMediaInfo_=void 0,this.startingMediaInfo_=void 0,this.segmentMetadataTrack_=e.segmentMetadataTrack,this.goalBufferLength_=e.goalBufferLength,this.sourceType_=e.sourceType,this.sourceUpdater_=e.sourceUpdater,this.inbandTextTracks_=e.inbandTextTracks,this.state_="INIT",this.timelineChangeController_=e.timelineChangeController,this.shouldSaveSegmentTimingInfo_=!0,this.parse708captions_=e.parse708captions,this.useDtsForTimestampOffset_=e.useDtsForTimestampOffset,this.calculateTimestampOffsetForEachSegment_=e.calculateTimestampOffsetForEachSegment,this.captionServices_=e.captionServices,this.exactManifestTimings=e.exactManifestTimings,this.addMetadataToTextTrack=e.addMetadataToTextTrack,this.checkBufferTimeout_=null,this.error_=void 0,this.currentTimeline_=-1,this.pendingSegment_=null,this.xhrOptions_=null,this.pendingSegments_=[],this.audioDisabled_=!1,this.isPendingTimestampOffset_=!1,this.gopBuffer_=[],this.timeMapping_=0,this.safeAppend_=!1,this.appendInitSegment_={audio:!0,video:!0},this.playlistOfLastInitSegment_={audio:null,video:null},this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_={id3:[],caption:[]},this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=null,this.activeInitSegmentId_=null,this.initSegments_={},this.cacheEncryptionKeys_=e.cacheEncryptionKeys,this.keyCache_={},this.decrypter_=e.decrypter,this.syncController_=e.syncController,this.syncPoint_={segmentIndex:0,time:0},this.transmuxer_=this.createTransmuxer_(),this.triggerSyncInfoUpdate_=()=>this.trigger("syncinfoupdate"),this.syncController_.on("syncinfoupdate",this.triggerSyncInfoUpdate_),this.mediaSource_.addEventListener("sourceopen",()=>{this.isEndOfStream_()||(this.ended_=!1)}),this.fetchAtBuffer_=!1,this.replaceSegmentsUntil_=-1,this.logger_=si(`SegmentLoader[${this.loaderType_}]`),Object.defineProperty(this,"state",{get(){return this.state_},set(n){n!==this.state_&&(this.logger_(`${this.state_} -> ${n}`),this.state_=n,this.trigger("statechange"))}}),this.sourceUpdater_.on("ready",()=>{this.hasEnoughInfoToAppend_()&&this.processCallQueue_()}),this.loaderType_==="main"&&this.timelineChangeController_.on("pendingtimelinechange",()=>{this.hasEnoughInfoToAppend_()&&this.processCallQueue_()}),this.loaderType_==="audio"&&this.timelineChangeController_.on("timelinechange",()=>{this.hasEnoughInfoToLoad_()&&this.processLoadQueue_(),this.hasEnoughInfoToAppend_()&&this.processCallQueue_()})}createTransmuxer_(){return qd.createTransmuxer({remux:!1,alignGopsAtEnd:this.safeAppend_,keepOriginalTimestamps:!0,parse708captions:this.parse708captions_,captionServices:this.captionServices_})}resetStats_(){this.mediaBytesTransferred=0,this.mediaRequests=0,this.mediaRequestsAborted=0,this.mediaRequestsTimedout=0,this.mediaRequestsErrored=0,this.mediaTransferDuration=0,this.mediaSecondsLoaded=0,this.mediaAppends=0}dispose(){this.trigger("dispose"),this.state="DISPOSED",this.pause(),this.abort_(),this.transmuxer_&&this.transmuxer_.terminate(),this.resetStats_(),this.checkBufferTimeout_&&A.clearTimeout(this.checkBufferTimeout_),this.syncController_&&this.triggerSyncInfoUpdate_&&this.syncController_.off("syncinfoupdate",this.triggerSyncInfoUpdate_),this.off()}setAudio(e){this.audioDisabled_=!e,e?this.appendInitSegment_.audio=!0:this.sourceUpdater_.removeAudio(0,this.duration_())}abort(){if(this.state!=="WAITING"){this.pendingSegment_&&(this.pendingSegment_=null);return}this.abort_(),this.state="READY",this.paused()||this.monitorBuffer_()}abort_(){this.pendingSegment_&&this.pendingSegment_.abortRequests&&this.pendingSegment_.abortRequests(),this.pendingSegment_=null,this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_.id3=[],this.metadataQueue_.caption=[],this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_),this.waitingOnRemove_=!1,A.clearTimeout(this.quotaExceededErrorRetryTimeout_),this.quotaExceededErrorRetryTimeout_=null}checkForAbort_(e){return this.state==="APPENDING"&&!this.pendingSegment_?(this.state="READY",!0):!this.pendingSegment_||this.pendingSegment_.requestId!==e}error(e){return typeof e<"u"&&(this.logger_("error occurred:",e),this.error_=e),this.pendingSegment_=null,this.error_}endOfStream(){this.ended_=!0,this.transmuxer_&&qd.reset(this.transmuxer_),this.gopBuffer_.length=0,this.pause(),this.trigger("ended")}buffered_(){const e=this.getMediaInfo_();if(!this.sourceUpdater_||!e)return ot();if(this.loaderType_==="main"){const{hasAudio:i,hasVideo:n,isMuxed:r}=e;if(n&&i&&!this.audioDisabled_&&!r)return this.sourceUpdater_.buffered();if(n)return this.sourceUpdater_.videoBuffered()}return this.sourceUpdater_.audioBuffered()}initSegmentForMap(e,i=!1){if(!e)return null;const n=Nu(e);let r=this.initSegments_[n];return i&&!r&&e.bytes&&(this.initSegments_[n]=r={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:e.bytes,tracks:e.tracks,timescales:e.timescales}),r||e}segmentKey(e,i=!1){if(!e)return null;const n=ux(e);let r=this.keyCache_[n];this.cacheEncryptionKeys_&&i&&!r&&e.bytes&&(this.keyCache_[n]=r={resolvedUri:e.resolvedUri,bytes:e.bytes});const s={resolvedUri:(r||e).resolvedUri};return r&&(s.bytes=r.bytes),s}couldBeginLoading_(){return this.playlist_&&!this.paused()}load(){if(this.monitorBuffer_(),!!this.playlist_){if(this.state==="INIT"&&this.couldBeginLoading_())return this.init_();!this.couldBeginLoading_()||this.state!=="READY"&&this.state!=="INIT"||(this.state="READY")}}init_(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}playlist(e,i={}){if(!e)return;const n=this.playlist_,r=this.pendingSegment_;this.playlist_=e,this.xhrOptions_=i,this.state==="INIT"&&(e.syncInfo={mediaSequence:e.mediaSequence,time:0},this.loaderType_==="main"&&this.syncController_.setDateTimeMappingForStart(e));let s=null;if(n&&(n.id?s=n.id:n.uri&&(s=n.uri)),this.logger_(`playlist update [${s} => ${e.id||e.uri}]`),this.trigger("syncinfoupdate"),this.state==="INIT"&&this.couldBeginLoading_())return this.init_();if(!n||n.uri!==e.uri){this.mediaIndex!==null&&(!e.endList&&typeof e.partTargetDuration=="number"?this.resetLoader():this.resyncLoader()),this.currentMediaInfo_=void 0,this.trigger("playlistupdate");return}const a=e.mediaSequence-n.mediaSequence;if(this.logger_(`live window shift [${a}]`),this.mediaIndex!==null)if(this.mediaIndex-=a,this.mediaIndex<0)this.mediaIndex=null,this.partIndex=null;else{const o=this.playlist_.segments[this.mediaIndex];if(this.partIndex&&(!o.parts||!o.parts.length||!o.parts[this.partIndex])){const l=this.mediaIndex;this.logger_(`currently processing part (index ${this.partIndex}) no longer exists.`),this.resetLoader(),this.mediaIndex=l}}r&&(r.mediaIndex-=a,r.mediaIndex<0?(r.mediaIndex=null,r.partIndex=null):(r.mediaIndex>=0&&(r.segment=e.segments[r.mediaIndex]),r.partIndex>=0&&r.segment.parts&&(r.part=r.segment.parts[r.partIndex]))),this.syncController_.saveExpiredSegmentInfo(n,e)}pause(){this.checkBufferTimeout_&&(A.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null)}paused(){return this.checkBufferTimeout_===null}resetLoaderProperties(){this.ended_=!1,this.activeInitSegmentId_=null,this.appendInitSegment_={audio:!0,video:!0}}resetEverything(e){this.resetLoaderProperties(),this.resetLoader(),this.remove(0,1/0,e),this.transmuxer_&&(this.transmuxer_.postMessage({action:"clearAllMp4Captions"}),this.transmuxer_.postMessage({action:"reset"}))}resetLoader(){this.fetchAtBuffer_=!1,this.resyncLoader()}resyncLoader(){this.transmuxer_&&qd.reset(this.transmuxer_),this.mediaIndex=null,this.partIndex=null,this.syncPoint_=null,this.isPendingTimestampOffset_=!1,this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_.id3=[],this.metadataQueue_.caption=[],this.abort(),this.transmuxer_&&this.transmuxer_.postMessage({action:"clearParsedMp4Captions"})}remove(e,i,n=()=>{},r=!1){if(i===1/0&&(i=this.duration_()),i<=e){this.logger_("skipping remove because end ${end} is <= start ${start}");return}if(!this.sourceUpdater_||!this.getMediaInfo_()){this.logger_("skipping remove because no source updater or starting media info");return}let s=1;const a=()=>{s--,s===0&&n()};(r||!this.audioDisabled_)&&(s++,this.sourceUpdater_.removeAudio(e,i,a)),(r||this.loaderType_==="main")&&(this.gopBuffer_=LI(this.gopBuffer_,e,i,this.timeMapping_),s++,this.sourceUpdater_.removeVideo(e,i,a));for(const o in this.inbandTextTracks_)Ea(e,i,this.inbandTextTracks_[o]);Ea(e,i,this.segmentMetadataTrack_),a()}monitorBuffer_(){this.checkBufferTimeout_&&A.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=A.setTimeout(this.monitorBufferTick_.bind(this),1)}monitorBufferTick_(){this.state==="READY"&&this.fillBuffer_(),this.checkBufferTimeout_&&A.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=A.setTimeout(this.monitorBufferTick_.bind(this),RI)}fillBuffer_(){if(this.sourceUpdater_.updating())return;const e=this.chooseNextRequest_();e&&(typeof e.timestampOffset=="number"&&(this.isPendingTimestampOffset_=!1,this.timelineChangeController_.pendingTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline})),this.loadSegment_(e))}isEndOfStream_(e=this.mediaIndex,i=this.playlist_,n=this.partIndex){if(!i||!this.mediaSource_)return!1;const r=typeof e=="number"&&i.segments[e],s=e+1===i.segments.length,a=!r||!r.parts||n+1===r.parts.length;return i.endList&&this.mediaSource_.readyState==="open"&&s&&a}chooseNextRequest_(){const e=this.buffered_(),i=Oy(e)||0,n=um(e,this.currentTime_()),r=!this.hasPlayed_()&&n>=1,s=n>=this.goalBufferLength_(),a=this.playlist_.segments;if(!a.length||r||s)return null;this.syncPoint_=this.syncPoint_||this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_());const o={partIndex:null,mediaIndex:null,startOfSegment:null,playlist:this.playlist_,isSyncRequest:!this.syncPoint_};if(o.isSyncRequest)o.mediaIndex=NI(this.currentTimeline_,a,i);else if(this.mediaIndex!==null){const v=a[this.mediaIndex],S=typeof this.partIndex=="number"?this.partIndex:-1;o.startOfSegment=v.end?v.end:i,v.parts&&v.parts[S+1]?(o.mediaIndex=this.mediaIndex,o.partIndex=S+1):o.mediaIndex=this.mediaIndex+1}else{const{segmentIndex:v,startTime:S,partIndex:_}=Dt.getMediaInfoForTime({exactManifestTimings:this.exactManifestTimings,playlist:this.playlist_,currentTime:this.fetchAtBuffer_?i:this.currentTime_(),startingPartIndex:this.syncPoint_.partIndex,startingSegmentIndex:this.syncPoint_.segmentIndex,startTime:this.syncPoint_.time});o.getMediaInfoForTime=this.fetchAtBuffer_?`bufferedEnd ${i}`:`currentTime ${this.currentTime_()}`,o.mediaIndex=v,o.startOfSegment=S,o.partIndex=_}const l=a[o.mediaIndex];let c=l&&typeof o.partIndex=="number"&&l.parts&&l.parts[o.partIndex];if(!l||typeof o.partIndex=="number"&&!c)return null;typeof o.partIndex!="number"&&l.parts&&(o.partIndex=0,c=l.parts[0]);const p=this.vhs_.playlists&&this.vhs_.playlists.main&&this.vhs_.playlists.main.independentSegments||this.playlist_.independentSegments;if(!n&&c&&!p&&!c.independent)if(o.partIndex===0){const v=a[o.mediaIndex-1],S=v.parts&&v.parts.length&&v.parts[v.parts.length-1];S&&S.independent&&(o.mediaIndex-=1,o.partIndex=v.parts.length-1,o.independent="previous segment")}else l.parts[o.partIndex-1].independent&&(o.partIndex-=1,o.independent="previous part");const g=this.mediaSource_&&this.mediaSource_.readyState==="ended";return o.mediaIndex>=a.length-1&&g&&!this.seeking_()?null:this.generateSegmentInfo_(o)}generateSegmentInfo_(e){const{independent:i,playlist:n,mediaIndex:r,startOfSegment:s,isSyncRequest:a,partIndex:o,forceTimestampOffset:l,getMediaInfoForTime:c}=e,p=n.segments[r],g=typeof o=="number"&&p.parts[o],v={requestId:"segment-loader-"+Math.random(),uri:g&&g.resolvedUri||p.resolvedUri,mediaIndex:r,partIndex:g?o:null,isSyncRequest:a,startOfSegment:s,playlist:n,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:p.timeline,duration:g&&g.duration||p.duration,segment:p,part:g,byteLength:0,transmuxer:this.transmuxer_,getMediaInfoForTime:c,independent:i},S=typeof l<"u"?l:this.isPendingTimestampOffset_;v.timestampOffset=this.timestampOffsetForSegment_({segmentTimeline:p.timeline,currentTimeline:this.currentTimeline_,startOfSegment:s,buffered:this.buffered_(),calculateTimestampOffsetForEachSegment:this.calculateTimestampOffsetForEachSegment_,overrideCheck:S});const _=Oy(this.sourceUpdater_.audioBuffered());return typeof _=="number"&&(v.audioAppendStart=_-this.sourceUpdater_.audioTimestampOffset()),this.sourceUpdater_.videoBuffered().length&&(v.gopsToAlignWith=PI(this.gopBuffer_,this.currentTime_()-this.sourceUpdater_.videoTimestampOffset(),this.timeMapping_)),v}timestampOffsetForSegment_(e){return FI(e)}earlyAbortWhenNeeded_(e){if(this.vhs_.tech_.paused()||!this.xhrOptions_.timeout||!this.playlist_.attributes.BANDWIDTH||Date.now()-(e.firstBytesReceivedAt||Date.now())<1e3)return;const i=this.currentTime_(),n=e.bandwidth,r=this.pendingSegment_.duration,s=Dt.estimateSegmentRequestTime(r,n,this.playlist_,e.bytesReceived),a=sP(this.buffered_(),i,this.vhs_.tech_.playbackRate())-1;if(s<=a)return;const o=_I({main:this.vhs_.playlists.main,currentTime:i,bandwidth:n,duration:this.duration_(),segmentDuration:r,timeUntilRebuffer:a,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(!o)return;const c=s-a-o.rebufferingImpact;let p=.5;a<=Bn&&(p=1),!(!o.playlist||o.playlist.uri===this.playlist_.uri||c{s[a.stream]=s[a.stream]||{startTime:1/0,captions:[],endTime:0};const o=s[a.stream];o.startTime=Math.min(o.startTime,a.startTime+r),o.endTime=Math.max(o.endTime,a.endTime+r),o.captions.push(a)}),Object.keys(s).forEach(a=>{const{startTime:o,endTime:l,captions:c}=s[a],p=this.inbandTextTracks_;this.logger_(`adding cues from ${o} -> ${l} for ${a}`),SI(p,this.vhs_.tech_,a),Ea(o,l,p[a]),EI({captionArray:c,inbandTextTracks:p,timestampOffset:r})}),this.transmuxer_&&this.transmuxer_.postMessage({action:"clearParsedMp4Captions"})}handleId3_(e,i,n){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(!this.pendingSegment_.hasAppendedData_){this.metadataQueue_.id3.push(this.handleId3_.bind(this,e,i,n));return}this.addMetadataToTextTrack(n,i,this.duration_())}processMetadataQueue_(){this.metadataQueue_.id3.forEach(e=>e()),this.metadataQueue_.caption.forEach(e=>e()),this.metadataQueue_.id3=[],this.metadataQueue_.caption=[]}processCallQueue_(){const e=this.callQueue_;this.callQueue_=[],e.forEach(i=>i())}processLoadQueue_(){const e=this.loadQueue_;this.loadQueue_=[],e.forEach(i=>i())}hasEnoughInfoToLoad_(){if(this.loaderType_!=="audio")return!0;const e=this.pendingSegment_;return e?this.getCurrentMediaInfo_()?!Gy({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}):!0:!1}getCurrentMediaInfo_(e=this.pendingSegment_){return e&&e.trackInfo||this.currentMediaInfo_}getMediaInfo_(e=this.pendingSegment_){return this.getCurrentMediaInfo_(e)||this.startingMediaInfo_}getPendingSegmentPlaylist(){return this.pendingSegment_?this.pendingSegment_.playlist:null}hasEnoughInfoToAppend_(){if(!this.sourceUpdater_.ready()||this.waitingOnRemove_||this.quotaExceededErrorRetryTimeout_)return!1;const e=this.pendingSegment_,i=this.getCurrentMediaInfo_();if(!e||!i)return!1;const{hasAudio:n,hasVideo:r,isMuxed:s}=i;return!(r&&!e.videoTimingInfo||n&&!this.audioDisabled_&&!s&&!e.audioTimingInfo||Gy({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}))}handleData_(e,i){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(this.callQueue_.length||!this.hasEnoughInfoToAppend_()){this.callQueue_.push(this.handleData_.bind(this,e,i));return}const n=this.pendingSegment_;if(this.setTimeMapping_(n.timeline),this.updateMediaSecondsLoaded_(n.part||n.segment),this.mediaSource_.readyState!=="closed"){if(e.map&&(e.map=this.initSegmentForMap(e.map,!0),n.segment.map=e.map),e.key&&this.segmentKey(e.key,!0),n.isFmp4=e.isFmp4,n.timingInfo=n.timingInfo||{},n.isFmp4)this.trigger("fmp4"),n.timingInfo.start=n[qy(i.type)].start;else{const r=this.getCurrentMediaInfo_(),s=this.loaderType_==="main"&&r&&r.hasVideo;let a;s&&(a=n.videoTimingInfo.start),n.timingInfo.start=this.trueSegmentStart_({currentStart:n.timingInfo.start,playlist:n.playlist,mediaIndex:n.mediaIndex,currentVideoTimestampOffset:this.sourceUpdater_.videoTimestampOffset(),useVideoTimingInfo:s,firstVideoFrameTimeForData:a,videoTimingInfo:n.videoTimingInfo,audioTimingInfo:n.audioTimingInfo})}if(this.updateAppendInitSegmentStatus(n,i.type),this.updateSourceBufferTimestampOffset_(n),n.isSyncRequest){this.updateTimingInfoEnd_(n),this.syncController_.saveSegmentTimingInfo({segmentInfo:n,shouldSaveTimelineMapping:this.loaderType_==="main"});const r=this.chooseNextRequest_();if(r.mediaIndex!==n.mediaIndex||r.partIndex!==n.partIndex){this.logger_("sync segment was incorrect, not appending");return}this.logger_("sync segment was correct, appending")}n.hasAppendedData_=!0,this.processMetadataQueue_(),this.appendData_(n,i)}}updateAppendInitSegmentStatus(e,i){this.loaderType_==="main"&&typeof e.timestampOffset=="number"&&!e.changedTimestampOffset&&(this.appendInitSegment_={audio:!0,video:!0}),this.playlistOfLastInitSegment_[i]!==e.playlist&&(this.appendInitSegment_[i]=!0)}getInitSegmentAndUpdateState_({type:e,initSegment:i,map:n,playlist:r}){if(n){const s=Nu(n);if(this.activeInitSegmentId_===s)return null;i=this.initSegmentForMap(n,!0).bytes,this.activeInitSegmentId_=s}return i&&this.appendInitSegment_[e]?(this.playlistOfLastInitSegment_[e]=r,this.appendInitSegment_[e]=!1,this.activeInitSegmentId_=null,i):null}handleQuotaExceededError_({segmentInfo:e,type:i,bytes:n},r){const s=this.sourceUpdater_.audioBuffered(),a=this.sourceUpdater_.videoBuffered();s.length>1&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the audio buffer: "+nr(s).join(", ")),a.length>1&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the video buffer: "+nr(a).join(", "));const o=s.length?s.start(0):0,l=s.length?s.end(s.length-1):0,c=a.length?a.start(0):0,p=a.length?a.end(a.length-1):0;if(l-o<=fa&&p-c<=fa){this.logger_(`On QUOTA_EXCEEDED_ERR, single segment too large to append to buffer, triggering an error. Appended byte length: ${n.byteLength}, audio buffer: ${nr(s).join(", ")}, video buffer: ${nr(a).join(", ")}, `),this.error({message:"Quota exceeded error with append of a single segment of content",excludeUntil:1/0}),this.trigger("error");return}this.waitingOnRemove_=!0,this.callQueue_.push(this.appendToSourceBuffer_.bind(this,{segmentInfo:e,type:i,bytes:n}));const v=this.currentTime_()-fa;this.logger_(`On QUOTA_EXCEEDED_ERR, removing audio/video from 0 to ${v}`),this.remove(0,v,()=>{this.logger_(`On QUOTA_EXCEEDED_ERR, retrying append in ${fa}s`),this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=A.setTimeout(()=>{this.logger_("On QUOTA_EXCEEDED_ERR, re-processing call queue"),this.quotaExceededErrorRetryTimeout_=null,this.processCallQueue_()},fa*1e3)},!0)}handleAppendError_({segmentInfo:e,type:i,bytes:n},r){if(r){if(r.code===wx){this.handleQuotaExceededError_({segmentInfo:e,type:i,bytes:n});return}this.logger_("Received non QUOTA_EXCEEDED_ERR on append",r),this.error(`${i} append of ${n.length}b failed for segment #${e.mediaIndex} in playlist ${e.playlist.id}`),this.trigger("appenderror")}}appendToSourceBuffer_({segmentInfo:e,type:i,initSegment:n,data:r,bytes:s}){if(!s){const a=[r];let o=r.byteLength;n&&(a.unshift(n),o+=n.byteLength),s=xI({bytes:o,segments:a})}this.sourceUpdater_.appendBuffer({segmentInfo:e,type:i,bytes:s},this.handleAppendError_.bind(this,{segmentInfo:e,type:i,bytes:s}))}handleSegmentTimingInfo_(e,i,n){if(!this.pendingSegment_||i!==this.pendingSegment_.requestId)return;const r=this.pendingSegment_.segment,s=`${e}TimingInfo`;r[s]||(r[s]={}),r[s].transmuxerPrependedSeconds=n.prependedContentDuration||0,r[s].transmuxedPresentationStart=n.start.presentation,r[s].transmuxedDecodeStart=n.start.decode,r[s].transmuxedPresentationEnd=n.end.presentation,r[s].transmuxedDecodeEnd=n.end.decode,r[s].baseMediaDecodeTime=n.baseMediaDecodeTime}appendData_(e,i){const{type:n,data:r}=i;if(!r||!r.byteLength||n==="audio"&&this.audioDisabled_)return;const s=this.getInitSegmentAndUpdateState_({type:n,initSegment:i.initSegment,playlist:e.playlist,map:e.isFmp4?e.segment.map:null});this.appendToSourceBuffer_({segmentInfo:e,type:n,initSegment:s,data:r})}loadSegment_(e){if(this.state="WAITING",this.pendingSegment_=e,this.trimBackBuffer_(e),typeof e.timestampOffset=="number"&&this.transmuxer_&&this.transmuxer_.postMessage({action:"clearAllMp4Captions"}),!this.hasEnoughInfoToLoad_()){this.loadQueue_.push(()=>{const i=rn({},e,{forceTimestampOffset:!0});rn(e,this.generateSegmentInfo_(i)),this.isPendingTimestampOffset_=!1,this.updateTransmuxerAndRequestSegment_(e)});return}this.updateTransmuxerAndRequestSegment_(e)}updateTransmuxerAndRequestSegment_(e){this.shouldUpdateTransmuxerTimestampOffset_(e.timestampOffset)&&(this.gopBuffer_.length=0,e.gopsToAlignWith=[],this.timeMapping_=0,this.transmuxer_.postMessage({action:"reset"}),this.transmuxer_.postMessage({action:"setTimestampOffset",timestampOffset:e.timestampOffset}));const i=this.createSimplifiedSegmentObj_(e),n=this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex),r=this.mediaIndex!==null,s=e.timeline!==this.currentTimeline_&&e.timeline>0,a=n||r&&s;this.logger_(`Requesting ${Nr(e)}`),i.map&&!i.map.bytes&&(this.logger_("going to request init segment."),this.appendInitSegment_={video:!0,audio:!0}),e.abortRequests=fI({xhr:this.vhs_.xhr,xhrOptions:this.xhrOptions_,decryptionWorker:this.decrypter_,segment:i,abortFn:this.handleAbort_.bind(this,e),progressFn:this.handleProgress_.bind(this),trackInfoFn:this.handleTrackInfo_.bind(this),timingInfoFn:this.handleTimingInfo_.bind(this),videoSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"video",e.requestId),audioSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"audio",e.requestId),captionsFn:this.handleCaptions_.bind(this),isEndOfTimeline:a,endedTimelineFn:()=>{this.logger_("received endedtimeline callback")},id3Fn:this.handleId3_.bind(this),dataFn:this.handleData_.bind(this),doneFn:this.segmentRequestFinished_.bind(this),onTransmuxerLog:({message:o,level:l,stream:c})=>{this.logger_(`${Nr(e)} logged from transmuxer stream ${c} as a ${l}: ${o}`)}})}trimBackBuffer_(e){const i=BI(this.seekable_(),this.currentTime_(),this.playlist_.targetDuration||10);i>0&&this.remove(0,i)}createSimplifiedSegmentObj_(e){const i=e.segment,n=e.part,r={resolvedUri:n?n.resolvedUri:i.resolvedUri,byterange:n?n.byterange:i.byterange,requestId:e.requestId,transmuxer:e.transmuxer,audioAppendStart:e.audioAppendStart,gopsToAlignWith:e.gopsToAlignWith,part:e.part},s=e.playlist.segments[e.mediaIndex-1];if(s&&s.timeline===i.timeline&&(s.videoTimingInfo?r.baseStartTime=s.videoTimingInfo.transmuxedDecodeEnd:s.audioTimingInfo&&(r.baseStartTime=s.audioTimingInfo.transmuxedDecodeEnd)),i.key){const a=i.key.iv||new Uint32Array([0,0,0,e.mediaIndex+e.playlist.mediaSequence]);r.key=this.segmentKey(i.key),r.key.iv=a}return i.map&&(r.map=this.initSegmentForMap(i.map)),r}saveTransferStats_(e){this.mediaRequests+=1,e&&(this.mediaBytesTransferred+=e.bytesReceived,this.mediaTransferDuration+=e.roundTripTime)}saveBandwidthRelatedStats_(e,i){if(this.pendingSegment_.byteLength=i.bytesReceived,e"u"||c.end!==r+s?r:o.start}waitForAppendsToComplete_(e){const i=this.getCurrentMediaInfo_(e);if(!i){this.error({message:"No starting media returned, likely due to an unsupported media format.",playlistExclusionDuration:1/0}),this.trigger("error");return}const{hasAudio:n,hasVideo:r,isMuxed:s}=i,a=this.loaderType_==="main"&&r,o=!this.audioDisabled_&&n&&!s;if(e.waitingOnAppends=0,!e.hasAppendedData_){!e.timingInfo&&typeof e.timestampOffset=="number"&&(this.isPendingTimestampOffset_=!0),e.timingInfo={start:0},e.waitingOnAppends++,this.isPendingTimestampOffset_||(this.updateSourceBufferTimestampOffset_(e),this.processMetadataQueue_()),this.checkAppendsDone_(e);return}a&&e.waitingOnAppends++,o&&e.waitingOnAppends++,a&&this.sourceUpdater_.videoQueueCallback(this.checkAppendsDone_.bind(this,e)),o&&this.sourceUpdater_.audioQueueCallback(this.checkAppendsDone_.bind(this,e))}checkAppendsDone_(e){this.checkForAbort_(e.requestId)||(e.waitingOnAppends--,e.waitingOnAppends===0&&this.handleAppendsDone_())}checkForIllegalMediaSwitch(e){const i=MI(this.loaderType_,this.getCurrentMediaInfo_(),e);return i?(this.error({message:i,playlistExclusionDuration:1/0}),this.trigger("error"),!0):!1}updateSourceBufferTimestampOffset_(e){if(e.timestampOffset===null||typeof e.timingInfo.start!="number"||e.changedTimestampOffset||this.loaderType_!=="main")return;let i=!1;e.timestampOffset-=this.getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e.segment.videoTimingInfo,audioTimingInfo:e.segment.audioTimingInfo,timingInfo:e.timingInfo}),e.changedTimestampOffset=!0,e.timestampOffset!==this.sourceUpdater_.videoTimestampOffset()&&(this.sourceUpdater_.videoTimestampOffset(e.timestampOffset),i=!0),e.timestampOffset!==this.sourceUpdater_.audioTimestampOffset()&&(this.sourceUpdater_.audioTimestampOffset(e.timestampOffset),i=!0),i&&this.trigger("timestampoffset")}getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e,audioTimingInfo:i,timingInfo:n}){return this.useDtsForTimestampOffset_?e&&typeof e.transmuxedDecodeStart=="number"?e.transmuxedDecodeStart:i&&typeof i.transmuxedDecodeStart=="number"?i.transmuxedDecodeStart:n.start:n.start}updateTimingInfoEnd_(e){e.timingInfo=e.timingInfo||{};const i=this.getMediaInfo_(),r=this.loaderType_==="main"&&i&&i.hasVideo&&e.videoTimingInfo?e.videoTimingInfo:e.audioTimingInfo;r&&(e.timingInfo.end=typeof r.end=="number"?r.end:r.start+e.duration)}handleAppendsDone_(){if(this.pendingSegment_&&this.trigger("appendsdone"),!this.pendingSegment_){this.state="READY",this.paused()||this.monitorBuffer_();return}const e=this.pendingSegment_;this.updateTimingInfoEnd_(e),this.shouldSaveSegmentTimingInfo_&&this.syncController_.saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:this.loaderType_==="main"});const i=jI(e,this.sourceType_);if(i&&(i.severity==="warn"?M.log.warn(i.message):this.logger_(i.message)),this.recordThroughput_(e),this.pendingSegment_=null,this.state="READY",e.isSyncRequest&&(this.trigger("syncinfoupdate"),!e.hasAppendedData_)){this.logger_(`Throwing away un-appended sync request ${Nr(e)}`);return}this.logger_(`Appended ${Nr(e)}`),this.addSegmentMetadataCue_(e),this.currentTime_()>=this.replaceSegmentsUntil_&&(this.replaceSegmentsUntil_=-1,this.fetchAtBuffer_=!0),this.currentTimeline_!==e.timeline&&(this.timelineChangeController_.lastTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline}),this.loaderType_==="main"&&!this.audioDisabled_&&this.timelineChangeController_.lastTimelineChange({type:"audio",from:this.currentTimeline_,to:e.timeline})),this.currentTimeline_=e.timeline,this.trigger("syncinfoupdate");const n=e.segment,r=e.part,s=n.end&&this.currentTime_()-n.end>e.playlist.targetDuration*3,a=r&&r.end&&this.currentTime_()-r.end>e.playlist.partTargetDuration*3;if(s||a){this.logger_(`bad ${s?"segment":"part"} ${Nr(e)}`),this.resetEverything();return}this.mediaIndex!==null&&this.trigger("bandwidthupdate"),this.trigger("progress"),this.mediaIndex=e.mediaIndex,this.partIndex=e.partIndex,this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex)&&this.endOfStream(),this.trigger("appended"),e.hasAppendedData_&&this.mediaAppends++,this.paused()||this.monitorBuffer_()}recordThroughput_(e){if(e.duratione.toUpperCase())},$I=["video","audio"],mf=(t,e)=>{const i=e[`${t}Buffer`];return i&&i.updating||e.queuePending[t]},VI=(t,e)=>{for(let i=0;i{if(e.queue.length===0)return;let i=0,n=e.queue[i];if(n.type==="mediaSource"){!e.updating()&&e.mediaSource.readyState!=="closed"&&(e.queue.shift(),n.action(e),n.doneFn&&n.doneFn(),ls("audio",e),ls("video",e));return}if(t!=="mediaSource"&&!(!e.ready()||e.mediaSource.readyState==="closed"||mf(t,e))){if(n.type!==t){if(i=VI(t,e.queue),i===null)return;n=e.queue[i]}if(e.queue.splice(i,1),e.queuePending[t]=n,n.action(t,e),!n.doneFn){e.queuePending[t]=null,ls(t,e);return}}},Ax=(t,e)=>{const i=e[`${t}Buffer`],n=Dx(t);i&&(i.removeEventListener("updateend",e[`on${n}UpdateEnd_`]),i.removeEventListener("error",e[`on${n}Error_`]),e.codecs[t]=null,e[`${t}Buffer`]=null)},Ei=(t,e)=>t&&e&&Array.prototype.indexOf.call(t.sourceBuffers,e)!==-1,Rt={appendBuffer:(t,e,i)=>(n,r)=>{const s=r[`${n}Buffer`];if(Ei(r.mediaSource,s)){r.logger_(`Appending segment ${e.mediaIndex}'s ${t.length} bytes to ${n}Buffer`);try{s.appendBuffer(t)}catch(a){r.logger_(`Error with code ${a.code} `+(a.code===wx?"(QUOTA_EXCEEDED_ERR) ":"")+`when appending segment ${e.mediaIndex} to ${n}Buffer`),r.queuePending[n]=null,i(a)}}},remove:(t,e)=>(i,n)=>{const r=n[`${i}Buffer`];if(Ei(n.mediaSource,r)){n.logger_(`Removing ${t} to ${e} from ${i}Buffer`);try{r.remove(t,e)}catch{n.logger_(`Remove ${t} to ${e} from ${i}Buffer failed`)}}},timestampOffset:t=>(e,i)=>{const n=i[`${e}Buffer`];Ei(i.mediaSource,n)&&(i.logger_(`Setting ${e}timestampOffset to ${t}`),n.timestampOffset=t)},callback:t=>(e,i)=>{t()},endOfStream:t=>e=>{if(e.mediaSource.readyState==="open"){e.logger_(`Calling mediaSource endOfStream(${t||""})`);try{e.mediaSource.endOfStream(t)}catch(i){M.log.warn("Failed to call media source endOfStream",i)}}},duration:t=>e=>{e.logger_(`Setting mediaSource duration to ${t}`);try{e.mediaSource.duration=t}catch(i){M.log.warn("Failed to set media source duration",i)}},abort:()=>(t,e)=>{if(e.mediaSource.readyState!=="open")return;const i=e[`${t}Buffer`];if(Ei(e.mediaSource,i)){e.logger_(`calling abort on ${t}Buffer`);try{i.abort()}catch(n){M.log.warn(`Failed to abort on ${t}Buffer`,n)}}},addSourceBuffer:(t,e)=>i=>{const n=Dx(t),r=ro(e);i.logger_(`Adding ${t}Buffer with codec ${e} to mediaSource`);const s=i.mediaSource.addSourceBuffer(r);s.addEventListener("updateend",i[`on${n}UpdateEnd_`]),s.addEventListener("error",i[`on${n}Error_`]),i.codecs[t]=e,i[`${t}Buffer`]=s},removeSourceBuffer:t=>e=>{const i=e[`${t}Buffer`];if(Ax(t,e),!!Ei(e.mediaSource,i)){e.logger_(`Removing ${t}Buffer with codec ${e.codecs[t]} from mediaSource`);try{e.mediaSource.removeSourceBuffer(i)}catch(n){M.log.warn(`Failed to removeSourceBuffer ${t}Buffer`,n)}}},changeType:t=>(e,i)=>{const n=i[`${e}Buffer`],r=ro(t);Ei(i.mediaSource,n)&&i.codecs[e]!==t&&(i.logger_(`changing ${e}Buffer codec from ${i.codecs[e]} to ${t}`),n.changeType(r),i.codecs[e]=t)}},Mt=({type:t,sourceUpdater:e,action:i,doneFn:n,name:r})=>{e.queue.push({type:t,action:i,doneFn:n,name:r}),ls(t,e)},Ky=(t,e)=>i=>{const n=e[`${t}Buffered`](),r=iP(n);if(e.logger_(`${t} source buffer update end. Buffered:
-`,r),e.queuePending[t]){const s=e.queuePending[t].doneFn;e.queuePending[t]=null,s&&s(e[`${t}Error_`])}ls(t,e)};class kx extends M.EventTarget{constructor(e){super(),this.mediaSource=e,this.sourceopenListener_=()=>ls("mediaSource",this),this.mediaSource.addEventListener("sourceopen",this.sourceopenListener_),this.logger_=si("SourceUpdater"),this.audioTimestampOffset_=0,this.videoTimestampOffset_=0,this.queue=[],this.queuePending={audio:null,video:null},this.delayedAudioAppendQueue_=[],this.videoAppendQueued_=!1,this.codecs={},this.onVideoUpdateEnd_=Ky("video",this),this.onAudioUpdateEnd_=Ky("audio",this),this.onVideoError_=i=>{this.videoError_=i},this.onAudioError_=i=>{this.audioError_=i},this.createdSourceBuffers_=!1,this.initializedEme_=!1,this.triggeredReady_=!1}initializedEme(){this.initializedEme_=!0,this.triggerReady()}hasCreatedSourceBuffers(){return this.createdSourceBuffers_}hasInitializedAnyEme(){return this.initializedEme_}ready(){return this.hasCreatedSourceBuffers()&&this.hasInitializedAnyEme()}createSourceBuffers(e){this.hasCreatedSourceBuffers()||(this.addOrChangeSourceBuffers(e),this.createdSourceBuffers_=!0,this.trigger("createdsourcebuffers"),this.triggerReady())}triggerReady(){this.ready()&&!this.triggeredReady_&&(this.triggeredReady_=!0,this.trigger("ready"))}addSourceBuffer(e,i){Mt({type:"mediaSource",sourceUpdater:this,action:Rt.addSourceBuffer(e,i),name:"addSourceBuffer"})}abort(e){Mt({type:e,sourceUpdater:this,action:Rt.abort(e),name:"abort"})}removeSourceBuffer(e){if(!this.canRemoveSourceBuffer()){M.log.error("removeSourceBuffer is not supported!");return}Mt({type:"mediaSource",sourceUpdater:this,action:Rt.removeSourceBuffer(e),name:"removeSourceBuffer"})}canRemoveSourceBuffer(){return!M.browser.IS_FIREFOX&&A.MediaSource&&A.MediaSource.prototype&&typeof A.MediaSource.prototype.removeSourceBuffer=="function"}static canChangeType(){return A.SourceBuffer&&A.SourceBuffer.prototype&&typeof A.SourceBuffer.prototype.changeType=="function"}canChangeType(){return this.constructor.canChangeType()}changeType(e,i){if(!this.canChangeType()){M.log.error("changeType is not supported!");return}Mt({type:e,sourceUpdater:this,action:Rt.changeType(i),name:"changeType"})}addOrChangeSourceBuffers(e){if(!e||typeof e!="object"||Object.keys(e).length===0)throw new Error("Cannot addOrChangeSourceBuffers to undefined codecs");Object.keys(e).forEach(i=>{const n=e[i];if(!this.hasCreatedSourceBuffers())return this.addSourceBuffer(i,n);this.canChangeType()&&this.changeType(i,n)})}appendBuffer(e,i){const{segmentInfo:n,type:r,bytes:s}=e;if(this.processedAppend_=!0,r==="audio"&&this.videoBuffer&&!this.videoAppendQueued_){this.delayedAudioAppendQueue_.push([e,i]),this.logger_(`delayed audio append of ${s.length} until video append`);return}const a=i;if(Mt({type:r,sourceUpdater:this,action:Rt.appendBuffer(s,n||{mediaIndex:-1},a),doneFn:i,name:"appendBuffer"}),r==="video"){if(this.videoAppendQueued_=!0,!this.delayedAudioAppendQueue_.length)return;const o=this.delayedAudioAppendQueue_.slice();this.logger_(`queuing delayed audio ${o.length} appendBuffers`),this.delayedAudioAppendQueue_.length=0,o.forEach(l=>{this.appendBuffer.apply(this,l)})}}audioBuffered(){return Ei(this.mediaSource,this.audioBuffer)&&this.audioBuffer.buffered?this.audioBuffer.buffered:ot()}videoBuffered(){return Ei(this.mediaSource,this.videoBuffer)&&this.videoBuffer.buffered?this.videoBuffer.buffered:ot()}buffered(){const e=Ei(this.mediaSource,this.videoBuffer)?this.videoBuffer:null,i=Ei(this.mediaSource,this.audioBuffer)?this.audioBuffer:null;return i&&!e?this.audioBuffered():e&&!i?this.videoBuffered():rP(this.audioBuffered(),this.videoBuffered())}setDuration(e,i=Wi){Mt({type:"mediaSource",sourceUpdater:this,action:Rt.duration(e),name:"duration",doneFn:i})}endOfStream(e=null,i=Wi){typeof e!="string"&&(e=void 0),Mt({type:"mediaSource",sourceUpdater:this,action:Rt.endOfStream(e),name:"endOfStream",doneFn:i})}removeAudio(e,i,n=Wi){if(!this.audioBuffered().length||this.audioBuffered().end(0)===0){n();return}Mt({type:"audio",sourceUpdater:this,action:Rt.remove(e,i),doneFn:n,name:"remove"})}removeVideo(e,i,n=Wi){if(!this.videoBuffered().length||this.videoBuffered().end(0)===0){n();return}Mt({type:"video",sourceUpdater:this,action:Rt.remove(e,i),doneFn:n,name:"remove"})}updating(){return!!(mf("audio",this)||mf("video",this))}audioTimestampOffset(e){return typeof e<"u"&&this.audioBuffer&&this.audioTimestampOffset_!==e&&(Mt({type:"audio",sourceUpdater:this,action:Rt.timestampOffset(e),name:"timestampOffset"}),this.audioTimestampOffset_=e),this.audioTimestampOffset_}videoTimestampOffset(e){return typeof e<"u"&&this.videoBuffer&&this.videoTimestampOffset!==e&&(Mt({type:"video",sourceUpdater:this,action:Rt.timestampOffset(e),name:"timestampOffset"}),this.videoTimestampOffset_=e),this.videoTimestampOffset_}audioQueueCallback(e){this.audioBuffer&&Mt({type:"audio",sourceUpdater:this,action:Rt.callback(e),name:"callback"})}videoQueueCallback(e){this.videoBuffer&&Mt({type:"video",sourceUpdater:this,action:Rt.callback(e),name:"callback"})}dispose(){this.trigger("dispose"),$I.forEach(e=>{this.abort(e),this.canRemoveSourceBuffer()?this.removeSourceBuffer(e):this[`${e}QueueCallback`](()=>Ax(e,this))}),this.videoAppendQueued_=!1,this.delayedAudioAppendQueue_.length=0,this.sourceopenListener_&&this.mediaSource.removeEventListener("sourceopen",this.sourceopenListener_),this.off()}}const Qy=t=>decodeURIComponent(escape(String.fromCharCode.apply(null,t))),Yy=new Uint8Array(`
-
-`.split("").map(t=>t.charCodeAt(0)));class zI extends Error{constructor(){super("Trying to parse received VTT cues, but there is no WebVTT. Make sure vtt.js is loaded.")}}class HI extends pf{constructor(e,i={}){super(e,i),this.mediaSource_=null,this.subtitlesTrack_=null,this.loaderType_="subtitle",this.featuresNativeTextTracks_=e.featuresNativeTextTracks,this.loadVttJs=e.loadVttJs,this.shouldSaveSegmentTimingInfo_=!1}createTransmuxer_(){return null}buffered_(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues||!this.subtitlesTrack_.cues.length)return ot();const e=this.subtitlesTrack_.cues,i=e[0].startTime,n=e[e.length-1].startTime;return ot([[i,n]])}initSegmentForMap(e,i=!1){if(!e)return null;const n=Nu(e);let r=this.initSegments_[n];if(i&&!r&&e.bytes){const s=Yy.byteLength+e.bytes.byteLength,a=new Uint8Array(s);a.set(e.bytes),a.set(Yy,e.bytes.byteLength),this.initSegments_[n]=r={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:a}}return r||e}couldBeginLoading_(){return this.playlist_&&this.subtitlesTrack_&&!this.paused()}init_(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}track(e){return typeof e>"u"?this.subtitlesTrack_:(this.subtitlesTrack_=e,this.state==="INIT"&&this.couldBeginLoading_()&&this.init_(),this.subtitlesTrack_)}remove(e,i){Ea(e,i,this.subtitlesTrack_)}fillBuffer_(){const e=this.chooseNextRequest_();if(e){if(this.syncController_.timestampOffsetForTimeline(e.timeline)===null){const i=()=>{this.state="READY",this.paused()||this.monitorBuffer_()};this.syncController_.one("timestampoffset",i),this.state="WAITING_ON_TIMELINE";return}this.loadSegment_(e)}}timestampOffsetForSegment_(){return null}chooseNextRequest_(){return this.skipEmptySegments_(super.chooseNextRequest_())}skipEmptySegments_(e){for(;e&&e.segment.empty;){if(e.mediaIndex+1>=e.playlist.segments.length){e=null;break}e=this.generateSegmentInfo_({playlist:e.playlist,mediaIndex:e.mediaIndex+1,startOfSegment:e.startOfSegment+e.duration,isSyncRequest:e.isSyncRequest})}return e}stopForError(e){this.error(e),this.state="READY",this.pause(),this.trigger("error")}segmentRequestFinished_(e,i,n){if(!this.subtitlesTrack_){this.state="READY";return}if(this.saveTransferStats_(i.stats),!this.pendingSegment_){this.state="READY",this.mediaRequestsAborted+=1;return}if(e){e.code===Di.TIMEOUT&&this.handleTimeout_(),e.code===Di.ABORTED?this.mediaRequestsAborted+=1:this.mediaRequestsErrored+=1,this.stopForError(e);return}const r=this.pendingSegment_;this.saveBandwidthRelatedStats_(r.duration,i.stats),i.key&&this.segmentKey(i.key,!0),this.state="APPENDING",this.trigger("appending");const s=r.segment;if(s.map&&(s.map.bytes=i.map.bytes),r.bytes=i.bytes,typeof A.WebVTT!="function"&&typeof this.loadVttJs=="function"){this.state="WAITING_ON_VTTJS",this.loadVttJs().then(()=>this.segmentRequestFinished_(e,i,n),()=>this.stopForError({message:"Error loading vtt.js"}));return}s.requested=!0;try{this.parseVTTCues_(r)}catch(a){this.stopForError({message:a.message});return}if(this.updateTimeMapping_(r,this.syncController_.timelines[r.timeline],this.playlist_),r.cues.length?r.timingInfo={start:r.cues[0].startTime,end:r.cues[r.cues.length-1].endTime}:r.timingInfo={start:r.startOfSegment,end:r.startOfSegment+r.duration},r.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}r.byteLength=r.bytes.byteLength,this.mediaSecondsLoaded+=s.duration,r.cues.forEach(a=>{this.subtitlesTrack_.addCue(this.featuresNativeTextTracks_?new A.VTTCue(a.startTime,a.endTime,a.text):a)}),kI(this.subtitlesTrack_),this.handleAppendsDone_()}handleData_(){}updateTimingInfoEnd_(){}parseVTTCues_(e){let i,n=!1;if(typeof A.WebVTT!="function")throw new zI;typeof A.TextDecoder=="function"?i=new A.TextDecoder("utf8"):(i=A.WebVTT.StringDecoder(),n=!0);const r=new A.WebVTT.Parser(A,A.vttjs,i);if(e.cues=[],e.timestampmap={MPEGTS:0,LOCAL:0},r.oncue=e.cues.push.bind(e.cues),r.ontimestampmap=a=>{e.timestampmap=a},r.onparsingerror=a=>{M.log.warn("Error encountered when parsing cues: "+a.message)},e.segment.map){let a=e.segment.map.bytes;n&&(a=Qy(a)),r.parse(a)}let s=e.bytes;n&&(s=Qy(s)),r.parse(s),r.flush()}updateTimeMapping_(e,i,n){const r=e.segment;if(!i)return;if(!e.cues.length){r.empty=!0;return}const s=e.timestampmap,a=s.MPEGTS/xu.ONE_SECOND_IN_TS-s.LOCAL+i.mapping;if(e.cues.forEach(o=>{o.startTime+=a,o.endTime+=a}),!n.syncInfo){const o=e.cues[0].startTime,l=e.cues[e.cues.length-1].startTime;n.syncInfo={mediaSequence:n.mediaSequence+e.mediaIndex,time:Math.min(o,l-r.duration)}}}}const qI=function(t,e){const i=t.cues;for(let n=0;n=r.adStartTime&&e<=r.adEndTime)return r}return null},WI=function(t,e,i=0){if(!t.segments)return;let n=i,r;for(let s=0;si!==1/0?{time:0,segmentIndex:0,partIndex:null}:null},{name:"ProgramDateTime",run:(t,e,i,n,r)=>{if(!Object.keys(t.timelineToDatetimeMappings).length)return null;let s=null,a=null;const o=af(e);r=r||0;for(let l=0;l{let s=null,a=null;r=r||0;const o=af(e);for(let l=0;l=S)&&(a=S,s={time:v,segmentIndex:p.segmentIndex,partIndex:p.partIndex})}}return s}},{name:"Discontinuity",run:(t,e,i,n,r)=>{let s=null;if(r=r||0,e.discontinuityStarts&&e.discontinuityStarts.length){let a=null;for(let o=0;o=g)&&(a=g,s={time:p.time,segmentIndex:l,partIndex:null})}}}return s}},{name:"Playlist",run:(t,e,i,n,r)=>e.syncInfo?{time:e.syncInfo.time,segmentIndex:e.syncInfo.mediaSequence-e.mediaSequence,partIndex:null}:null}];class XI extends M.EventTarget{constructor(e={}){super(),this.timelines=[],this.discontinuities=[],this.timelineToDatetimeMappings={},this.logger_=si("SyncController")}getSyncPoint(e,i,n,r){const s=this.runStrategies_(e,i,n,r);return s.length?this.selectSyncPoint_(s,{key:"time",value:r}):null}getExpiredTime(e,i){if(!e||!e.segments)return null;const n=this.runStrategies_(e,i,e.discontinuitySequence,0);if(!n.length)return null;const r=this.selectSyncPoint_(n,{key:"segmentIndex",value:0});return r.segmentIndex>0&&(r.time*=-1),Math.abs(r.time+Ba({defaultDuration:e.targetDuration,durationList:e.segments,startIndex:r.segmentIndex,endIndex:0}))}runStrategies_(e,i,n,r){const s=[];for(let a=0;aGI){M.log.warn(`Not saving expired segment info. Media sequence gap ${n} is too large.`);return}for(let r=n-1;r>=0;r--){const s=e.segments[r];if(s&&typeof s.start<"u"){i.syncInfo={mediaSequence:e.mediaSequence+r,time:s.start},this.logger_(`playlist refresh sync: [time:${i.syncInfo.time}, mediaSequence: ${i.syncInfo.mediaSequence}]`),this.trigger("syncinfoupdate");break}}}setDateTimeMappingForStart(e){if(this.timelineToDatetimeMappings={},e.segments&&e.segments.length&&e.segments[0].dateTimeObject){const i=e.segments[0],n=i.dateTimeObject.getTime()/1e3;this.timelineToDatetimeMappings[i.timeline]=-n}}saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:i}){const n=this.calculateSegmentTimeMapping_(e,e.timingInfo,i),r=e.segment;n&&(this.saveDiscontinuitySyncInfo_(e),e.playlist.syncInfo||(e.playlist.syncInfo={mediaSequence:e.playlist.mediaSequence+e.mediaIndex,time:r.start}));const s=r.dateTimeObject;r.discontinuity&&i&&s&&(this.timelineToDatetimeMappings[r.timeline]=-(s.getTime()/1e3))}timestampOffsetForTimeline(e){return typeof this.timelines[e]>"u"?null:this.timelines[e].time}mappingForTimeline(e){return typeof this.timelines[e]>"u"?null:this.timelines[e].mapping}calculateSegmentTimeMapping_(e,i,n){const r=e.segment,s=e.part;let a=this.timelines[e.timeline],o,l;if(typeof e.timestampOffset=="number")a={time:e.startOfSegment,mapping:e.startOfSegment-i.start},n&&(this.timelines[e.timeline]=a,this.trigger("timestampoffset"),this.logger_(`time mapping for timeline ${e.timeline}: [time: ${a.time}] [mapping: ${a.mapping}]`)),o=e.startOfSegment,l=i.end+a.mapping;else if(a)o=i.start+a.mapping,l=i.end+a.mapping;else return!1;return s&&(s.start=o,s.end=l),(!r.start||ol){let c;o<0?c=n.start-Ba({defaultDuration:i.targetDuration,durationList:i.segments,startIndex:e.mediaIndex,endIndex:s}):c=n.end+Ba({defaultDuration:i.targetDuration,durationList:i.segments,startIndex:e.mediaIndex+1,endIndex:s}),this.discontinuities[a]={time:c,accuracy:l}}}}dispose(){this.trigger("dispose"),this.off()}}class KI extends M.EventTarget{constructor(){super(),this.pendingTimelineChanges_={},this.lastTimelineChanges_={}}clearPendingTimelineChange(e){this.pendingTimelineChanges_[e]=null,this.trigger("pendingtimelinechange")}pendingTimelineChange({type:e,from:i,to:n}){return typeof i=="number"&&typeof n=="number"&&(this.pendingTimelineChanges_[e]={type:e,from:i,to:n},this.trigger("pendingtimelinechange")),this.pendingTimelineChanges_[e]}lastTimelineChange({type:e,from:i,to:n}){return typeof i=="number"&&typeof n=="number"&&(this.lastTimelineChanges_[e]={type:e,from:i,to:n},delete this.pendingTimelineChanges_[e],this.trigger("timelinechange")),this.lastTimelineChanges_[e]}dispose(){this.trigger("dispose"),this.pendingTimelineChanges_={},this.lastTimelineChanges_={},this.off()}}const QI=mx(gx(function(){var t=function(){function w(){this.listeners={}}var I=w.prototype;return I.on=function(T,C){this.listeners[T]||(this.listeners[T]=[]),this.listeners[T].push(C)},I.off=function(T,C){if(!this.listeners[T])return!1;var k=this.listeners[T].indexOf(C);return this.listeners[T]=this.listeners[T].slice(0),this.listeners[T].splice(k,1),k>-1},I.trigger=function(T){var C=this.listeners[T];if(C)if(arguments.length===2)for(var k=C.length,L=0;L>7)*283)^k]=k;for(L=N=0;!T[L];L^=K||1,N=$[N]||1)for(he=N^N<<1^N<<2^N<<3^N<<4,he=he>>8^he&255^99,T[L]=he,C[he]=L,ne=F[Y=F[K=F[L]]],ce=ne*16843009^Y*65537^K*257^L*16843008,Q=F[he]*257^he*16843008,k=0;k<4;k++)I[k][L]=Q=Q<<24^Q>>>8,x[k][he]=ce=ce<<24^ce>>>8;for(k=0;k<5;k++)I[k]=I[k].slice(0),x[k]=x[k].slice(0);return w};let n=null;class r{constructor(I){n||(n=i()),this._tables=[[n[0][0].slice(),n[0][1].slice(),n[0][2].slice(),n[0][3].slice(),n[0][4].slice()],[n[1][0].slice(),n[1][1].slice(),n[1][2].slice(),n[1][3].slice(),n[1][4].slice()]];let x,T,C;const k=this._tables[0][4],L=this._tables[1],N=I.length;let F=1;if(N!==4&&N!==6&&N!==8)throw new Error("Invalid aes key size");const $=I.slice(0),K=[];for(this._key=[$,K],x=N;x<4*N+28;x++)C=$[x-1],(x%N===0||N===8&&x%N===4)&&(C=k[C>>>24]<<24^k[C>>16&255]<<16^k[C>>8&255]<<8^k[C&255],x%N===0&&(C=C<<8^C>>>24^F<<24,F=F<<1^(F>>7)*283)),$[x]=$[x-N]^C;for(T=0;x;T++,x--)C=$[T&3?x:x-4],x<=4||T<4?K[T]=C:K[T]=L[0][k[C>>>24]]^L[1][k[C>>16&255]]^L[2][k[C>>8&255]]^L[3][k[C&255]]}decrypt(I,x,T,C,k,L){const N=this._key[1];let F=I^N[0],$=C^N[1],K=T^N[2],Y=x^N[3],ne,he,Q;const ce=N.length/4-2;let dt,ue=4;const Ce=this._tables[1],H=Ce[0],ee=Ce[1],te=Ce[2],fe=Ce[3],Te=Ce[4];for(dt=0;dt>>24]^ee[$>>16&255]^te[K>>8&255]^fe[Y&255]^N[ue],he=H[$>>>24]^ee[K>>16&255]^te[Y>>8&255]^fe[F&255]^N[ue+1],Q=H[K>>>24]^ee[Y>>16&255]^te[F>>8&255]^fe[$&255]^N[ue+2],Y=H[Y>>>24]^ee[F>>16&255]^te[$>>8&255]^fe[K&255]^N[ue+3],ue+=4,F=ne,$=he,K=Q;for(dt=0;dt<4;dt++)k[(3&-dt)+L]=Te[F>>>24]<<24^Te[$>>16&255]<<16^Te[K>>8&255]<<8^Te[Y&255]^N[ue++],ne=F,F=$,$=K,K=Y,Y=ne}}class s extends t{constructor(){super(t),this.jobs=[],this.delay=1,this.timeout_=null}processJob_(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null}push(I){this.jobs.push(I),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))}}const a=function(w){return w<<24|(w&65280)<<8|(w&16711680)>>8|w>>>24},o=function(w,I,x){const T=new Int32Array(w.buffer,w.byteOffset,w.byteLength>>2),C=new r(Array.prototype.slice.call(I)),k=new Uint8Array(w.byteLength),L=new Int32Array(k.buffer);let N,F,$,K,Y,ne,he,Q,ce;for(N=x[0],F=x[1],$=x[2],K=x[3],ce=0;ce{const T=w[x];v(T)?I[x]={bytes:T.buffer,byteOffset:T.byteOffset,byteLength:T.byteLength}:I[x]=T}),I};self.onmessage=function(w){const I=w.data,x=new Uint8Array(I.encrypted.bytes,I.encrypted.byteOffset,I.encrypted.byteLength),T=new Uint32Array(I.key.bytes,I.key.byteOffset,I.key.byteLength/4),C=new Uint32Array(I.iv.bytes,I.iv.byteOffset,I.iv.byteLength/4);new l(x,T,C,function(k,L){self.postMessage(_({source:I.source,decrypted:L}),[L.buffer])})}}));var YI=px(QI);const JI=t=>{let e=t.default?"main":"alternative";return t.characteristics&&t.characteristics.indexOf("public.accessibility.describes-video")>=0&&(e="main-desc"),e},Px=(t,e)=>{t.abort(),t.pause(),e&&e.activePlaylistLoader&&(e.activePlaylistLoader.pause(),e.activePlaylistLoader=null)},gf=(t,e)=>{e.activePlaylistLoader=t,t.load()},ZI=(t,e)=>()=>{const{segmentLoaders:{[t]:i,main:n},mediaTypes:{[t]:r}}=e,s=r.activeTrack(),a=r.getActiveGroup(),o=r.activePlaylistLoader,l=r.lastGroup_;if(!(a&&l&&a.id===l.id)&&(r.lastGroup_=a,r.lastTrack_=s,Px(i,r),!(!a||a.isMainPlaylist))){if(!a.playlistLoader){o&&n.resetEverything();return}i.resyncLoader(),gf(a.playlistLoader,r)}},e8=(t,e)=>()=>{const{segmentLoaders:{[t]:i},mediaTypes:{[t]:n}}=e;n.lastGroup_=null,i.abort(),i.pause()},t8=(t,e)=>()=>{const{mainPlaylistLoader:i,segmentLoaders:{[t]:n,main:r},mediaTypes:{[t]:s}}=e,a=s.activeTrack(),o=s.getActiveGroup(),l=s.activePlaylistLoader,c=s.lastTrack_;if(!(c&&a&&c.id===a.id)&&(s.lastGroup_=o,s.lastTrack_=a,Px(n,s),!!o)){if(o.isMainPlaylist){if(!a||!c||a.id===c.id)return;const p=e.vhs.playlistController_,g=p.selectPlaylist();if(p.media()===g)return;s.logger_(`track change. Switching main audio from ${c.id} to ${a.id}`),i.pause(),r.resetEverything(),p.fastQualityChange_(g);return}if(t==="AUDIO"){if(!o.playlistLoader){r.setAudio(!0),r.resetEverything();return}n.setAudio(!0),r.setAudio(!1)}if(l===o.playlistLoader){gf(o.playlistLoader,s);return}n.track&&n.track(a),n.resetEverything(),gf(o.playlistLoader,s)}},Bu={AUDIO:(t,e)=>()=>{const{mediaTypes:{[t]:i},excludePlaylist:n}=e,r=i.activeTrack(),s=i.activeGroup(),a=(s.filter(l=>l.default)[0]||s[0]).id,o=i.tracks[a];if(r===o){n({error:{message:"Problem encountered loading the default audio track."}});return}M.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(const l in i.tracks)i.tracks[l].enabled=i.tracks[l]===o;i.onTrackChanged()},SUBTITLES:(t,e)=>()=>{const{mediaTypes:{[t]:i}}=e;M.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track.");const n=i.activeTrack();n&&(n.mode="disabled"),i.onTrackChanged()}},Zy={AUDIO:(t,e,i)=>{if(!e)return;const{tech:n,requestOptions:r,segmentLoaders:{[t]:s}}=i;e.on("loadedmetadata",()=>{const a=e.media();s.playlist(a,r),(!n.paused()||a.endList&&n.preload()!=="none")&&s.load()}),e.on("loadedplaylist",()=>{s.playlist(e.media(),r),n.paused()||s.load()}),e.on("error",Bu[t](t,i))},SUBTITLES:(t,e,i)=>{const{tech:n,requestOptions:r,segmentLoaders:{[t]:s},mediaTypes:{[t]:a}}=i;e.on("loadedmetadata",()=>{const o=e.media();s.playlist(o,r),s.track(a.activeTrack()),(!n.paused()||o.endList&&n.preload()!=="none")&&s.load()}),e.on("loadedplaylist",()=>{s.playlist(e.media(),r),n.paused()||s.load()}),e.on("error",Bu[t](t,i))}},i8={AUDIO:(t,e)=>{const{vhs:i,sourceType:n,segmentLoaders:{[t]:r},requestOptions:s,main:{mediaGroups:a},mediaTypes:{[t]:{groups:o,tracks:l,logger_:c}},mainPlaylistLoader:p}=e,g=Do(p.main);(!a[t]||Object.keys(a[t]).length===0)&&(a[t]={main:{default:{default:!0}}},g&&(a[t].main.default.playlists=p.main.playlists));for(const v in a[t]){o[v]||(o[v]=[]);for(const S in a[t][v]){let _=a[t][v][S],w;if(g?(c(`AUDIO group '${v}' label '${S}' is a main playlist`),_.isMainPlaylist=!0,w=null):n==="vhs-json"&&_.playlists?w=new Qr(_.playlists[0],i,s):_.resolvedUri?w=new Qr(_.resolvedUri,i,s):_.playlists&&n==="dash"?w=new hf(_.playlists[0],i,s,p):w=null,_=ve({id:S,playlistLoader:w},_),Zy[t](t,_.playlistLoader,e),o[v].push(_),typeof l[S]>"u"){const I=new M.AudioTrack({id:S,kind:JI(_),enabled:!1,language:_.language,default:_.default,label:S});l[S]=I}}}r.on("error",Bu[t](t,e))},SUBTITLES:(t,e)=>{const{tech:i,vhs:n,sourceType:r,segmentLoaders:{[t]:s},requestOptions:a,main:{mediaGroups:o},mediaTypes:{[t]:{groups:l,tracks:c}},mainPlaylistLoader:p}=e;for(const g in o[t]){l[g]||(l[g]=[]);for(const v in o[t][g]){if(!n.options_.useForcedSubtitles&&o[t][g][v].forced)continue;let S=o[t][g][v],_;if(r==="hls")_=new Qr(S.resolvedUri,n,a);else if(r==="dash"){if(!S.playlists.filter(I=>I.excludeUntil!==1/0).length)return;_=new hf(S.playlists[0],n,a,p)}else r==="vhs-json"&&(_=new Qr(S.playlists?S.playlists[0]:S.resolvedUri,n,a));if(S=ve({id:v,playlistLoader:_},S),Zy[t](t,S.playlistLoader,e),l[g].push(S),typeof c[v]>"u"){const w=i.addRemoteTextTrack({id:v,kind:"subtitles",default:S.default&&S.autoselect,language:S.language,label:v},!1).track;c[v]=w}}}s.on("error",Bu[t](t,e))},"CLOSED-CAPTIONS":(t,e)=>{const{tech:i,main:{mediaGroups:n},mediaTypes:{[t]:{groups:r,tracks:s}}}=e;for(const a in n[t]){r[a]||(r[a]=[]);for(const o in n[t][a]){const l=n[t][a][o];if(!/^(?:CC|SERVICE)/.test(l.instreamId))continue;const c=i.options_.vhs&&i.options_.vhs.captionServices||{};let p={label:o,language:l.language,instreamId:l.instreamId,default:l.default&&l.autoselect};if(c[p.instreamId]&&(p=ve(p,c[p.instreamId])),p.default===void 0&&delete p.default,r[a].push(ve({id:o},l)),typeof s[o]>"u"){const g=i.addRemoteTextTrack({id:p.instreamId,kind:"captions",default:p.default,language:p.language,label:p.label},!1).track;s[o]=g}}}}},Ix=(t,e)=>{for(let i=0;ii=>{const{mainPlaylistLoader:n,mediaTypes:{[t]:{groups:r}}}=e,s=n.media();if(!s)return null;let a=null;s.attributes[t]&&(a=r[s.attributes[t]]);const o=Object.keys(r);if(!a)if(t==="AUDIO"&&o.length>1&&Do(e.main))for(let l=0;l"u"?a:i===null||!a?null:a.filter(l=>l.id===i.id)[0]||null},r8={AUDIO:(t,e)=>()=>{const{mediaTypes:{[t]:{tracks:i}}}=e;for(const n in i)if(i[n].enabled)return i[n];return null},SUBTITLES:(t,e)=>()=>{const{mediaTypes:{[t]:{tracks:i}}}=e;for(const n in i)if(i[n].mode==="showing"||i[n].mode==="hidden")return i[n];return null}},s8=(t,{mediaTypes:e})=>()=>{const i=e[t].activeTrack();return i?e[t].activeGroup(i):null},a8=t=>{["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(c=>{i8[c](c,t)});const{mediaTypes:e,mainPlaylistLoader:i,tech:n,vhs:r,segmentLoaders:{["AUDIO"]:s,main:a}}=t;["AUDIO","SUBTITLES"].forEach(c=>{e[c].activeGroup=n8(c,t),e[c].activeTrack=r8[c](c,t),e[c].onGroupChanged=ZI(c,t),e[c].onGroupChanging=e8(c,t),e[c].onTrackChanged=t8(c,t),e[c].getActiveGroup=s8(c,t)});const o=e.AUDIO.activeGroup();if(o){const c=(o.filter(g=>g.default)[0]||o[0]).id;e.AUDIO.tracks[c].enabled=!0,e.AUDIO.onGroupChanged(),e.AUDIO.onTrackChanged(),e.AUDIO.getActiveGroup().playlistLoader?(a.setAudio(!1),s.setAudio(!0)):a.setAudio(!0)}i.on("mediachange",()=>{["AUDIO","SUBTITLES"].forEach(c=>e[c].onGroupChanged())}),i.on("mediachanging",()=>{["AUDIO","SUBTITLES"].forEach(c=>e[c].onGroupChanging())});const l=()=>{e.AUDIO.onTrackChanged(),n.trigger({type:"usage",name:"vhs-audio-change"})};n.audioTracks().addEventListener("change",l),n.remoteTextTracks().addEventListener("change",e.SUBTITLES.onTrackChanged),r.on("dispose",()=>{n.audioTracks().removeEventListener("change",l),n.remoteTextTracks().removeEventListener("change",e.SUBTITLES.onTrackChanged)}),n.clearTracks("audio");for(const c in e.AUDIO.tracks)n.audioTracks().addTrack(e.AUDIO.tracks[c])},o8=()=>{const t={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{t[e]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:Wi,activeTrack:Wi,getActiveGroup:Wi,onGroupChanged:Wi,onTrackChanged:Wi,lastTrack_:null,logger_:si(`MediaGroups[${e}]`)}}),t};class ev{constructor(){this.priority_=[]}set version(e){e===1&&(this.version_=e)}set ttl(e){this.ttl_=e||300}set reloadUri(e){e&&(this.reloadUri_=Ft(this.reloadUri_,e))}set priority(e){e&&e.length&&(this.priority_=e)}get version(){return this.version_}get ttl(){return this.ttl_}get reloadUri(){return this.reloadUri_}get priority(){return this.priority_}}class l8 extends M.EventTarget{constructor(e,i){super(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=null,this.availablePathways_=new Set,this.excludedPathways_=new Set,this.steeringManifest=new ev,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.excludedSteeringManifestURLs=new Set,this.logger_=si("Content Steering"),this.xhr_=e,this.getBandwidth_=i}assignTagProperties(e,i){this.manifestType_=i.serverUri?"HLS":"DASH";const n=i.serverUri||i.serverURL;if(!n){this.logger_(`steering manifest URL is ${n}, cannot request steering manifest.`),this.trigger("error");return}if(n.startsWith("data:")){this.decodeDataUriManifest_(n.substring(n.indexOf(",")+1));return}this.steeringManifest.reloadUri=this.queryBeforeStart?n:Ft(e,n),this.defaultPathway=i.pathwayId||i.defaultServiceLocation,this.queryBeforeStart=i.queryBeforeStart||!1,this.proxyServerUrl_=i.proxyServerURL||null,this.defaultPathway&&!this.queryBeforeStart&&this.trigger("content-steering"),this.queryBeforeStart&&this.requestSteeringManifest(this.steeringManifest.reloadUri)}requestSteeringManifest(e){const i=this.steeringManifest.reloadUri;if(!e&&!i)return;const n=e||this.getRequestURI(i);if(!n){this.logger_("No valid content steering manifest URIs. Stopping content steering."),this.trigger("error"),this.dispose();return}this.request_=this.xhr_({uri:n},(r,s)=>{if(r){if(s.status===410){this.logger_(`manifest request 410 ${r}.`),this.logger_(`There will be no more content steering requests to ${n} this session.`),this.excludedSteeringManifestURLs.add(n);return}if(s.status===429){const o=s.responseHeaders["retry-after"];this.logger_(`manifest request 429 ${r}.`),this.logger_(`content steering will retry in ${o} seconds.`),this.startTTLTimeout_(parseInt(o,10));return}this.logger_(`manifest failed to load ${r}.`),this.startTTLTimeout_();return}const a=JSON.parse(this.request_.responseText);this.startTTLTimeout_(),this.assignSteeringProperties_(a)})}setProxyServerUrl_(e){const i=new A.URL(e),n=new A.URL(this.proxyServerUrl_);return n.searchParams.set("url",encodeURI(i.toString())),this.setSteeringParams_(n.toString())}decodeDataUriManifest_(e){const i=JSON.parse(A.atob(e));this.assignSteeringProperties_(i)}setSteeringParams_(e){const i=new A.URL(e),n=this.getPathway(),r=this.getBandwidth_();if(n){const s=`_${this.manifestType_}_pathway`;i.searchParams.set(s,n)}if(r){const s=`_${this.manifestType_}_throughput`;i.searchParams.set(s,r)}return i.toString()}assignSteeringProperties_(e){if(this.steeringManifest.version=e.VERSION,!this.steeringManifest.version){this.logger_(`manifest version is ${e.VERSION}, which is not supported.`),this.trigger("error");return}this.steeringManifest.ttl=e.TTL,this.steeringManifest.reloadUri=e["RELOAD-URI"],this.steeringManifest.priority=e["PATHWAY-PRIORITY"]||e["SERVICE-LOCATION-PRIORITY"],this.availablePathways_.size||(this.logger_("There are no available pathways for content steering. Ending content steering."),this.trigger("error"),this.dispose());const n=(r=>{for(const s of r)if(this.availablePathways_.has(s))return s;return[...this.availablePathways_][0]})(this.steeringManifest.priority);this.currentPathway!==n&&(this.currentPathway=n,this.trigger("content-steering"))}getPathway(){return this.currentPathway||this.defaultPathway}getRequestURI(e){if(!e)return null;const i=r=>this.excludedSteeringManifestURLs.has(r);if(this.proxyServerUrl_){const r=this.setProxyServerUrl_(e);if(!i(r))return r}const n=this.setSteeringParams_(e);return i(n)?null:n}startTTLTimeout_(e=this.steeringManifest.ttl){const i=e*1e3;this.ttlTimeout_=A.setTimeout(()=>{this.requestSteeringManifest()},i)}clearTTLTimeout_(){A.clearTimeout(this.ttlTimeout_),this.ttlTimeout_=null}abort(){this.request_&&this.request_.abort(),this.request_=null}dispose(){this.off("content-steering"),this.off("error"),this.abort(),this.clearTTLTimeout_(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=null,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.excludedSteeringManifestURLs=new Set,this.availablePathways_=new Set,this.excludedPathways_=new Set,this.steeringManifest=new ev}addAvailablePathway(e){e&&this.availablePathways_.add(e)}clearAvailablePathways(){this.availablePathways_.clear()}excludePathway(e){return this.availablePathways_.delete(e)}}const u8=10;let Vi;const c8=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred","mediaAppends"],d8=function(t){return this.audioSegmentLoader_[t]+this.mainSegmentLoader_[t]},h8=function({currentPlaylist:t,buffered:e,currentTime:i,nextPlaylist:n,bufferLowWaterLine:r,bufferHighWaterLine:s,duration:a,bufferBasedABR:o,log:l}){if(!n)return M.log.warn("We received no playlist to switch to. Please check your stream."),!1;const c=`allowing switch ${t&&t.id||"null"} -> ${n.id}`;if(!t)return l(`${c} as current playlist is not set`),!0;if(n.id===t.id)return!1;const p=!!Kr(e,i).length;if(!t.endList)return!p&&typeof t.partTargetDuration=="number"?(l(`not ${c} as current playlist is live llhls, but currentTime isn't in buffered.`),!1):(l(`${c} as current playlist is live`),!0);const g=um(e,i),v=o?Qe.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:Qe.MAX_BUFFER_LOW_WATER_LINE;if(a_)&&g>=r){let w=`${c} as forwardBuffer >= bufferLowWaterLine (${g} >= ${r})`;return o&&(w+=` and next bandwidth > current bandwidth (${S} > ${_})`),l(w),!0}return l(`not ${c} as no switching criteria met`),!1};class f8 extends M.EventTarget{constructor(e){super();const{src:i,withCredentials:n,tech:r,bandwidth:s,externVhs:a,useCueTags:o,playlistExclusionDuration:l,enableLowInitialPlaylist:c,sourceType:p,cacheEncryptionKeys:g,bufferBasedABR:v,leastPixelDiffSelector:S,captionServices:_}=e;if(!i)throw new Error("A non-empty playlist URL or JSON manifest string is required");let{maxPlaylistRetries:w}=e;(w===null||typeof w>"u")&&(w=1/0),Vi=a,this.bufferBasedABR=!!v,this.leastPixelDiffSelector=!!S,this.withCredentials=n,this.tech_=r,this.vhs_=r.vhs,this.sourceType_=p,this.useCueTags_=o,this.playlistExclusionDuration=l,this.maxPlaylistRetries=w,this.enableLowInitialPlaylist=c,this.useCueTags_&&(this.cueTagsTrack_=this.tech_.addTextTrack("metadata","ad-cues"),this.cueTagsTrack_.inBandMetadataTrackDispatchType=""),this.requestOptions_={withCredentials:n,maxPlaylistRetries:w,timeout:null},this.on("error",this.pauseLoading),this.mediaTypes_=o8(),this.mediaSource=new A.MediaSource,this.handleDurationChange_=this.handleDurationChange_.bind(this),this.handleSourceOpen_=this.handleSourceOpen_.bind(this),this.handleSourceEnded_=this.handleSourceEnded_.bind(this),this.mediaSource.addEventListener("durationchange",this.handleDurationChange_),this.mediaSource.addEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.addEventListener("sourceended",this.handleSourceEnded_),this.seekable_=ot(),this.hasPlayed_=!1,this.syncController_=new XI(e),this.segmentMetadataTrack_=r.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,this.decrypter_=new YI,this.sourceUpdater_=new kx(this.mediaSource),this.inbandTextTracks_={},this.timelineChangeController_=new KI;const I={vhs:this.vhs_,parse708captions:e.parse708captions,useDtsForTimestampOffset:e.useDtsForTimestampOffset,calculateTimestampOffsetForEachSegment:e.calculateTimestampOffsetForEachSegment,captionServices:_,mediaSource:this.mediaSource,currentTime:this.tech_.currentTime.bind(this.tech_),seekable:()=>this.seekable(),seeking:()=>this.tech_.seeking(),duration:()=>this.duration(),hasPlayed:()=>this.hasPlayed_,goalBufferLength:()=>this.goalBufferLength(),bandwidth:s,syncController:this.syncController_,decrypter:this.decrypter_,sourceType:this.sourceType_,inbandTextTracks:this.inbandTextTracks_,cacheEncryptionKeys:g,sourceUpdater:this.sourceUpdater_,timelineChangeController:this.timelineChangeController_,exactManifestTimings:e.exactManifestTimings,addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)};this.mainPlaylistLoader_=this.sourceType_==="dash"?new hf(i,this.vhs_,ve(this.requestOptions_,{addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)})):new Qr(i,this.vhs_,ve(this.requestOptions_,{addDateRangesToTextTrack:this.addDateRangesToTextTrack_.bind(this)})),this.setupMainPlaylistLoaderListeners_(),this.mainSegmentLoader_=new pf(ve(I,{segmentMetadataTrack:this.segmentMetadataTrack_,loaderType:"main"}),e),this.audioSegmentLoader_=new pf(ve(I,{loaderType:"audio"}),e),this.subtitleSegmentLoader_=new HI(ve(I,{loaderType:"vtt",featuresNativeTextTracks:this.tech_.featuresNativeTextTracks,loadVttJs:()=>new Promise((C,k)=>{function L(){r.off("vttjserror",N),C()}function N(){r.off("vttjsloaded",L),k()}r.one("vttjsloaded",L),r.one("vttjserror",N),r.addWebVttScript_()})}),e);const x=()=>this.mainSegmentLoader_.bandwidth;this.contentSteeringController_=new l8(this.vhs_.xhr,x),this.setupSegmentLoaderListeners_(),this.bufferBasedABR&&(this.mainPlaylistLoader_.one("loadedplaylist",()=>this.startABRTimer_()),this.tech_.on("pause",()=>this.stopABRTimer_()),this.tech_.on("play",()=>this.startABRTimer_())),c8.forEach(C=>{this[C+"_"]=d8.bind(this,C)}),this.logger_=si("pc"),this.triggeredFmp4Usage=!1,this.tech_.preload()==="none"?(this.loadOnPlay_=()=>{this.loadOnPlay_=null,this.mainPlaylistLoader_.load()},this.tech_.one("play",this.loadOnPlay_)):this.mainPlaylistLoader_.load(),this.timeToLoadedData__=-1,this.mainAppendsToLoadedData__=-1,this.audioAppendsToLoadedData__=-1;const T=this.tech_.preload()==="none"?"play":"loadstart";this.tech_.one(T,()=>{const C=Date.now();this.tech_.one("loadeddata",()=>{this.timeToLoadedData__=Date.now()-C,this.mainAppendsToLoadedData__=this.mainSegmentLoader_.mediaAppends,this.audioAppendsToLoadedData__=this.audioSegmentLoader_.mediaAppends})})}mainAppendsToLoadedData_(){return this.mainAppendsToLoadedData__}audioAppendsToLoadedData_(){return this.audioAppendsToLoadedData__}appendsToLoadedData_(){const e=this.mainAppendsToLoadedData_(),i=this.audioAppendsToLoadedData_();return e===-1||i===-1?-1:e+i}timeToLoadedData_(){return this.timeToLoadedData__}checkABR_(e="abr"){const i=this.selectPlaylist();i&&this.shouldSwitchToMedia_(i)&&this.switchMedia_(i,e)}switchMedia_(e,i,n){const r=this.media(),s=r&&(r.id||r.uri),a=e.id||e.uri;s&&s!==a&&(this.logger_(`switch media ${s} -> ${a} from ${i}`),this.tech_.trigger({type:"usage",name:`vhs-rendition-change-${i}`})),this.mainPlaylistLoader_.media(e,n)}switchMediaForDASHContentSteering_(){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{const i=this.mediaTypes_[e],n=i?i.activeGroup():null,r=this.contentSteeringController_.getPathway();if(n&&r){const a=(n.length?n[0].playlists:n.playlists).filter(o=>o.attributes.serviceLocation===r);a.length&&this.mediaTypes_[e].activePlaylistLoader.media(a[0])}})}startABRTimer_(){this.stopABRTimer_(),this.abrTimer_=A.setInterval(()=>this.checkABR_(),250)}stopABRTimer_(){this.tech_.scrubbing&&this.tech_.scrubbing()||(A.clearInterval(this.abrTimer_),this.abrTimer_=null)}getAudioTrackPlaylists_(){const e=this.main(),i=e&&e.playlists||[];if(!e||!e.mediaGroups||!e.mediaGroups.AUDIO)return i;const n=e.mediaGroups.AUDIO,r=Object.keys(n);let s;if(Object.keys(this.mediaTypes_.AUDIO.groups).length)s=this.mediaTypes_.AUDIO.activeTrack();else{const o=n.main||r.length&&n[r[0]];for(const l in o)if(o[l].default){s={label:l};break}}if(!s)return i;const a=[];for(const o in n)if(n[o][s.label]){const l=n[o][s.label];if(l.playlists&&l.playlists.length)a.push.apply(a,l.playlists);else if(l.uri)a.push(l);else if(e.playlists.length)for(let c=0;c{const e=this.mainPlaylistLoader_.media(),i=e.targetDuration*1.5*1e3;of(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=i,e.endList&&this.tech_.preload()!=="none"&&(this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.mainSegmentLoader_.load()),a8({sourceType:this.sourceType_,segmentLoaders:{AUDIO:this.audioSegmentLoader_,SUBTITLES:this.subtitleSegmentLoader_,main:this.mainSegmentLoader_},tech:this.tech_,requestOptions:this.requestOptions_,mainPlaylistLoader:this.mainPlaylistLoader_,vhs:this.vhs_,main:this.main(),mediaTypes:this.mediaTypes_,excludePlaylist:this.excludePlaylist.bind(this)}),this.triggerPresenceUsage_(this.main(),e),this.setupFirstPlay(),!this.mediaTypes_.AUDIO.activePlaylistLoader||this.mediaTypes_.AUDIO.activePlaylistLoader.media()?this.trigger("selectedinitialmedia"):this.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",()=>{this.trigger("selectedinitialmedia")})}),this.mainPlaylistLoader_.on("loadedplaylist",()=>{this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_);let e=this.mainPlaylistLoader_.media();if(!e){this.initContentSteeringController_(),this.excludeUnsupportedVariants_();let i;if(this.enableLowInitialPlaylist&&(i=this.selectInitialPlaylist()),i||(i=this.selectPlaylist()),!i||!this.shouldSwitchToMedia_(i)||(this.initialMedia_=i,this.switchMedia_(this.initialMedia_,"initial"),!(this.sourceType_==="vhs-json"&&this.initialMedia_.segments)))return;e=this.initialMedia_}this.handleUpdatedMediaPlaylist(e)}),this.mainPlaylistLoader_.on("error",()=>{const e=this.mainPlaylistLoader_.error;this.excludePlaylist({playlistToExclude:e.playlist,error:e})}),this.mainPlaylistLoader_.on("mediachanging",()=>{this.mainSegmentLoader_.abort(),this.mainSegmentLoader_.pause()}),this.mainPlaylistLoader_.on("mediachange",()=>{const e=this.mainPlaylistLoader_.media(),i=e.targetDuration*1.5*1e3;of(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=i,this.mainPlaylistLoader_.load(),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.mainSegmentLoader_.load(),this.tech_.trigger({type:"mediachange",bubbles:!0})}),this.mainPlaylistLoader_.on("playlistunchanged",()=>{const e=this.mainPlaylistLoader_.media();if(e.lastExcludeReason_==="playlist-unchanged")return;this.stuckAtPlaylistEnd_(e)&&(this.excludePlaylist({error:{message:"Playlist no longer updating.",reason:"playlist-unchanged"}}),this.tech_.trigger("playliststuck"))}),this.mainPlaylistLoader_.on("renditiondisabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-disabled"})}),this.mainPlaylistLoader_.on("renditionenabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-enabled"})})}handleUpdatedMediaPlaylist(e){this.useCueTags_&&this.updateAdCues_(e),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.updateDuration(!e.endList),this.tech_.paused()||(this.mainSegmentLoader_.load(),this.audioSegmentLoader_&&this.audioSegmentLoader_.load())}triggerPresenceUsage_(e,i){const n=e.mediaGroups||{};let r=!0;const s=Object.keys(n.AUDIO);for(const a in n.AUDIO)for(const o in n.AUDIO[a])n.AUDIO[a][o].uri||(r=!1);r&&this.tech_.trigger({type:"usage",name:"vhs-demuxed"}),Object.keys(n.SUBTITLES).length&&this.tech_.trigger({type:"usage",name:"vhs-webvtt"}),Vi.Playlist.isAes(i)&&this.tech_.trigger({type:"usage",name:"vhs-aes"}),s.length&&Object.keys(n.AUDIO[s[0]]).length>1&&this.tech_.trigger({type:"usage",name:"vhs-alternate-audio"}),this.useCueTags_&&this.tech_.trigger({type:"usage",name:"vhs-playlist-cue-tags"})}shouldSwitchToMedia_(e){const i=this.mainPlaylistLoader_.media()||this.mainPlaylistLoader_.pendingMedia_,n=this.tech_.currentTime(),r=this.bufferLowWaterLine(),s=this.bufferHighWaterLine(),a=this.tech_.buffered();return h8({buffered:a,currentTime:n,currentPlaylist:i,nextPlaylist:e,bufferLowWaterLine:r,bufferHighWaterLine:s,duration:this.duration(),bufferBasedABR:this.bufferBasedABR,log:this.logger_})}setupSegmentLoaderListeners_(){this.mainSegmentLoader_.on("bandwidthupdate",()=>{this.checkABR_("bandwidthupdate"),this.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("timeout",()=>{this.bufferBasedABR&&this.mainSegmentLoader_.load()}),this.bufferBasedABR||this.mainSegmentLoader_.on("progress",()=>{this.trigger("progress")}),this.mainSegmentLoader_.on("error",()=>{const i=this.mainSegmentLoader_.error();this.excludePlaylist({playlistToExclude:i.playlist,error:i})}),this.mainSegmentLoader_.on("appenderror",()=>{this.error=this.mainSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",()=>{this.tech_.trigger({type:"usage",name:"vhs-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.audioSegmentLoader_.on("appenderror",()=>{this.error=this.audioSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("ended",()=>{this.logger_("main segment loader ended"),this.onEndOfStream()}),this.mainSegmentLoader_.on("earlyabort",i=>{this.bufferBasedABR||(this.delegateLoaders_("all",["abort"]),this.excludePlaylist({error:{message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},playlistExclusionDuration:u8}))});const e=()=>{if(!this.sourceUpdater_.hasCreatedSourceBuffers())return this.tryToCreateSourceBuffers_();const i=this.getCodecsOrExclude_();i&&this.sourceUpdater_.addOrChangeSourceBuffers(i)};this.mainSegmentLoader_.on("trackinfo",e),this.audioSegmentLoader_.on("trackinfo",e),this.mainSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("ended",()=>{this.logger_("audioSegmentLoader ended"),this.onEndOfStream()})}mediaSecondsLoaded_(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}load(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()}fastQualityChange_(e=this.selectPlaylist()){if(e===this.mainPlaylistLoader_.media()){this.logger_("skipping fastQualityChange because new media is same as old");return}this.switchMedia_(e,"fast-quality"),this.resetMainLoaderReplaceSegments()}resetMainLoaderReplaceSegments(){const e=this.tech_.buffered(),i=e.end(e.length-1);this.mainSegmentLoader_.replaceSegmentsUntil=i,this.mainSegmentLoader_.resetLoaderProperties(),this.mainSegmentLoader_.resetLoader()}play(){if(this.setupFirstPlay())return;this.tech_.ended()&&this.tech_.setCurrentTime(0),this.hasPlayed_&&this.load();const e=this.tech_.seekable();if(this.tech_.duration()===1/0&&this.tech_.currentTime(){})}this.trigger("sourceopen")}handleSourceEnded_(){if(!this.inbandTextTracks_.metadataTrack_)return;const e=this.inbandTextTracks_.metadataTrack_.cues;if(!e||!e.length)return;const i=this.duration();e[e.length-1].endTime=isNaN(i)||Math.abs(i)===1/0?Number.MAX_VALUE:i}handleDurationChange_(){this.tech_.trigger("durationchange")}onEndOfStream(){let e=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader){const i=this.mainSegmentLoader_.getCurrentMediaInfo_();!i||i.hasVideo?e=e&&this.audioSegmentLoader_.ended_:e=this.audioSegmentLoader_.ended_}e&&(this.stopABRTimer_(),this.sourceUpdater_.endOfStream())}stuckAtPlaylistEnd_(e){if(!this.seekable().length)return!1;const n=this.syncController_.getExpiredTime(e,this.duration());if(n===null)return!1;const r=Vi.Playlist.playlistEnd(e,n),s=this.tech_.currentTime(),a=this.tech_.buffered();if(!a.length)return r-s<=wi;const o=a.end(a.length-1);return o-s<=wi&&r-o<=wi}excludePlaylist({playlistToExclude:e=this.mainPlaylistLoader_.media(),error:i={},playlistExclusionDuration:n}){if(e=e||this.mainPlaylistLoader_.media(),n=n||i.playlistExclusionDuration||this.playlistExclusionDuration,!e){this.error=i,this.mediaSource.readyState!=="open"?this.trigger("error"):this.sourceUpdater_.endOfStream("network");return}e.playlistErrors_++;const r=this.mainPlaylistLoader_.main.playlists,s=r.filter(Ac),a=s.length===1&&s[0]===e;if(r.length===1&&n!==1/0)return M.log.warn(`Problem encountered with playlist ${e.id}. Trying again since it is the only playlist.`),this.tech_.trigger("retryplaylist"),this.mainPlaylistLoader_.load(a);if(a){if(this.main().contentSteering){const _=this.pathwayAttribute_(e),w=this.contentSteeringController_.steeringManifest.ttl*1e3;this.contentSteeringController_.excludePathway(_),this.excludeThenChangePathway_(),setTimeout(()=>{this.contentSteeringController_.addAvailablePathway(_)},w);return}let S=!1;r.forEach(_=>{if(_===e)return;const w=_.excludeUntil;typeof w<"u"&&w!==1/0&&(S=!0,delete _.excludeUntil)}),S&&(M.log.warn("Removing other playlists from the exclusion list because the last rendition is about to be excluded."),this.tech_.trigger("retryplaylist"))}let o;e.playlistErrors_>this.maxPlaylistRetries?o=1/0:o=Date.now()+n*1e3,e.excludeUntil=o,i.reason&&(e.lastExcludeReason_=i.reason),this.tech_.trigger("excludeplaylist"),this.tech_.trigger({type:"usage",name:"vhs-rendition-excluded"});const l=this.selectPlaylist();if(!l){this.error="Playback cannot continue. No available working or supported playlists.",this.trigger("error");return}const c=i.internal?this.logger_:M.log.warn,p=i.message?" "+i.message:"";c(`${i.internal?"Internal problem":"Problem"} encountered with playlist ${e.id}.${p} Switching to playlist ${l.id}.`),l.attributes.AUDIO!==e.attributes.AUDIO&&this.delegateLoaders_("audio",["abort","pause"]),l.attributes.SUBTITLES!==e.attributes.SUBTITLES&&this.delegateLoaders_("subtitle",["abort","pause"]),this.delegateLoaders_("main",["abort","pause"]);const g=l.targetDuration/2*1e3||5*1e3,v=typeof l.lastRequest=="number"&&Date.now()-l.lastRequest<=g;return this.switchMedia_(l,"exclude",a||v)}pauseLoading(){this.delegateLoaders_("all",["abort","pause"]),this.stopABRTimer_()}delegateLoaders_(e,i){const n=[],r=e==="all";(r||e==="main")&&n.push(this.mainPlaylistLoader_);const s=[];(r||e==="audio")&&s.push("AUDIO"),(r||e==="subtitle")&&(s.push("CLOSED-CAPTIONS"),s.push("SUBTITLES")),s.forEach(a=>{const o=this.mediaTypes_[a]&&this.mediaTypes_[a].activePlaylistLoader;o&&n.push(o)}),["main","audio","subtitle"].forEach(a=>{const o=this[`${a}SegmentLoader_`];o&&(e===a||e==="all")&&n.push(o)}),n.forEach(a=>i.forEach(o=>{typeof a[o]=="function"&&a[o]()}))}setCurrentTime(e){const i=Kr(this.tech_.buffered(),e);if(!(this.mainPlaylistLoader_&&this.mainPlaylistLoader_.media())||!this.mainPlaylistLoader_.media().segments)return 0;if(i&&i.length)return e;this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.resetEverything(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.resetEverything(),this.load()}duration(){if(!this.mainPlaylistLoader_)return 0;const e=this.mainPlaylistLoader_.media();return e?e.endList?this.mediaSource?this.mediaSource.duration:Vi.Playlist.duration(e):1/0:0}seekable(){return this.seekable_}onSyncInfoUpdate_(){let e;if(!this.mainPlaylistLoader_)return;let i=this.mainPlaylistLoader_.media();if(!i)return;let n=this.syncController_.getExpiredTime(i,this.duration());if(n===null)return;const r=this.mainPlaylistLoader_.main,s=Vi.Playlist.seekable(i,n,Vi.Playlist.liveEdgeDelay(r,i));if(s.length===0||this.mediaTypes_.AUDIO.activePlaylistLoader&&(i=this.mediaTypes_.AUDIO.activePlaylistLoader.media(),n=this.syncController_.getExpiredTime(i,this.duration()),n===null||(e=Vi.Playlist.seekable(i,n,Vi.Playlist.liveEdgeDelay(r,i)),e.length===0)))return;let a,o;this.seekable_&&this.seekable_.length&&(a=this.seekable_.end(0),o=this.seekable_.start(0)),e?e.start(0)>s.end(0)||s.start(0)>e.end(0)?this.seekable_=s:this.seekable_=ot([[e.start(0)>s.start(0)?e.start(0):s.start(0),e.end(0)0&&(n=Math.max(n,i.end(i.length-1))),this.mediaSource.duration!==n&&this.sourceUpdater_.setDuration(n)}dispose(){this.trigger("dispose"),this.decrypter_.terminate(),this.mainPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),this.contentSteeringController_.dispose(),this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_),["AUDIO","SUBTITLES"].forEach(e=>{const i=this.mediaTypes_[e].groups;for(const n in i)i[n].forEach(r=>{r.playlistLoader&&r.playlistLoader.dispose()})}),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose(),this.sourceUpdater_.dispose(),this.timelineChangeController_.dispose(),this.stopABRTimer_(),this.updateDuration_&&this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.mediaSource.removeEventListener("durationchange",this.handleDurationChange_),this.mediaSource.removeEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.removeEventListener("sourceended",this.handleSourceEnded_),this.off()}main(){return this.mainPlaylistLoader_.main}media(){return this.mainPlaylistLoader_.media()||this.initialMedia_}areMediaTypesKnown_(){const e=!!this.mediaTypes_.AUDIO.activePlaylistLoader,i=!!this.mainSegmentLoader_.getCurrentMediaInfo_(),n=e?!!this.audioSegmentLoader_.getCurrentMediaInfo_():!0;return!(!i||!n)}getCodecsOrExclude_(){const e={main:this.mainSegmentLoader_.getCurrentMediaInfo_()||{},audio:this.audioSegmentLoader_.getCurrentMediaInfo_()||{}},i=this.mainSegmentLoader_.getPendingSegmentPlaylist()||this.media();e.video=e.main;const n=Ua(this.main(),i),r={},s=!!this.mediaTypes_.AUDIO.activePlaylistLoader;if(e.main.hasVideo&&(r.video=n.video||e.main.videoCodec||MA),e.main.isMuxed&&(r.video+=`,${n.audio||e.main.audioCodec||R0}`),(e.main.hasAudio&&!e.main.isMuxed||e.audio.hasAudio||s)&&(r.audio=n.audio||e.main.audioCodec||e.audio.audioCodec||R0,e.audio.isFmp4=e.main.hasAudio&&!e.main.isMuxed?e.main.isFmp4:e.audio.isFmp4),!r.audio&&!r.video){this.excludePlaylist({playlistToExclude:i,error:{message:"Could not determine codecs for playlist."},playlistExclusionDuration:1/0});return}const a=(c,p)=>c?Bl(p):Pd(p),o={};let l;if(["video","audio"].forEach(function(c){if(r.hasOwnProperty(c)&&!a(e[c].isFmp4,r[c])){const p=e[c].isFmp4?"browser":"muxer";o[p]=o[p]||[],o[p].push(r[c]),c==="audio"&&(l=p)}}),s&&l&&i.attributes.AUDIO){const c=i.attributes.AUDIO;this.main().playlists.forEach(p=>{(p.attributes&&p.attributes.AUDIO)===c&&p!==i&&(p.excludeUntil=1/0)}),this.logger_(`excluding audio group ${c} as ${l} does not support codec(s): "${r.audio}"`)}if(Object.keys(o).length){const c=Object.keys(o).reduce((p,g)=>(p&&(p+=", "),p+=`${g} does not support codec(s): "${o[g].join(",")}"`,p),"")+".";this.excludePlaylist({playlistToExclude:i,error:{internal:!0,message:c},playlistExclusionDuration:1/0});return}if(this.sourceUpdater_.hasCreatedSourceBuffers()&&!this.sourceUpdater_.canChangeType()){const c=[];if(["video","audio"].forEach(p=>{const g=(Si(this.sourceUpdater_.codecs[p]||"")[0]||{}).type,v=(Si(r[p]||"")[0]||{}).type;g&&v&&g.toLowerCase()!==v.toLowerCase()&&c.push(`"${this.sourceUpdater_.codecs[p]}" -> "${r[p]}"`)}),c.length){this.excludePlaylist({playlistToExclude:i,error:{message:`Codec switching not supported: ${c.join(", ")}.`,internal:!0},playlistExclusionDuration:1/0});return}}return r}tryToCreateSourceBuffers_(){if(this.mediaSource.readyState!=="open"||this.sourceUpdater_.hasCreatedSourceBuffers()||!this.areMediaTypesKnown_())return;const e=this.getCodecsOrExclude_();if(!e)return;this.sourceUpdater_.createSourceBuffers(e);const i=[e.video,e.audio].filter(Boolean).join(",");this.excludeIncompatibleVariants_(i)}excludeUnsupportedVariants_(){const e=this.main().playlists,i=[];Object.keys(e).forEach(n=>{const r=e[n];if(i.indexOf(r.id)!==-1)return;i.push(r.id);const s=Ua(this.main,r),a=[];s.audio&&!Pd(s.audio)&&!Bl(s.audio)&&a.push(`audio codec ${s.audio}`),s.video&&!Pd(s.video)&&!Bl(s.video)&&a.push(`video codec ${s.video}`),s.text&&s.text==="stpp.ttml.im1t"&&a.push(`text codec ${s.text}`),a.length&&(r.excludeUntil=1/0,this.logger_(`excluding ${r.id} for unsupported: ${a.join(", ")}`))})}excludeIncompatibleVariants_(e){const i=[],n=this.main().playlists,r=Ru(Si(e)),s=jy(r),a=r.video&&Si(r.video)[0]||null,o=r.audio&&Si(r.audio)[0]||null;Object.keys(n).forEach(l=>{const c=n[l];if(i.indexOf(c.id)!==-1||c.excludeUntil===1/0)return;i.push(c.id);const p=[],g=Ua(this.mainPlaylistLoader_.main,c),v=jy(g);if(!(!g.audio&&!g.video)){if(v!==s&&p.push(`codec count "${v}" !== "${s}"`),!this.sourceUpdater_.canChangeType()){const S=g.video&&Si(g.video)[0]||null,_=g.audio&&Si(g.audio)[0]||null;S&&a&&S.type.toLowerCase()!==a.type.toLowerCase()&&p.push(`video codec "${S.type}" !== "${a.type}"`),_&&o&&_.type.toLowerCase()!==o.type.toLowerCase()&&p.push(`audio codec "${_.type}" !== "${o.type}"`)}p.length&&(c.excludeUntil=1/0,this.logger_(`excluding ${c.id}: ${p.join(" && ")}`))}})}updateAdCues_(e){let i=0;const n=this.seekable();n.length&&(i=n.start(0)),WI(e,this.cueTagsTrack_,i)}goalBufferLength(){const e=this.tech_.currentTime(),i=Qe.GOAL_BUFFER_LENGTH,n=Qe.GOAL_BUFFER_LENGTH_RATE,r=Math.max(i,Qe.MAX_GOAL_BUFFER_LENGTH);return Math.min(i+e*n,r)}bufferLowWaterLine(){const e=this.tech_.currentTime(),i=Qe.BUFFER_LOW_WATER_LINE,n=Qe.BUFFER_LOW_WATER_LINE_RATE,r=Math.max(i,Qe.MAX_BUFFER_LOW_WATER_LINE),s=Math.max(i,Qe.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE);return Math.min(i+e*n,this.bufferBasedABR?s:r)}bufferHighWaterLine(){return Qe.BUFFER_HIGH_WATER_LINE}addDateRangesToTextTrack_(e){zy(this.inbandTextTracks_,"com.apple.streaming",this.tech_),AI({inbandTextTracks:this.inbandTextTracks_,dateRanges:e})}addMetadataToTextTrack(e,i,n){const r=this.sourceUpdater_.videoBuffer?this.sourceUpdater_.videoTimestampOffset():this.sourceUpdater_.audioTimestampOffset();zy(this.inbandTextTracks_,e,this.tech_),CI({inbandTextTracks:this.inbandTextTracks_,metadataArray:i,timestampOffset:r,videoDuration:n})}pathwayAttribute_(e){return e.attributes["PATHWAY-ID"]||e.attributes.serviceLocation}initContentSteeringController_(){const e=this.main();if(!e.contentSteering)return;const i=n=>{for(const r of n.playlists)this.contentSteeringController_.addAvailablePathway(this.pathwayAttribute_(r));this.contentSteeringController_.assignTagProperties(n.uri,n.contentSteering)};i(e),this.contentSteeringController_.on("content-steering",this.excludeThenChangePathway_.bind(this)),this.sourceType_==="dash"&&this.mainPlaylistLoader_.on("mediaupdatetimeout",()=>{this.mainPlaylistLoader_.refreshMedia_(this.mainPlaylistLoader_.media().id),this.contentSteeringController_.abort(),this.contentSteeringController_.clearTTLTimeout_(),this.contentSteeringController_.clearAvailablePathways(),i(this.main())}),this.contentSteeringController_.queryBeforeStart||this.tech_.one("canplay",()=>{this.contentSteeringController_.requestSteeringManifest()})}excludeThenChangePathway_(){const e=this.contentSteeringController_.getPathway();if(!e)return;const n=this.main().playlists,r=new Set;let s=!1;Object.keys(n).forEach(a=>{const o=n[a],l=this.pathwayAttribute_(o),c=l&&e!==l;o.excludeUntil===1/0&&o.lastExcludeReason_==="content-steering"&&!c&&(delete o.excludeUntil,delete o.lastExcludeReason_,s=!0);const g=!o.excludeUntil&&o.excludeUntil!==1/0;!r.has(o.id)&&c&&g&&(r.add(o.id),o.excludeUntil=1/0,o.lastExcludeReason_="content-steering",this.logger_(`excluding ${o.id} for ${o.lastExcludeReason_}`))}),this.contentSteeringController_.manifestType_==="DASH"&&Object.keys(this.mediaTypes_).forEach(a=>{const o=this.mediaTypes_[a];if(o.activePlaylistLoader){const l=o.activePlaylistLoader.media_;l&&l.attributes.serviceLocation!==e&&(s=!0)}}),s&&this.changeSegmentPathway_()}changeSegmentPathway_(){const e=this.selectPlaylist();this.pauseLoading(),this.contentSteeringController_.manifestType_==="DASH"&&this.switchMediaForDASHContentSteering_(),this.switchMedia_(e,"content-steering")}}const p8=(t,e,i)=>n=>{const r=t.main.playlists[e],s=dm(r),a=Ac(r);return typeof n>"u"?a:(n?delete r.disabled:r.disabled=!0,n!==a&&!s&&(i(),n?t.trigger("renditionenabled"):t.trigger("renditiondisabled")),n)};class m8{constructor(e,i,n){const{playlistController_:r}=e,s=r.fastQualityChange_.bind(r);if(i.attributes){const a=i.attributes.RESOLUTION;this.width=a&&a.width,this.height=a&&a.height,this.bandwidth=i.attributes.BANDWIDTH,this.frameRate=i.attributes["FRAME-RATE"]}this.codecs=Ua(r.main(),i),this.playlist=i,this.id=n,this.enabled=p8(e.playlists,i.id,s)}}const g8=function(t){t.representations=()=>{const e=t.playlistController_.main(),i=Do(e)?t.playlistController_.getAudioTrackPlaylists_():e.playlists;return i?i.filter(n=>!dm(n)).map((n,r)=>new m8(t,n,n.id)):[]}},tv=["seeking","seeked","pause","playing","error"];class y8{constructor(e){this.playlistController_=e.playlistController,this.tech_=e.tech,this.seekable=e.seekable,this.allowSeeksWithinUnsafeLiveWindow=e.allowSeeksWithinUnsafeLiveWindow,this.liveRangeSafeTimeDelta=e.liveRangeSafeTimeDelta,this.media=e.media,this.consecutiveUpdates=0,this.lastRecordedTime=null,this.checkCurrentTimeTimeout_=null,this.logger_=si("PlaybackWatcher"),this.logger_("initialize");const i=()=>this.monitorCurrentTime_(),n=()=>this.monitorCurrentTime_(),r=()=>this.techWaiting_(),s=()=>this.resetTimeUpdate_(),a=this.playlistController_,o=["main","subtitle","audio"],l={};o.forEach(p=>{l[p]={reset:()=>this.resetSegmentDownloads_(p),updateend:()=>this.checkSegmentDownloads_(p)},a[`${p}SegmentLoader_`].on("appendsdone",l[p].updateend),a[`${p}SegmentLoader_`].on("playlistupdate",l[p].reset),this.tech_.on(["seeked","seeking"],l[p].reset)});const c=p=>{["main","audio"].forEach(g=>{a[`${g}SegmentLoader_`][p]("appended",this.seekingAppendCheck_)})};this.seekingAppendCheck_=()=>{this.fixesBadSeeks_()&&(this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime(),c("off"))},this.clearSeekingAppendCheck_=()=>c("off"),this.watchForBadSeeking_=()=>{this.clearSeekingAppendCheck_(),c("on")},this.tech_.on("seeked",this.clearSeekingAppendCheck_),this.tech_.on("seeking",this.watchForBadSeeking_),this.tech_.on("waiting",r),this.tech_.on(tv,s),this.tech_.on("canplay",n),this.tech_.one("play",i),this.dispose=()=>{this.clearSeekingAppendCheck_(),this.logger_("dispose"),this.tech_.off("waiting",r),this.tech_.off(tv,s),this.tech_.off("canplay",n),this.tech_.off("play",i),this.tech_.off("seeking",this.watchForBadSeeking_),this.tech_.off("seeked",this.clearSeekingAppendCheck_),o.forEach(p=>{a[`${p}SegmentLoader_`].off("appendsdone",l[p].updateend),a[`${p}SegmentLoader_`].off("playlistupdate",l[p].reset),this.tech_.off(["seeked","seeking"],l[p].reset)}),this.checkCurrentTimeTimeout_&&A.clearTimeout(this.checkCurrentTimeTimeout_),this.resetTimeUpdate_()}}monitorCurrentTime_(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&A.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=A.setTimeout(this.monitorCurrentTime_.bind(this),250)}resetSegmentDownloads_(e){const i=this.playlistController_[`${e}SegmentLoader_`];this[`${e}StalledDownloads_`]>0&&this.logger_(`resetting possible stalled download count for ${e} loader`),this[`${e}StalledDownloads_`]=0,this[`${e}Buffered_`]=i.buffered_()}checkSegmentDownloads_(e){const i=this.playlistController_,n=i[`${e}SegmentLoader_`],r=n.buffered_(),s=aP(this[`${e}Buffered_`],r);if(this[`${e}Buffered_`]=r,s){this.resetSegmentDownloads_(e);return}this[`${e}StalledDownloads_`]++,this.logger_(`found #${this[`${e}StalledDownloads_`]} ${e} appends that did not increase buffer (possible stalled download)`,{playlistId:n.playlist_&&n.playlist_.id,buffered:nr(r)}),!(this[`${e}StalledDownloads_`]<10)&&(this.logger_(`${e} loader stalled download exclusion`),this.resetSegmentDownloads_(e),this.tech_.trigger({type:"usage",name:`vhs-${e}-download-exclusion`}),e!=="subtitle"&&i.excludePlaylist({error:{message:`Excessive ${e} segment downloading detected.`},playlistExclusionDuration:1/0}))}checkCurrentTime_(){if(this.tech_.paused()||this.tech_.seeking())return;const e=this.tech_.currentTime(),i=this.tech_.buffered();if(this.lastRecordedTime===e&&(!i.length||e+wi>=i.end(i.length-1)))return this.techWaiting_();this.consecutiveUpdates>=5&&e===this.lastRecordedTime?(this.consecutiveUpdates++,this.waiting_()):e===this.lastRecordedTime?this.consecutiveUpdates++:(this.consecutiveUpdates=0,this.lastRecordedTime=e)}resetTimeUpdate_(){this.consecutiveUpdates=0}fixesBadSeeks_(){if(!this.tech_.seeking())return!1;const i=this.seekable(),n=this.tech_.currentTime(),r=this.afterSeekableWindow_(i,n,this.media(),this.allowSeeksWithinUnsafeLiveWindow);let s;if(r&&(s=i.end(i.length-1)),this.beforeSeekableWindow_(i,n)){const _=i.start(0);s=_+(_===i.end(0)?0:wi)}if(typeof s<"u")return this.logger_(`Trying to seek outside of seekable at time ${n} with seekable range ${WT(i)}. Seeking to ${s}.`),this.tech_.setCurrentTime(s),!0;const a=this.playlistController_.sourceUpdater_,o=this.tech_.buffered(),l=a.audioBuffer?a.audioBuffered():null,c=a.videoBuffer?a.videoBuffered():null,p=this.media(),g=p.partTargetDuration?p.partTargetDuration:(p.targetDuration-Bn)*2,v=[l,c];for(let _=0;_ ${n.end(0)}]. Attempting to resume playback by seeking to the current time.`),this.tech_.trigger({type:"usage",name:"vhs-unknown-waiting"});return}}techWaiting_(){const e=this.seekable(),i=this.tech_.currentTime();if(this.tech_.seeking())return!0;if(this.beforeSeekableWindow_(e,i)){const o=e.end(e.length-1);return this.logger_(`Fell out of live window at time ${i}. Seeking to live point (seekable end) ${o}`),this.resetTimeUpdate_(),this.tech_.setCurrentTime(o),this.tech_.trigger({type:"usage",name:"vhs-live-resync"}),!0}const n=this.tech_.vhs.playlistController_.sourceUpdater_,r=this.tech_.buffered();if(this.videoUnderflow_({audioBuffered:n.audioBuffered(),videoBuffered:n.videoBuffered(),currentTime:i}))return this.resetTimeUpdate_(),this.tech_.setCurrentTime(i),this.tech_.trigger({type:"usage",name:"vhs-video-underflow"}),!0;const a=xl(r,i);return a.length>0?(this.logger_(`Stopped at ${i} and seeking to ${a.start(0)}`),this.resetTimeUpdate_(),this.skipTheGap_(i),!0):!1}afterSeekableWindow_(e,i,n,r=!1){if(!e.length)return!1;let s=e.end(e.length-1)+wi;const a=!n.endList,o=typeof n.partTargetDuration=="number";return a&&(o||r)&&(s=e.end(e.length-1)+n.targetDuration*3),i>s}beforeSeekableWindow_(e,i){return!!(e.length&&e.start(0)>0&&i2)return{start:s,end:a}}return null}}const v8={errorInterval:30,getSource(t){const i=this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource();return t(i)}},Lx=function(t,e){let i=0,n=0;const r=ve(v8,e);t.ready(()=>{t.trigger({type:"usage",name:"vhs-error-reload-initialized"})});const s=function(){n&&t.currentTime(n)},a=function(p){p!=null&&(n=t.duration()!==1/0&&t.currentTime()||0,t.one("loadedmetadata",s),t.src(p),t.trigger({type:"usage",name:"vhs-error-reload"}),t.play())},o=function(){if(Date.now()-i{Object.defineProperty(Ne,t,{get(){return M.log.warn(`using Vhs.${t} is UNSAFE be sure you know what you are doing`),Qe[t]},set(e){if(M.log.warn(`using Vhs.${t} is UNSAFE be sure you know what you are doing`),typeof e!="number"||e<0){M.log.warn(`value of Vhs.${t} must be greater than or equal to 0`);return}Qe[t]=e}})});const Nx="videojs-vhs",Rx=function(t,e){const i=e.media();let n=-1;for(let r=0;r{t.addQualityLevel(i)}),Rx(t,e.playlists)};Ne.canPlaySource=function(){return M.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};const C8=(t,e,i)=>{if(!t)return t;let n={};e&&e.attributes&&e.attributes.CODECS&&(n=Ru(Si(e.attributes.CODECS))),i&&i.attributes&&i.attributes.CODECS&&(n.audio=i.attributes.CODECS);const r=ro(n.video),s=ro(n.audio),a={};for(const o in t)a[o]={},s&&(a[o].audioContentType=s),r&&(a[o].videoContentType=r),e.contentProtection&&e.contentProtection[o]&&e.contentProtection[o].pssh&&(a[o].pssh=e.contentProtection[o].pssh),typeof t[o]=="string"&&(a[o].url=t[o]);return ve(t,a)},w8=(t,e)=>t.reduce((i,n)=>{if(!n.contentProtection)return i;const r=e.reduce((s,a)=>{const o=n.contentProtection[a];return o&&o.pssh&&(s[a]={pssh:o.pssh}),s},{});return Object.keys(r).length&&i.push(r),i},[]),D8=({player:t,sourceKeySystems:e,audioMedia:i,mainPlaylists:n})=>{if(!t.eme.initializeMediaKeys)return Promise.resolve();const r=i?n.concat([i]):n,s=w8(r,Object.keys(e)),a=[],o=[];return s.forEach(l=>{o.push(new Promise((c,p)=>{t.tech_.one("keysessioncreated",c)})),a.push(new Promise((c,p)=>{t.eme.initializeMediaKeys({keySystems:l},g=>{if(g){p(g);return}c()})}))}),Promise.race([Promise.all(a),Promise.race(o)])},A8=({player:t,sourceKeySystems:e,media:i,audioMedia:n})=>{const r=C8(e,i,n);return r?(t.currentSource().keySystems=r,r&&!t.eme?(M.log.warn("DRM encrypted source cannot be decrypted without a DRM plugin"),!1):!0):!1},Mx=()=>{if(!A.localStorage)return null;const t=A.localStorage.getItem(Nx);if(!t)return null;try{return JSON.parse(t)}catch{return null}},k8=t=>{if(!A.localStorage)return!1;let e=Mx();e=e?ve(e,t):t;try{A.localStorage.setItem(Nx,JSON.stringify(e))}catch{return!1}return e},P8=t=>t.toLowerCase().indexOf("data:application/vnd.videojs.vhs+json,")===0?JSON.parse(t.substring(t.indexOf(",")+1)):t,Bx=(t,e)=>{t._requestCallbackSet||(t._requestCallbackSet=new Set),t._requestCallbackSet.add(e)},Fx=(t,e)=>{t._responseCallbackSet||(t._responseCallbackSet=new Set),t._responseCallbackSet.add(e)},Ux=(t,e)=>{t._requestCallbackSet&&(t._requestCallbackSet.delete(e),t._requestCallbackSet.size||delete t._requestCallbackSet)},jx=(t,e)=>{t._responseCallbackSet&&(t._responseCallbackSet.delete(e),t._responseCallbackSet.size||delete t._responseCallbackSet)};Ne.supportsNativeHls=function(){if(!V||!V.createElement)return!1;const t=V.createElement("video");return M.getTech("Html5").isSupported()?["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"].some(function(i){return/maybe|probably/i.test(t.canPlayType(i))}):!1}();Ne.supportsNativeDash=function(){return!V||!V.createElement||!M.getTech("Html5").isSupported()?!1:/maybe|probably/i.test(V.createElement("video").canPlayType("application/dash+xml"))}();Ne.supportsTypeNatively=t=>t==="hls"?Ne.supportsNativeHls:t==="dash"?Ne.supportsNativeDash:!1;Ne.isSupported=function(){return M.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};Ne.xhr.onRequest=function(t){Bx(Ne.xhr,t)};Ne.xhr.onResponse=function(t){Fx(Ne.xhr,t)};Ne.xhr.offRequest=function(t){Ux(Ne.xhr,t)};Ne.xhr.offResponse=function(t){jx(Ne.xhr,t)};const I8=M.getComponent("Component");class $x extends I8{constructor(e,i,n){if(super(i,n.vhs),typeof n.initialBandwidth=="number"&&(this.options_.bandwidth=n.initialBandwidth),this.logger_=si("VhsHandler"),i.options_&&i.options_.playerId){const r=M.getPlayer(i.options_.playerId);this.player_=r}if(this.tech_=i,this.source_=e,this.stats={},this.ignoreNextSeekingEvent_=!1,this.setOptions_(),this.options_.overrideNative&&i.overrideNativeAudioTracks&&i.overrideNativeVideoTracks)i.overrideNativeAudioTracks(!0),i.overrideNativeVideoTracks(!0);else if(this.options_.overrideNative&&(i.featuresNativeVideoTracks||i.featuresNativeAudioTracks))throw new Error("Overriding native VHS requires emulated tracks. See https://git.io/vMpjB");this.on(V,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],r=>{const s=V.fullscreenElement||V.webkitFullscreenElement||V.mozFullScreenElement||V.msFullscreenElement;s&&s.contains(this.tech_.el())?this.playlistController_.fastQualityChange_():this.playlistController_.checkABR_()}),this.on(this.tech_,"seeking",function(){if(this.ignoreNextSeekingEvent_){this.ignoreNextSeekingEvent_=!1;return}this.setCurrentTime(this.tech_.currentTime())}),this.on(this.tech_,"error",function(){this.tech_.error()&&this.playlistController_&&this.playlistController_.pauseLoading()}),this.on(this.tech_,"play",this.play)}setOptions_(){if(this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions!==!1,this.options_.useDevicePixelRatio=this.options_.useDevicePixelRatio||!1,this.options_.useBandwidthFromLocalStorage=typeof this.source_.useBandwidthFromLocalStorage<"u"?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.useForcedSubtitles=this.options_.useForcedSubtitles||!1,this.options_.useNetworkInformationApi=this.options_.useNetworkInformationApi||!1,this.options_.useDtsForTimestampOffset=this.options_.useDtsForTimestampOffset||!1,this.options_.calculateTimestampOffsetForEachSegment=this.options_.calculateTimestampOffsetForEachSegment||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,this.options_.llhls=this.options_.llhls!==!1,this.options_.bufferBasedABR=this.options_.bufferBasedABR||!1,typeof this.options_.playlistExclusionDuration!="number"&&(this.options_.playlistExclusionDuration=60),typeof this.options_.bandwidth!="number"&&this.options_.useBandwidthFromLocalStorage){const e=Mx();e&&e.bandwidth&&(this.options_.bandwidth=e.bandwidth,this.tech_.trigger({type:"usage",name:"vhs-bandwidth-from-local-storage"})),e&&e.throughput&&(this.options_.throughput=e.throughput,this.tech_.trigger({type:"usage",name:"vhs-throughput-from-local-storage"}))}typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=Qe.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===Qe.INITIAL_BANDWIDTH,["withCredentials","useDevicePixelRatio","limitRenditionByPlayerDimensions","bandwidth","customTagParsers","customTagMappers","cacheEncryptionKeys","playlistSelector","initialPlaylistSelector","bufferBasedABR","liveRangeSafeTimeDelta","llhls","useForcedSubtitles","useNetworkInformationApi","useDtsForTimestampOffset","calculateTimestampOffsetForEachSegment","exactManifestTimings","leastPixelDiffSelector"].forEach(e=>{typeof this.source_[e]<"u"&&(this.options_[e]=this.source_[e])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions,this.useDevicePixelRatio=this.options_.useDevicePixelRatio}src(e,i){if(!e)return;this.setOptions_(),this.options_.src=P8(this.source_.src),this.options_.tech=this.tech_,this.options_.externVhs=Ne,this.options_.sourceType=$1(i),this.options_.seekTo=s=>{this.tech_.setCurrentTime(s)},this.playlistController_=new f8(this.options_);const n=ve({liveRangeSafeTimeDelta:wi},this.options_,{seekable:()=>this.seekable(),media:()=>this.playlistController_.media(),playlistController:this.playlistController_});this.playbackWatcher_=new y8(n),this.playlistController_.on("error",()=>{const s=M.players[this.tech_.options_.playerId];let a=this.playlistController_.error;typeof a=="object"&&!a.code?a.code=3:typeof a=="string"&&(a={message:a,code:3}),s.error(a)});const r=this.options_.bufferBasedABR?Ne.movingAverageBandwidthSelector(.55):Ne.STANDARD_PLAYLIST_SELECTOR;this.playlistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):r.bind(this),this.playlistController_.selectInitialPlaylist=Ne.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.playlistController_.mainPlaylistLoader_,this.mediaSource=this.playlistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get(){return this.playlistController_.selectPlaylist},set(s){this.playlistController_.selectPlaylist=s.bind(this)}},throughput:{get(){return this.playlistController_.mainSegmentLoader_.throughput.rate},set(s){this.playlistController_.mainSegmentLoader_.throughput.rate=s,this.playlistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get(){let s=this.playlistController_.mainSegmentLoader_.bandwidth;const a=A.navigator.connection||A.navigator.mozConnection||A.navigator.webkitConnection,o=1e7;if(this.options_.useNetworkInformationApi&&a){const l=a.downlink*1e3*1e3;l>=o&&s>=o?s=Math.max(s,l):s=l}return s},set(s){this.playlistController_.mainSegmentLoader_.bandwidth=s,this.playlistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get(){const s=1/(this.bandwidth||1);let a;return this.throughput>0?a=1/this.throughput:a=0,Math.floor(1/(s+a))},set(){M.log.error('The "systemBandwidth" property is read-only')}}}),this.options_.bandwidth&&(this.bandwidth=this.options_.bandwidth),this.options_.throughput&&(this.throughput=this.options_.throughput),Object.defineProperties(this.stats,{bandwidth:{get:()=>this.bandwidth||0,enumerable:!0},mediaRequests:{get:()=>this.playlistController_.mediaRequests_()||0,enumerable:!0},mediaRequestsAborted:{get:()=>this.playlistController_.mediaRequestsAborted_()||0,enumerable:!0},mediaRequestsTimedout:{get:()=>this.playlistController_.mediaRequestsTimedout_()||0,enumerable:!0},mediaRequestsErrored:{get:()=>this.playlistController_.mediaRequestsErrored_()||0,enumerable:!0},mediaTransferDuration:{get:()=>this.playlistController_.mediaTransferDuration_()||0,enumerable:!0},mediaBytesTransferred:{get:()=>this.playlistController_.mediaBytesTransferred_()||0,enumerable:!0},mediaSecondsLoaded:{get:()=>this.playlistController_.mediaSecondsLoaded_()||0,enumerable:!0},mediaAppends:{get:()=>this.playlistController_.mediaAppends_()||0,enumerable:!0},mainAppendsToLoadedData:{get:()=>this.playlistController_.mainAppendsToLoadedData_()||0,enumerable:!0},audioAppendsToLoadedData:{get:()=>this.playlistController_.audioAppendsToLoadedData_()||0,enumerable:!0},appendsToLoadedData:{get:()=>this.playlistController_.appendsToLoadedData_()||0,enumerable:!0},timeToLoadedData:{get:()=>this.playlistController_.timeToLoadedData_()||0,enumerable:!0},buffered:{get:()=>nr(this.tech_.buffered()),enumerable:!0},currentTime:{get:()=>this.tech_.currentTime(),enumerable:!0},currentSource:{get:()=>this.tech_.currentSource_,enumerable:!0},currentTech:{get:()=>this.tech_.name_,enumerable:!0},duration:{get:()=>this.tech_.duration(),enumerable:!0},main:{get:()=>this.playlists.main,enumerable:!0},playerDimensions:{get:()=>this.tech_.currentDimensions(),enumerable:!0},seekable:{get:()=>nr(this.tech_.seekable()),enumerable:!0},timestamp:{get:()=>Date.now(),enumerable:!0},videoPlaybackQuality:{get:()=>this.tech_.getVideoPlaybackQuality(),enumerable:!0}}),this.tech_.one("canplay",this.playlistController_.setupFirstPlay.bind(this.playlistController_)),this.tech_.on("bandwidthupdate",()=>{this.options_.useBandwidthFromLocalStorage&&k8({bandwidth:this.bandwidth,throughput:Math.round(this.throughput)})}),this.playlistController_.on("selectedinitialmedia",()=>{g8(this)}),this.playlistController_.sourceUpdater_.on("createdsourcebuffers",()=>{this.setupEme_()}),this.on(this.playlistController_,"progress",function(){this.tech_.trigger("progress")}),this.on(this.playlistController_,"firstplay",function(){this.ignoreNextSeekingEvent_=!0}),this.setupQualityLevels_(),this.tech_.el()&&(this.mediaSourceUrl_=A.URL.createObjectURL(this.playlistController_.mediaSource),this.tech_.src(this.mediaSourceUrl_))}createKeySessions_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader;this.logger_("waiting for EME key session creation"),D8({player:this.player_,sourceKeySystems:this.source_.keySystems,audioMedia:e&&e.media(),mainPlaylists:this.playlists.main.playlists}).then(()=>{this.logger_("created EME key session"),this.playlistController_.sourceUpdater_.initializedEme()}).catch(i=>{this.logger_("error while creating EME key session",i),this.player_.error({message:"Failed to initialize media keys for EME",code:3})})}handleWaitingForKey_(){this.logger_("waitingforkey fired, attempting to create any new key sessions"),this.createKeySessions_()}setupEme_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader,i=A8({player:this.player_,sourceKeySystems:this.source_.keySystems,media:this.playlists.media(),audioMedia:e&&e.media()});if(this.player_.tech_.on("keystatuschange",n=>{if(n.status!=="output-restricted")return;const r=this.playlistController_.main();if(!r||!r.playlists)return;const s=[];r.playlists.forEach(a=>{a&&a.attributes&&a.attributes.RESOLUTION&&a.attributes.RESOLUTION.height>=720&&(!a.excludeUntil||a.excludeUntil<1/0)&&(a.excludeUntil=1/0,s.push(a))}),s.length&&(M.log.warn('DRM keystatus changed to "output-restricted." Removing the following HD playlists that will most likely fail to play and clearing the buffer. This may be due to HDCP restrictions on the stream and the capabilities of the current device.',...s),this.playlistController_.mainSegmentLoader_.resetEverything(),this.playlistController_.fastQualityChange_())}),this.handleWaitingForKey_=this.handleWaitingForKey_.bind(this),this.player_.tech_.on("waitingforkey",this.handleWaitingForKey_),!i){this.playlistController_.sourceUpdater_.initializedEme();return}this.createKeySessions_()}setupQualityLevels_(){const e=M.players[this.tech_.options_.playerId];!e||!e.qualityLevels||this.qualityLevels_||(this.qualityLevels_=e.qualityLevels(),this.playlistController_.on("selectedinitialmedia",()=>{b8(this.qualityLevels_,this)}),this.playlists.on("mediachange",()=>{Rx(this.qualityLevels_,this.playlists)}))}static version(){return{"@videojs/http-streaming":Ox,"mux.js":T8,"mpd-parser":x8,"m3u8-parser":S8,"aes-decrypter":E8}}version(){return this.constructor.version()}canChangeType(){return kx.canChangeType()}play(){this.playlistController_.play()}setCurrentTime(e){this.playlistController_.setCurrentTime(e)}duration(){return this.playlistController_.duration()}seekable(){return this.playlistController_.seekable()}dispose(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.playlistController_&&this.playlistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.tech_&&this.tech_.vhs&&delete this.tech_.vhs,this.mediaSourceUrl_&&A.URL.revokeObjectURL&&(A.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null),this.tech_&&this.tech_.off("waitingforkey",this.handleWaitingForKey_),super.dispose()}convertToProgramTime(e,i){return UP({playlist:this.playlistController_.media(),time:e,callback:i})}seekToProgramTime(e,i,n=!0,r=2){return hx({programTime:e,playlist:this.playlistController_.media(),retryCount:r,pauseAfterSeek:n,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:i})}setupXhrHooks_(){this.xhr.onRequest=e=>{Bx(this.xhr,e)},this.xhr.onResponse=e=>{Fx(this.xhr,e)},this.xhr.offRequest=e=>{Ux(this.xhr,e)},this.xhr.offResponse=e=>{jx(this.xhr,e)},this.player_.trigger("xhr-hooks-ready")}}const Fu={name:"videojs-http-streaming",VERSION:Ox,canHandleSource(t,e={}){const i=ve(M.options,e);return Fu.canPlayType(t.type,i)},handleSource(t,e,i={}){const n=ve(M.options,i);return e.vhs=new $x(t,e,n),e.vhs.xhr=ox(),e.vhs.setupXhrHooks_(),e.vhs.src(t.src,t.type),e.vhs},canPlayType(t,e){const i=$1(t);if(!i)return"";const n=Fu.getOverrideNative(e);return!Ne.supportsTypeNatively(i)||n?"maybe":""},getOverrideNative(t={}){const{vhs:e={}}=t,i=!(M.browser.IS_ANY_SAFARI||M.browser.IS_IOS),{overrideNative:n=i}=e;return n}},L8=()=>Bl("avc1.4d400d,mp4a.40.2");L8()&&M.getTech("Html5").registerSourceHandler(Fu,0);M.VhsHandler=$x;M.VhsSourceHandler=Fu;M.Vhs=Ne;M.use||M.registerComponent("Vhs",Ne);M.options.vhs=M.options.vhs||{};(!M.getPlugin||!M.getPlugin("reloadSourceOnError"))&&M.registerPlugin("reloadSourceOnError",_8);const O8=({video:t})=>{var l;const[e,i]=G.useState(""),n="http://13.209.86.34:5002/api/chat/create",[r,s]=G.useState(void 0),a=async()=>{try{const c=await fetch(`http://13.209.86.34:5002/api/chat/list?video_name=${t}`);if(!c.ok)throw new Error("Network response was not ok");const g=(await c.json()).chats.slice(0,7).reverse();s({chats:g})}catch(c){console.error("Error fetching chat list:",c)}},o=async()=>{try{if(!(await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({video_name:t,content:e})})).ok)throw new Error("Network response was not ok");console.log("Message sent successfully"),i("")}catch(c){console.error("Error sending message:",c)}};return G.useEffect(()=>{a();const c=setInterval(a,1e3);return()=>clearInterval(c)},[t]),q.jsxs("div",{className:"fixed bottom-0 left-0 w-full px-6",children:[q.jsx("div",{children:(l=r==null?void 0:r.chats)==null?void 0:l.map((c,p)=>q.jsxs("div",{className:"flex flex-row gap-4 w-full overflow-x-scroll mb-4",children:[q.jsx("div",{children:"익명"}),q.jsx("div",{className:"font-bold",children:c.content}),q.jsx("div",{className:"text-[12px]",children:c.created_at})]},p))}),q.jsxs("div",{className:"flex flex-row mb-4",children:[q.jsx("input",{className:"w-full px-4 py-2 input-style rounded-l",type:"text",placeholder:"내용을 입력하세요.",value:e,onChange:c=>i(c.target.value)}),q.jsx("button",{className:"bg-white px-4 py-2 text-black min-w-fit",onClick:o,children:"전송"})]})]})},N8=()=>{const t=G.useRef(null),{video:e}=aD();return G.useEffect(()=>{if(!t.current)return;const i={controls:!0,fluid:!0,sources:[{src:`https://furiosa-video.s3.ap-northeast-2.amazonaws.com/convert/${e}`,type:"video/mp4"}]},n=M(t.current,i,function(){console.log("Player is ready")});return()=>{n&&n.dispose()}},[e]),q.jsxs(q.Fragment,{children:[q.jsx("div",{"data-vjs-player":!0,children:q.jsx("video",{ref:t,className:"video-js vjs-big-play-centered"})}),q.jsx(O8,{video:e})]})},R8="/noc-client/assets/thumbnail-U4Odmowz.png",M8=({title:t,date:e})=>{const i=rc(),n=()=>{i(`/view/${t}`)};return q.jsx("button",{onClick:n,children:q.jsxs("div",{className:"rounded-xl w-[12rem] overflow-hidden text-left",children:[q.jsx("img",{src:R8,alt:"thumbnail"}),q.jsx("div",{className:"font-bold truncate",children:t}),q.jsx("span",{className:"text-[14px]",children:e})]})})},B8=({title:t,videoList:e})=>{var i;return console.log(e),q.jsxs("div",{className:"p-6",children:[q.jsx("span",{className:"text-2xl font-bold mb-2",children:t}),q.jsx("div",{className:"flex flex-row gap-4 w-full overflow-x-scroll mb-4",children:(i=e==null?void 0:e.list)==null?void 0:i.map((n,r)=>q.jsx(M8,{title:n.name,date:n.created_at},r))})]})},F8=()=>q.jsx("div",{className:"w-full h-30 bottom-0 p-6 pb-16 bg-[#232020]",children:q.jsx("span",{className:"opacity-25",children:"Sponsored by FURIOSA, elise"})}),U8=()=>{const t=rc(),[e,i]=G.useState(void 0),n="http://13.209.86.34:5002/api/video_list";G.useEffect(()=>{(async()=>{try{const a=await fetch(n);if(!a.ok)throw new Error("Network response was not ok");const o=await a.json();i(o)}catch(a){console.error("Error fetching data:",a)}})()},[n]);const r=()=>{t("/upload")};return q.jsx(q.Fragment,{children:q.jsxs("div",{className:"flex flex-col justify-between h-full w-full bg-black",children:[q.jsxs("div",{children:[q.jsx("div",{className:"mb-[1rem] p-6",children:q.jsx("span",{className:"text-[#E21401] text-3xl font-bold ",children:"AI Blur"})}),q.jsx(B8,{title:"HOT 10",videoList:e})]}),q.jsxs("div",{className:"flex items-center flex-col w-full",children:[q.jsx("div",{className:"flex w-full px-6 my-2",children:q.jsx("button",{onClick:r,className:"bg-[#E21401] py-2 px-4 w-full text-center rounded-l",children:"영상 업로드하기"})}),q.jsx(F8,{})]})]})})};function j8(){const[t,e]=G.useState(!0);return G.useEffect(()=>{const i=setTimeout(()=>{e(!1)},3e3);return()=>clearTimeout(i)},[]),q.jsx(q.Fragment,{children:q.jsxs(SD,{basename:"/noc-client",children:[t&&q.jsx(DD,{}),q.jsxs(TD,{children:[q.jsx(Ml,{path:"/",element:q.jsx(U8,{})}),q.jsx(Ml,{path:"/upload",element:q.jsx(wD,{})}),q.jsx(Ml,{path:"/view/:video",element:q.jsx(N8,{})})]})]})})}Wd.createRoot(document.getElementById("root")).render(q.jsx(Ki.StrictMode,{children:q.jsx(j8,{})}));
diff --git a/assets/index-5nUgs8zv.js b/assets/index-5nUgs8zv.js
new file mode 100644
index 0000000..6bf634b
--- /dev/null
+++ b/assets/index-5nUgs8zv.js
@@ -0,0 +1,277 @@
+function gC(t,e){for(var i=0;in[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function i(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(r){if(r.ep)return;r.ep=!0;const s=i(r);fetch(r.href,s)}})();var ru=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function gn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Yv(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var i=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};i.prototype=e.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(i,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}),i}var Jv={exports:{}},nc={},Zv={exports:{}},ue={};/**
+ * @license React
+ * react.production.min.js
+ *
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */var Co=Symbol.for("react.element"),yC=Symbol.for("react.portal"),vC=Symbol.for("react.fragment"),_C=Symbol.for("react.strict_mode"),TC=Symbol.for("react.profiler"),xC=Symbol.for("react.provider"),SC=Symbol.for("react.context"),EC=Symbol.for("react.forward_ref"),bC=Symbol.for("react.suspense"),CC=Symbol.for("react.memo"),wC=Symbol.for("react.lazy"),Xg=Symbol.iterator;function AC(t){return t===null||typeof t!="object"?null:(t=Xg&&t[Xg]||t["@@iterator"],typeof t=="function"?t:null)}var e_={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},t_=Object.assign,i_={};function Bs(t,e,i){this.props=t,this.context=e,this.refs=i_,this.updater=i||e_}Bs.prototype.isReactComponent={};Bs.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};Bs.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function n_(){}n_.prototype=Bs.prototype;function Kf(t,e,i){this.props=t,this.context=e,this.refs=i_,this.updater=i||e_}var Qf=Kf.prototype=new n_;Qf.constructor=Kf;t_(Qf,Bs.prototype);Qf.isPureReactComponent=!0;var Kg=Array.isArray,r_=Object.prototype.hasOwnProperty,Yf={current:null},s_={key:!0,ref:!0,__self:!0,__source:!0};function a_(t,e,i){var n,r={},s=null,a=null;if(e!=null)for(n in e.ref!==void 0&&(a=e.ref),e.key!==void 0&&(s=""+e.key),e)r_.call(e,n)&&!s_.hasOwnProperty(n)&&(r[n]=e[n]);var o=arguments.length-2;if(o===1)r.children=i;else if(1>>1,Se=q[me];if(0>>1;mer(kr,ie))Sir(Pr,kr)?(q[me]=Pr,q[Si]=ie,me=Si):(q[me]=kr,q[xi]=ie,me=xi);else if(Sir(Pr,ie))q[me]=Pr,q[Si]=ie,me=Si;else break e}}return te}function r(q,te){var ie=q.sortIndex-te.sortIndex;return ie!==0?ie:q.id-te.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var a=Date,o=a.now();t.unstable_now=function(){return a.now()-o}}var l=[],c=[],p=1,m=null,_=3,E=!1,v=!1,S=!1,D=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function C(q){for(var te=i(c);te!==null;){if(te.callback===null)n(c);else if(te.startTime<=q)n(c),te.sortIndex=te.expirationTime,e(l,te);else break;te=i(c)}}function P(q){if(S=!1,C(q),!v)if(i(l)!==null)v=!0,ce(O);else{var te=i(c);te!==null&&Ae(P,te.startTime-q)}}function O(q,te){v=!1,S&&(S=!1,x(V),V=-1),E=!0;var ie=_;try{for(C(te),m=i(l);m!==null&&(!(m.expirationTime>te)||q&&!re());){var me=m.callback;if(typeof me=="function"){m.callback=null,_=m.priorityLevel;var Se=me(m.expirationTime<=te);te=t.unstable_now(),typeof Se=="function"?m.callback=Se:m===i(l)&&n(l),C(te)}else n(l);m=i(l)}if(m!==null)var qi=!0;else{var xi=i(c);xi!==null&&Ae(P,xi.startTime-te),qi=!1}return qi}finally{m=null,_=ie,E=!1}}var N=!1,F=null,V=-1,Q=5,J=-1;function re(){return!(t.unstable_now()-Jq||125me?(q.sortIndex=ie,e(c,q),i(l)===null&&q===i(c)&&(S?(x(V),V=-1):S=!0,Ae(P,ie-me))):(q.sortIndex=Se,e(l,q),v||E||(v=!0,ce(O))),q},t.unstable_shouldYield=re,t.unstable_wrapCallback=function(q){var te=_;return function(){var ie=_;_=te;try{return q.apply(this,arguments)}finally{_=ie}}}})(c_);u_.exports=c_;var UC=u_.exports;/**
+ * @license React
+ * react-dom.production.min.js
+ *
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */var d_=X,Wt=UC;function $(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Th=Object.prototype.hasOwnProperty,jC=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Yg={},Jg={};function $C(t){return Th.call(Jg,t)?!0:Th.call(Yg,t)?!1:jC.test(t)?Jg[t]=!0:(Yg[t]=!0,!1)}function VC(t,e,i,n){if(i!==null&&i.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return n?!1:i!==null?!i.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function HC(t,e,i,n){if(e===null||typeof e>"u"||VC(t,e,i,n))return!0;if(n)return!1;if(i!==null)switch(i.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function Ct(t,e,i,n,r,s,a){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=n,this.attributeNamespace=r,this.mustUseProperty=i,this.propertyName=t,this.type=e,this.sanitizeURL=s,this.removeEmptyString=a}var at={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){at[t]=new Ct(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];at[e]=new Ct(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){at[t]=new Ct(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){at[t]=new Ct(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){at[t]=new Ct(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){at[t]=new Ct(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){at[t]=new Ct(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){at[t]=new Ct(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){at[t]=new Ct(t,5,!1,t.toLowerCase(),null,!1,!1)});var Zf=/[\-:]([a-z])/g;function ep(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(Zf,ep);at[e]=new Ct(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Zf,ep);at[e]=new Ct(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Zf,ep);at[e]=new Ct(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){at[t]=new Ct(t,1,!1,t.toLowerCase(),null,!1,!1)});at.xlinkHref=new Ct("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){at[t]=new Ct(t,1,!1,t.toLowerCase(),null,!0,!0)});function tp(t,e,i,n){var r=at.hasOwnProperty(e)?at[e]:null;(r!==null?r.type!==0:n||!(2o||r[a]!==s[o]){var l=`
+`+r[a].replace(" at new "," at ");return t.displayName&&l.includes("")&&(l=l.replace("",t.displayName)),l}while(1<=a&&0<=o);break}}}finally{bd=!1,Error.prepareStackTrace=i}return(t=t?t.displayName||t.name:"")?Ca(t):""}function zC(t){switch(t.tag){case 5:return Ca(t.type);case 16:return Ca("Lazy");case 13:return Ca("Suspense");case 19:return Ca("SuspenseList");case 0:case 2:case 15:return t=Cd(t.type,!1),t;case 11:return t=Cd(t.type.render,!1),t;case 1:return t=Cd(t.type,!0),t;default:return""}}function bh(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case zr:return"Fragment";case Hr:return"Portal";case xh:return"Profiler";case ip:return"StrictMode";case Sh:return"Suspense";case Eh:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case p_:return(t.displayName||"Context")+".Consumer";case f_:return(t._context.displayName||"Context")+".Provider";case np:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case rp:return e=t.displayName||null,e!==null?e:bh(t.type)||"Memo";case bn:e=t._payload,t=t._init;try{return bh(t(e))}catch{}}return null}function qC(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return bh(e);case 8:return e===ip?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function $n(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function g_(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function WC(t){var e=g_(t)?"checked":"value",i=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),n=""+t[e];if(!t.hasOwnProperty(e)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var r=i.get,s=i.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return r.call(this)},set:function(a){n=""+a,s.call(this,a)}}),Object.defineProperty(t,e,{enumerable:i.enumerable}),{getValue:function(){return n},setValue:function(a){n=""+a},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function ml(t){t._valueTracker||(t._valueTracker=WC(t))}function y_(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var i=e.getValue(),n="";return t&&(n=g_(t)?t.checked?"true":"false":t.value),t=n,t!==i?(e.setValue(t),!0):!1}function su(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Ch(t,e){var i=e.checked;return Fe({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??t._wrapperState.initialChecked})}function e0(t,e){var i=e.defaultValue==null?"":e.defaultValue,n=e.checked!=null?e.checked:e.defaultChecked;i=$n(e.value!=null?e.value:i),t._wrapperState={initialChecked:n,initialValue:i,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function v_(t,e){e=e.checked,e!=null&&tp(t,"checked",e,!1)}function wh(t,e){v_(t,e);var i=$n(e.value),n=e.type;if(i!=null)n==="number"?(i===0&&t.value===""||t.value!=i)&&(t.value=""+i):t.value!==""+i&&(t.value=""+i);else if(n==="submit"||n==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Ah(t,e.type,i):e.hasOwnProperty("defaultValue")&&Ah(t,e.type,$n(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function t0(t,e,i){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var n=e.type;if(!(n!=="submit"&&n!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,i||e===t.value||(t.value=e),t.defaultValue=e}i=t.name,i!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,i!==""&&(t.name=i)}function Ah(t,e,i){(e!=="number"||su(t.ownerDocument)!==t)&&(i==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+i&&(t.defaultValue=""+i))}var wa=Array.isArray;function ss(t,e,i,n){if(t=t.options,e){e={};for(var r=0;r"+e.valueOf().toString()+"",e=gl.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function Ja(t,e){if(e){var i=t.firstChild;if(i&&i===t.lastChild&&i.nodeType===3){i.nodeValue=e;return}}t.textContent=e}var Ra={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},GC=["Webkit","ms","Moz","O"];Object.keys(Ra).forEach(function(t){GC.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Ra[e]=Ra[t]})});function S_(t,e,i){return e==null||typeof e=="boolean"||e===""?"":i||typeof e!="number"||e===0||Ra.hasOwnProperty(t)&&Ra[t]?(""+e).trim():e+"px"}function E_(t,e){t=t.style;for(var i in e)if(e.hasOwnProperty(i)){var n=i.indexOf("--")===0,r=S_(i,e[i],n);i==="float"&&(i="cssFloat"),n?t.setProperty(i,r):t[i]=r}}var XC=Fe({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ph(t,e){if(e){if(XC[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error($(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error($(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error($(61))}if(e.style!=null&&typeof e.style!="object")throw Error($(62))}}function Ih(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Oh=null;function sp(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Lh=null,as=null,os=null;function r0(t){if(t=Do(t)){if(typeof Lh!="function")throw Error($(280));var e=t.stateNode;e&&(e=lc(e),Lh(t.stateNode,t.type,e))}}function b_(t){as?os?os.push(t):os=[t]:as=t}function C_(){if(as){var t=as,e=os;if(os=as=null,r0(t),e)for(t=0;t>>=0,t===0?32:31-(sw(t)/aw|0)|0}var yl=64,vl=4194304;function Aa(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function uu(t,e){var i=t.pendingLanes;if(i===0)return 0;var n=0,r=t.suspendedLanes,s=t.pingedLanes,a=i&268435455;if(a!==0){var o=a&~r;o!==0?n=Aa(o):(s&=a,s!==0&&(n=Aa(s)))}else a=i&~r,a!==0?n=Aa(a):s!==0&&(n=Aa(s));if(n===0)return 0;if(e!==0&&e!==n&&!(e&r)&&(r=n&-n,s=e&-e,r>=s||r===16&&(s&4194240)!==0))return e;if(n&4&&(n|=i&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=n;0i;i++)e.push(t);return e}function wo(t,e,i){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-gi(e),t[e]=i}function cw(t,e){var i=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var n=t.eventTimes;for(t=t.expirationTimes;0=Ba),f0=" ",p0=!1;function q_(t,e){switch(t){case"keyup":return Fw.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function W_(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var qr=!1;function jw(t,e){switch(t){case"compositionend":return W_(e);case"keypress":return e.which!==32?null:(p0=!0,f0);case"textInput":return t=e.data,t===f0&&p0?null:t;default:return null}}function $w(t,e){if(qr)return t==="compositionend"||!fp&&q_(t,e)?(t=H_(),$l=cp=kn=null,qr=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:i,offset:e-t};t=n}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=v0(i)}}function Q_(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?Q_(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function Y_(){for(var t=window,e=su();e instanceof t.HTMLIFrameElement;){try{var i=typeof e.contentWindow.location.href=="string"}catch{i=!1}if(i)t=e.contentWindow;else break;e=su(t.document)}return e}function pp(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function Qw(t){var e=Y_(),i=t.focusedElem,n=t.selectionRange;if(e!==i&&i&&i.ownerDocument&&Q_(i.ownerDocument.documentElement,i)){if(n!==null&&pp(i)){if(e=n.start,t=n.end,t===void 0&&(t=e),"selectionStart"in i)i.selectionStart=e,i.selectionEnd=Math.min(t,i.value.length);else if(t=(e=i.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var r=i.textContent.length,s=Math.min(n.start,r);n=n.end===void 0?s:Math.min(n.end,r),!t.extend&&s>n&&(r=n,n=s,s=r),r=_0(i,s);var a=_0(i,n);r&&a&&(t.rangeCount!==1||t.anchorNode!==r.node||t.anchorOffset!==r.offset||t.focusNode!==a.node||t.focusOffset!==a.offset)&&(e=e.createRange(),e.setStart(r.node,r.offset),t.removeAllRanges(),s>n?(t.addRange(e),t.extend(a.node,a.offset)):(e.setEnd(a.node,a.offset),t.addRange(e)))}}for(e=[],t=i;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,Wr=null,Uh=null,Ua=null,jh=!1;function T0(t,e,i){var n=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;jh||Wr==null||Wr!==su(n)||(n=Wr,"selectionStart"in n&&pp(n)?n={start:n.selectionStart,end:n.selectionEnd}:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection(),n={anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}),Ua&&ro(Ua,n)||(Ua=n,n=hu(Uh,"onSelect"),0Kr||(t.current=Wh[Kr],Wh[Kr]=null,Kr--)}function be(t,e){Kr++,Wh[Kr]=t.current,t.current=e}var Vn={},ht=Gn(Vn),Ot=Gn(!1),vr=Vn;function vs(t,e){var i=t.type.contextTypes;if(!i)return Vn;var n=t.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===e)return n.__reactInternalMemoizedMaskedChildContext;var r={},s;for(s in i)r[s]=e[s];return n&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=r),r}function Lt(t){return t=t.childContextTypes,t!=null}function pu(){Pe(Ot),Pe(ht)}function A0(t,e,i){if(ht.current!==Vn)throw Error($(168));be(ht,e),be(Ot,i)}function a1(t,e,i){var n=t.stateNode;if(e=e.childContextTypes,typeof n.getChildContext!="function")return i;n=n.getChildContext();for(var r in n)if(!(r in e))throw Error($(108,qC(t)||"Unknown",r));return Fe({},i,n)}function mu(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Vn,vr=ht.current,be(ht,t),be(Ot,Ot.current),!0}function D0(t,e,i){var n=t.stateNode;if(!n)throw Error($(169));i?(t=a1(t,e,vr),n.__reactInternalMemoizedMergedChildContext=t,Pe(Ot),Pe(ht),be(ht,t)):Pe(Ot),be(Ot,i)}var Qi=null,uc=!1,Ud=!1;function o1(t){Qi===null?Qi=[t]:Qi.push(t)}function lA(t){uc=!0,o1(t)}function Xn(){if(!Ud&&Qi!==null){Ud=!0;var t=0,e=ve;try{var i=Qi;for(ve=1;t>=a,r-=a,Zi=1<<32-gi(e)+r|i<V?(Q=F,F=null):Q=F.sibling;var J=_(x,F,C[V],P);if(J===null){F===null&&(F=Q);break}t&&F&&J.alternate===null&&e(x,F),T=s(J,T,V),N===null?O=J:N.sibling=J,N=J,F=Q}if(V===C.length)return i(x,F),Ne&&rr(x,V),O;if(F===null){for(;VV?(Q=F,F=null):Q=F.sibling;var re=_(x,F,J.value,P);if(re===null){F===null&&(F=Q);break}t&&F&&re.alternate===null&&e(x,F),T=s(re,T,V),N===null?O=re:N.sibling=re,N=re,F=Q}if(J.done)return i(x,F),Ne&&rr(x,V),O;if(F===null){for(;!J.done;V++,J=C.next())J=m(x,J.value,P),J!==null&&(T=s(J,T,V),N===null?O=J:N.sibling=J,N=J);return Ne&&rr(x,V),O}for(F=n(x,F);!J.done;V++,J=C.next())J=E(F,x,V,J.value,P),J!==null&&(t&&J.alternate!==null&&F.delete(J.key===null?V:J.key),T=s(J,T,V),N===null?O=J:N.sibling=J,N=J);return t&&F.forEach(function(pe){return e(x,pe)}),Ne&&rr(x,V),O}function D(x,T,C,P){if(typeof C=="object"&&C!==null&&C.type===zr&&C.key===null&&(C=C.props.children),typeof C=="object"&&C!==null){switch(C.$$typeof){case pl:e:{for(var O=C.key,N=T;N!==null;){if(N.key===O){if(O=C.type,O===zr){if(N.tag===7){i(x,N.sibling),T=r(N,C.props.children),T.return=x,x=T;break e}}else if(N.elementType===O||typeof O=="object"&&O!==null&&O.$$typeof===bn&&R0(O)===N.type){i(x,N.sibling),T=r(N,C.props),T.ref=fa(x,N,C),T.return=x,x=T;break e}i(x,N);break}else e(x,N);N=N.sibling}C.type===zr?(T=fr(C.props.children,x.mode,P,C.key),T.return=x,x=T):(P=Kl(C.type,C.key,C.props,null,x.mode,P),P.ref=fa(x,T,C),P.return=x,x=P)}return a(x);case Hr:e:{for(N=C.key;T!==null;){if(T.key===N)if(T.tag===4&&T.stateNode.containerInfo===C.containerInfo&&T.stateNode.implementation===C.implementation){i(x,T.sibling),T=r(T,C.children||[]),T.return=x,x=T;break e}else{i(x,T);break}else e(x,T);T=T.sibling}T=Gd(C,x.mode,P),T.return=x,x=T}return a(x);case bn:return N=C._init,D(x,T,N(C._payload),P)}if(wa(C))return v(x,T,C,P);if(la(C))return S(x,T,C,P);Cl(x,C)}return typeof C=="string"&&C!==""||typeof C=="number"?(C=""+C,T!==null&&T.tag===6?(i(x,T.sibling),T=r(T,C),T.return=x,x=T):(i(x,T),T=Wd(C,x.mode,P),T.return=x,x=T),a(x)):i(x,T)}return D}var Ts=m1(!0),g1=m1(!1),ko={},Ni=Gn(ko),lo=Gn(ko),uo=Gn(ko);function cr(t){if(t===ko)throw Error($(174));return t}function Ep(t,e){switch(be(uo,e),be(lo,t),be(Ni,ko),t=e.nodeType,t){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:kh(null,"");break;default:t=t===8?e.parentNode:e,e=t.namespaceURI||null,t=t.tagName,e=kh(e,t)}Pe(Ni),be(Ni,e)}function xs(){Pe(Ni),Pe(lo),Pe(uo)}function y1(t){cr(uo.current);var e=cr(Ni.current),i=kh(e,t.type);e!==i&&(be(lo,t),be(Ni,i))}function bp(t){lo.current===t&&(Pe(Ni),Pe(lo))}var Re=Gn(0);function xu(t){for(var e=t;e!==null;){if(e.tag===13){var i=e.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||i.data==="$?"||i.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var jd=[];function Cp(){for(var t=0;ti?i:4,t(!0);var n=$d.transition;$d.transition={};try{t(!1),e()}finally{ve=i,$d.transition=n}}function L1(){return ai().memoizedState}function hA(t,e,i){var n=Fn(t);if(i={lane:n,action:i,hasEagerState:!1,eagerState:null,next:null},N1(t))R1(e,i);else if(i=d1(t,e,i,n),i!==null){var r=St();yi(i,t,n,r),M1(i,e,n)}}function fA(t,e,i){var n=Fn(t),r={lane:n,action:i,hasEagerState:!1,eagerState:null,next:null};if(N1(t))R1(e,r);else{var s=t.alternate;if(t.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var a=e.lastRenderedState,o=s(a,i);if(r.hasEagerState=!0,r.eagerState=o,_i(o,a)){var l=e.interleaved;l===null?(r.next=r,xp(e)):(r.next=l.next,l.next=r),e.interleaved=r;return}}catch{}finally{}i=d1(t,e,r,n),i!==null&&(r=St(),yi(i,t,n,r),M1(i,e,n))}}function N1(t){var e=t.alternate;return t===Be||e!==null&&e===Be}function R1(t,e){ja=Su=!0;var i=t.pending;i===null?e.next=e:(e.next=i.next,i.next=e),t.pending=e}function M1(t,e,i){if(i&4194240){var n=e.lanes;n&=t.pendingLanes,i|=n,e.lanes=i,op(t,i)}}var Eu={readContext:si,useCallback:ot,useContext:ot,useEffect:ot,useImperativeHandle:ot,useInsertionEffect:ot,useLayoutEffect:ot,useMemo:ot,useReducer:ot,useRef:ot,useState:ot,useDebugValue:ot,useDeferredValue:ot,useTransition:ot,useMutableSource:ot,useSyncExternalStore:ot,useId:ot,unstable_isNewReconciler:!1},pA={readContext:si,useCallback:function(t,e){return Ci().memoizedState=[t,e===void 0?null:e],t},useContext:si,useEffect:B0,useImperativeHandle:function(t,e,i){return i=i!=null?i.concat([t]):null,ql(4194308,4,D1.bind(null,e,t),i)},useLayoutEffect:function(t,e){return ql(4194308,4,t,e)},useInsertionEffect:function(t,e){return ql(4,2,t,e)},useMemo:function(t,e){var i=Ci();return e=e===void 0?null:e,t=t(),i.memoizedState=[t,e],t},useReducer:function(t,e,i){var n=Ci();return e=i!==void 0?i(e):e,n.memoizedState=n.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},n.queue=t,t=t.dispatch=hA.bind(null,Be,t),[n.memoizedState,t]},useRef:function(t){var e=Ci();return t={current:t},e.memoizedState=t},useState:M0,useDebugValue:Pp,useDeferredValue:function(t){return Ci().memoizedState=t},useTransition:function(){var t=M0(!1),e=t[0];return t=dA.bind(null,t[1]),Ci().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,i){var n=Be,r=Ci();if(Ne){if(i===void 0)throw Error($(407));i=i()}else{if(i=e(),tt===null)throw Error($(349));Tr&30||T1(n,e,i)}r.memoizedState=i;var s={value:i,getSnapshot:e};return r.queue=s,B0(S1.bind(null,n,s,t),[t]),n.flags|=2048,fo(9,x1.bind(null,n,s,i,e),void 0,null),i},useId:function(){var t=Ci(),e=tt.identifierPrefix;if(Ne){var i=en,n=Zi;i=(n&~(1<<32-gi(n)-1)).toString(32)+i,e=":"+e+"R"+i,i=co++,0<\/script>",t=t.removeChild(t.firstChild)):typeof n.is=="string"?t=a.createElement(i,{is:n.is}):(t=a.createElement(i),i==="select"&&(a=t,n.multiple?a.multiple=!0:n.size&&(a.size=n.size))):t=a.createElementNS(t,i),t[Di]=e,t[oo]=n,q1(t,e,!1,!1),e.stateNode=t;e:{switch(a=Ih(i,n),i){case"dialog":ke("cancel",t),ke("close",t),r=n;break;case"iframe":case"object":case"embed":ke("load",t),r=n;break;case"video":case"audio":for(r=0;rEs&&(e.flags|=128,n=!0,pa(s,!1),e.lanes=4194304)}else{if(!n)if(t=xu(a),t!==null){if(e.flags|=128,n=!0,i=t.updateQueue,i!==null&&(e.updateQueue=i,e.flags|=4),pa(s,!0),s.tail===null&&s.tailMode==="hidden"&&!a.alternate&&!Ne)return lt(e),null}else 2*He()-s.renderingStartTime>Es&&i!==1073741824&&(e.flags|=128,n=!0,pa(s,!1),e.lanes=4194304);s.isBackwards?(a.sibling=e.child,e.child=a):(i=s.last,i!==null?i.sibling=a:e.child=a,s.last=a)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=He(),e.sibling=null,i=Re.current,be(Re,n?i&1|2:i&1),e):(lt(e),null);case 22:case 23:return Mp(),n=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(e.flags|=8192),n&&e.mode&1?jt&1073741824&&(lt(e),e.subtreeFlags&6&&(e.flags|=8192)):lt(e),null;case 24:return null;case 25:return null}throw Error($(156,e.tag))}function SA(t,e){switch(gp(e),e.tag){case 1:return Lt(e.type)&&pu(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return xs(),Pe(Ot),Pe(ht),Cp(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return bp(e),null;case 13:if(Pe(Re),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error($(340));_s()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return Pe(Re),null;case 4:return xs(),null;case 10:return Tp(e.type._context),null;case 22:case 23:return Mp(),null;case 24:return null;default:return null}}var Al=!1,ut=!1,EA=typeof WeakSet=="function"?WeakSet:Set,K=null;function Zr(t,e){var i=t.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(n){Ue(t,e,n)}else i.current=null}function sf(t,e,i){try{i()}catch(n){Ue(t,e,n)}}var W0=!1;function bA(t,e){if($h=cu,t=Y_(),pp(t)){if("selectionStart"in t)var i={start:t.selectionStart,end:t.selectionEnd};else e:{i=(i=t.ownerDocument)&&i.defaultView||window;var n=i.getSelection&&i.getSelection();if(n&&n.rangeCount!==0){i=n.anchorNode;var r=n.anchorOffset,s=n.focusNode;n=n.focusOffset;try{i.nodeType,s.nodeType}catch{i=null;break e}var a=0,o=-1,l=-1,c=0,p=0,m=t,_=null;t:for(;;){for(var E;m!==i||r!==0&&m.nodeType!==3||(o=a+r),m!==s||n!==0&&m.nodeType!==3||(l=a+n),m.nodeType===3&&(a+=m.nodeValue.length),(E=m.firstChild)!==null;)_=m,m=E;for(;;){if(m===t)break t;if(_===i&&++c===r&&(o=a),_===s&&++p===n&&(l=a),(E=m.nextSibling)!==null)break;m=_,_=m.parentNode}m=E}i=o===-1||l===-1?null:{start:o,end:l}}else i=null}i=i||{start:0,end:0}}else i=null;for(Vh={focusedElem:t,selectionRange:i},cu=!1,K=e;K!==null;)if(e=K,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,K=t;else for(;K!==null;){e=K;try{var v=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(v!==null){var S=v.memoizedProps,D=v.memoizedState,x=e.stateNode,T=x.getSnapshotBeforeUpdate(e.elementType===e.type?S:fi(e.type,S),D);x.__reactInternalSnapshotBeforeUpdate=T}break;case 3:var C=e.stateNode.containerInfo;C.nodeType===1?C.textContent="":C.nodeType===9&&C.documentElement&&C.removeChild(C.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error($(163))}}catch(P){Ue(e,e.return,P)}if(t=e.sibling,t!==null){t.return=e.return,K=t;break}K=e.return}return v=W0,W0=!1,v}function $a(t,e,i){var n=e.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var r=n=n.next;do{if((r.tag&t)===t){var s=r.destroy;r.destroy=void 0,s!==void 0&&sf(e,i,s)}r=r.next}while(r!==n)}}function hc(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var i=e=e.next;do{if((i.tag&t)===t){var n=i.create;i.destroy=n()}i=i.next}while(i!==e)}}function af(t){var e=t.ref;if(e!==null){var i=t.stateNode;switch(t.tag){case 5:t=i;break;default:t=i}typeof e=="function"?e(t):e.current=t}}function X1(t){var e=t.alternate;e!==null&&(t.alternate=null,X1(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Di],delete e[oo],delete e[qh],delete e[aA],delete e[oA])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function K1(t){return t.tag===5||t.tag===3||t.tag===4}function G0(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||K1(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function of(t,e,i){var n=t.tag;if(n===5||n===6)t=t.stateNode,e?i.nodeType===8?i.parentNode.insertBefore(t,e):i.insertBefore(t,e):(i.nodeType===8?(e=i.parentNode,e.insertBefore(t,i)):(e=i,e.appendChild(t)),i=i._reactRootContainer,i!=null||e.onclick!==null||(e.onclick=fu));else if(n!==4&&(t=t.child,t!==null))for(of(t,e,i),t=t.sibling;t!==null;)of(t,e,i),t=t.sibling}function lf(t,e,i){var n=t.tag;if(n===5||n===6)t=t.stateNode,e?i.insertBefore(t,e):i.appendChild(t);else if(n!==4&&(t=t.child,t!==null))for(lf(t,e,i),t=t.sibling;t!==null;)lf(t,e,i),t=t.sibling}var nt=null,pi=!1;function xn(t,e,i){for(i=i.child;i!==null;)Q1(t,e,i),i=i.sibling}function Q1(t,e,i){if(Li&&typeof Li.onCommitFiberUnmount=="function")try{Li.onCommitFiberUnmount(rc,i)}catch{}switch(i.tag){case 5:ut||Zr(i,e);case 6:var n=nt,r=pi;nt=null,xn(t,e,i),nt=n,pi=r,nt!==null&&(pi?(t=nt,i=i.stateNode,t.nodeType===8?t.parentNode.removeChild(i):t.removeChild(i)):nt.removeChild(i.stateNode));break;case 18:nt!==null&&(pi?(t=nt,i=i.stateNode,t.nodeType===8?Fd(t.parentNode,i):t.nodeType===1&&Fd(t,i),io(t)):Fd(nt,i.stateNode));break;case 4:n=nt,r=pi,nt=i.stateNode.containerInfo,pi=!0,xn(t,e,i),nt=n,pi=r;break;case 0:case 11:case 14:case 15:if(!ut&&(n=i.updateQueue,n!==null&&(n=n.lastEffect,n!==null))){r=n=n.next;do{var s=r,a=s.destroy;s=s.tag,a!==void 0&&(s&2||s&4)&&sf(i,e,a),r=r.next}while(r!==n)}xn(t,e,i);break;case 1:if(!ut&&(Zr(i,e),n=i.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=i.memoizedProps,n.state=i.memoizedState,n.componentWillUnmount()}catch(o){Ue(i,e,o)}xn(t,e,i);break;case 21:xn(t,e,i);break;case 22:i.mode&1?(ut=(n=ut)||i.memoizedState!==null,xn(t,e,i),ut=n):xn(t,e,i);break;default:xn(t,e,i)}}function X0(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var i=t.stateNode;i===null&&(i=t.stateNode=new EA),e.forEach(function(n){var r=LA.bind(null,t,n);i.has(n)||(i.add(n),n.then(r,r))})}}function hi(t,e){var i=e.deletions;if(i!==null)for(var n=0;nr&&(r=a),n&=~s}if(n=r,n=He()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*wA(n/1960))-n,10t?16:t,Pn===null)var n=!1;else{if(t=Pn,Pn=null,wu=0,fe&6)throw Error($(331));var r=fe;for(fe|=4,K=t.current;K!==null;){var s=K,a=s.child;if(K.flags&16){var o=s.deletions;if(o!==null){for(var l=0;l