"use strict";class t{constructor(){this.events_=new Map}on(t,e){this.events_.has(t)||this.events_.set(t,new Set);this.events_.get(t).add(e)}off(t,e){const s=this.events_.get(t);s&&(s.delete(e),0===s.size&&this.events_.delete(t))}emit(t,e){const s=this.events_.get(t);s&&s.forEach((t=>t(e)))}once(t,e){const s=i=>{this.off(t,s),e(i)};this.on(t,s)}offAllFor(t){this.events_.delete(t)}reset(){this.events_.clear()}}const e="transition";class s{constructor(t,e){this.from=t,this.to=e}}class i extends t{constructor(){super(...arguments),this.val_=null}get value(){return this.val_}updateValue(t){const i=this.val_;this.val_=t,this.emit(e,new s(i,t))}safeAttempt(t,e){return null===this.val_?e():t(this.val_)}}class n extends i{constructor(t){super(),this.videoJsLogger_=t.logger}safeAttemptOn(t,e,s,i={}){return this.safeAttempt(e,(()=>(i.silent||this.warnAttempt_(t),s)))}voidSafeAttemptOn(t,e,s={}){return this.safeAttemptOn(t,e,void 0,s)}warnAttempt_(t){this.videoJsLogger_.warn(`Attempt to call "${t}", but no video element attached. Call "attach" first.`)}}class r{constructor(t){this.handlePlayerTransition_=({from:t,to:e})=>null===t&&null!==e?this.handlePlayerAttach_(e):null!==t&&null===e?this.handlePlayerDetach_(t):void 0,this.videoJsPlayerProvider_=t.videoJsPlayerProvider,this.logger_=t.logger,this.videojs_=t.videojs,this.sdkEventEmitter_=t.sdkEventEmitter,this.sdkStateProvider_=t.sdkStateProvider,this.configuration_=t.configuration,this.videoJsPlayerProvider_.on(e,this.handlePlayerTransition_)}dispose(){this.videoJsPlayerProvider_.off(e,this.handlePlayerTransition_),this.handleDispose_()}updateConfiguration(t,e){this.configuration_=t,this.handleUpdateConfiguration_(t,e)}}class a extends r{constructor(t){super(t),this.pluginProvider_=new n({logger:this.logger_})}}exports.NextPlaylistItemEndScreenIntegrationFactory=class extends a{handlePlayerAttach_(t){const e={nextEndscreen:!0,hideOnStart:!0,nextButton:!1,nextOverlay:!1,playlistPicker:!1};t.usingPlugin("bcPlaylistUi")?(t.bcPlaylistUi().options.nextEndscreen=!0,t.bcPlaylistUi().initNextEndscreen_()):t.bcPlaylistUi(e);const s=t.bcPlaylistUi();this.pluginProvider_.updateValue(s)}handlePlayerDetach_(){this.pluginProvider_.updateValue(null)}handleUpdateConfiguration_(){}handleDispose_(){}};
