(function(g){var window=this;var Mta=function(a,b){var c=[];g.Jf(b,function(a){var b;try{b=g.aj.prototype.o.call(this,a,!0)}catch(f){if("Storage: Invalid value was encountered"==f)return;throw f;}g.p(b)?g.$i(b)&&c.push(a):c.push(a)},a);
return c},Nta=function(a,b){var c=Mta(a,b);
(0,g.F)(c,function(a){g.aj.prototype.remove.call(this,a)},a)},Ota=function(a){return a.H?a.F+((0,g.E)()-a.A)/1E3:a.F},Pta=function(){var a=g.bj;
Nta(a,a.g.Ad(!0))},v9=function(a){g.Ow.call(this,"ScreenServiceProxy");
this.Oc=a;this.o=[];this.o.push(this.Oc.$_s("screenChange",(0,g.z)(this.DL,this)));this.o.push(this.Oc.$_s("onlineScreenChange",(0,g.z)(this.jI,this)))},w9=function(a){g.Kw("cloudview",a)},Qta=function(a){w9("setApiReady_ "+a);
g.ka("yt.mdx.remote.cloudview.apiReady_",a,void 0)},x9=function(){return g.u("yt.mdx.remote.cloudview.instance_")},Rta=function(a){g.Fi[a]&&(a=g.Fi[a],(0,g.F)(a,function(a){g.Di[a]&&delete g.Di[a]}),a.length=0)},y9=function(){return g.u("yt.mdx.remote.connection_")},z9=function(a){g.ka("yt.mdx.remote.connectData_",a,void 0)},Sta=function(a){g.ka("yt.mdx.remote.currentScreenId_",a,void 0)},A9=function(){return g.u("yt.mdx.remote.currentScreenId_")},C9=function(){if(!B9){var a=g.u("yt.mdx.remote.screenService_");
B9=a?new v9(a):null}return B9},D9=function(a){g.ka("yt.mdx.remote.cloudview.initializing_",a,void 0)},E9=function(){return!!g.u("yt.mdx.remote.cloudview.apiReady_")},F9=function(a){w9("setCastInstalled_ "+a);
g.dj("yt-remote-cast-installed",a)},G9=function(a){g.Kw("cloudview",a)},Tta=function(a,b){x9().init(a,b)},H9=function(){return!!g.ej("yt-remote-cast-installed")},Uta=function(){w9("dispose");
var a=x9();a&&a.dispose();g.ka("yt.mdx.remote.cloudview.instance_",null,void 0);Qta(!1);g.Hi(I9);I9.length=0},Vta=function(){var a=window.document.createElement("a");
g.we(a,"https://www.gstatic.com/cv/js/sender/v1/cast_sender.js");a=a.href.replace(/^[a-zA-Z]+:\/\//,"//");return"js-"+g.Oa(a)},Wta=function(a,b){var c=window.document.createElement("script");
c.id=a;c.onload=function(){b&&(0,window.setTimeout)(b,0)};
c.onreadystatechange=function(){switch(c.readyState){case "loaded":case "complete":c.onload()}};
c.src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js";var d=window.document.getElementsByTagName("head")[0]||window.document.body;d.insertBefore(c,d.firstChild);return c},Xta=function(a){var b=g.Bi();
if(b)if(b.clear(a),a)Rta(a);else for(var c in g.Fi)Rta(c)},J9=function(){return g.u("yt.mdx.remote.channelParams_")||{}},L9=function(a){var b=y9();
z9(null);a||Sta("");g.ka("yt.mdx.remote.connection_",a,void 0);K9&&((0,g.F)(K9,function(b){b(a)}),K9.length=0);
b&&!a?g.Ki("yt-remote-connection-change",!1):!b&&a&&g.Ki("yt-remote-connection-change",!0)},Yta=function(){return g.u("yt.mdx.remote.connectData_")},M9=function(){var a=A9();
if(!a)return null;var b=C9().Ed();return g.hi(b,a)},Zta=function(a,b){F9(!0);
D9(!1);Tta(a,function(a){a?(Qta(!0),g.Ji("yt-remote-cast2-api-ready")):(G9("Failed to initialize cast API."),F9(!1),g.fj("yt-remote-cast-available"),g.fj("yt-remote-cast-receiver"),Uta());b(a)})},$ta=function(){return H9()?x9()?x9().getCastSession():(G9("getCastSelector: Cast is not initialized."),null):(G9("getCastSelector: Cast API is not installed!"),null)},aua=function(){if(g.ooa){var a=2,b=g.zw(),c=function(){a--;
0==a&&b&&b(!0)};
window.__onGCastApiAvailable=c;g.Ew("//www.gstatic.com/cast/sdk/libs/sender/1.0/cast_framework.js",g.Bw,c)}},bua=function(){var a=Vta(),b=window.document.getElementById(a),c=b&&g.bh(b,"loaded");
c||b&&!c||(b=Wta(a,function(){g.bh(b,"loaded")||(g.ah(b,"loaded","true"),g.Ji(a),g.mi(g.va(Xta,a),0))}))},cua=function(a){return(0,g.Q)(a,function(a){return{key:a.id,
name:a.name}})},O9=function(a,b){A9();
M9()&&M9();Sta(a.id);var c=new g.$y(N9,a,J9());c.connect(b,Yta());c.subscribe("beforeDisconnect",function(a){g.Ki("yt-remote-before-disconnect",a)});
c.subscribe("beforeDispose",function(){y9()&&(y9(),L9(null))});
L9(c)},P9=function(){var a=g.ij();
if(!a)return null;var b=C9().Ed();return g.hi(b,a)},Q9=function(a){g.Kw("remote",a)},R9=function(){var a=y9();
return!!a&&3!=a.getProxyState()},S9=function(){E9()?x9().stopSession():G9("stopSession called before API ready.");
var a=y9();a&&(a.disconnect(1),L9(null))},dua=function(){var a;
a=C9().Oc.$_gos();var b=M9();b&&y9()&&(g.gi(a,b)||a.push(b));return cua(a)},U9=function(a,b){g.Vk.call(this);
this.g=0;this.B=a;this.D=[];this.C=new g.Py;this.A=this.o=null;this.H=(0,g.z)(this.AG,this);this.F=(0,g.z)(this.bj,this);this.G=(0,g.z)(this.zG,this);this.J=(0,g.z)(this.KG,this);var c=0;a?(c=a.getProxyState(),3!=c&&(a.subscribe("proxyStateChange",this.aq,this),eua(this))):c=3;0!=c&&(b?this.aq(c):g.mi((0,g.z)(function(){this.aq(c)},this),0));
var d=$ta();d&&T9(this,d);this.subscribe("yt-remote-cast2-session-change",this.J)},V9=function(a){return new g.Uy(a.B.getPlayerContextData())},fua=function(a,b,c,d,e){var f=V9(a),k=e||f.listId;
d=d||0;var l={videoId:b,currentIndex:d};g.Yy(f,b,d);g.p(c)&&(g.Wy(f,c),l.currentTime=c);g.p(k)&&(l.listId=k);W9(a,"setPlaylist",l);e||X9(a,f)},eua=function(a){(0,g.F)("nowAutoplaying autoplayDismissed remotePlayerChange remoteQueueChange autoplayModeChange autoplayUpNext previousNextChange".split(" "),function(a){this.D.push(this.B.subscribe(a,g.va(this.DI,a),this))},a)},gua=function(a){(0,g.F)(a.D,function(a){this.B.unsubscribeByKey(a)},a);
a.D.length=0},Y9=function(a,b){50>a.C.tc()&&g.Ry(a.C,b)},Z9=function(a,b,c){var d=V9(a);
g.Wy(d,c);-1E3!=d.g&&(d.g=b);X9(a,d)},W9=function(a,b,c){a.B.sendMessage(b,c)},X9=function(a,b){gua(a);
a.B.setPlayerContextData(g.Zy(b));eua(a)},T9=function(a,b){a.A&&(a.A.removeUpdateListener(a.H),a.A.removeMediaListener(a.F),a.bj(null));
a.A=b;a.A&&($9("Setting cast session: "+a.A.sessionId),a.A.addUpdateListener(a.H),a.A.addMediaListener(a.F),a.A.media.length&&a.bj(a.A.media[0]))},hua=function(a){var b=a.o.media,c=a.o.customData;
if(b&&c){var d=V9(a);b.contentId!=d.videoId&&$9("Cast changing video to: "+b.contentId);d.videoId=b.contentId;d.g=c.playerState;g.Wy(d,a.o.getEstimatedTime());X9(a,d)}else $9("No cast media video. Ignoring state update.")},$9=function(a){g.Kw("CP",a)},a$=function(a,b,c){return(0,g.z)(function(a){this.Ub("Failed to "+b+" with cast v2 channel. Error code: "+a.code);
a.code!=window.chrome.cast.ErrorCode.TIMEOUT&&(this.Ub("Retrying "+b+" using MDx browser channel."),W9(this,b,c))},a)},iua=function(a){var b=!1;
x9()||(a=new g.ox(a),a.subscribe("yt-remote-cast2-availability-change",function(a){g.dj("yt-remote-cast-available",a);g.Ki("yt-remote-cast2-availability-change",a)}),a.subscribe("yt-remote-cast2-receiver-selected",function(a){w9("onReceiverSelected: "+a.friendlyName);
g.dj("yt-remote-cast-receiver",a);g.Ki("yt-remote-cast2-receiver-selected",a)}),a.subscribe("yt-remote-cast2-receiver-resumed",function(a){w9("onReceiverResumed: "+a.friendlyName);
g.dj("yt-remote-cast-receiver",a)}),a.subscribe("yt-remote-cast2-session-change",function(a){w9("onSessionChange: "+g.di(a));
a||g.fj("yt-remote-cast-receiver");g.Ki("yt-remote-cast2-session-change",a)}),g.ka("yt.mdx.remote.cloudview.instance_",a,void 0),b=!0);
w9("cloudview.createSingleton_: "+b);return b},jua=function(){var a=0<=g.fc.search(/\ (CrMo|Chrome|CriOS)\//);
return g.xi||a},b$=function(a,b){E9()?x9().setConnectedScreenStatus(a,b):G9("setConnectedScreenStatus called before ready.")},kua=function(){w9("clearCurrentReceiver");
g.fj("yt-remote-cast-receiver")},lua=function(){if(0<=window.navigator.userAgent.indexOf("CriOS")){var a=window.__gCrWeb&&window.__gCrWeb.message&&window.__gCrWeb.message.invokeOnHost;
if(a){aua();a({command:"cast.sender.init"});return}}if(window.chrome)if(aua(),a=window.navigator.userAgent,0<=a.indexOf("Android")&&0<=a.indexOf("Chrome/")&&window.navigator.presentation){var a="",b=g.xw();55<=b?a="55":50<=b&&(a="50");g.Ew("//www.gstatic.com/eureka/clank"+a+g.Cw,g.Bw)}else g.Fw(0);else g.Bw()},mua=function(a){a?(g.dj("yt-remote-session-app",a.app),g.dj("yt-remote-session-name",a.name)):(g.fj("yt-remote-session-app"),g.fj("yt-remote-session-name"));
g.ka("yt.mdx.remote.channelParams_",a,void 0)},nua=function(){var a=J9();
if(g.Tb(a)){var a=g.hj(),b=g.ej("yt-remote-session-name")||"",c=g.ej("yt-remote-session-app")||"",a={device:"REMOTE_CONTROL",id:a,name:b,app:c,"mdx-version":3};g.ka("yt.mdx.remote.channelParams_",a,void 0)}},oua=function(){var a=P9();
a?(Q9("Resume connection to: "+g.di(a)),O9(a,0)):(g.rj(),kua(),Q9("Skipping connecting because no session screen found."))},pua=function(a){Q9("remote.onCastSessionChange_: "+g.di(a));
if(a){var b=M9();b&&b.id==a.id?b$(b.id,"YouTube TV"):(b&&S9(),O9(a,1))}else y9()&&S9()},qua=function(){var a=dua(),b=M9();
b||(b=P9());return g.Wa(a,function(a){return b&&g.ai(b,a.key)?!0:!1})},rua=function(){var a=g.ej("yt-remote-cast-receiver");
return a?a.friendlyName:null},sua=function(a,b,c,d){jua()?iua(b)&&(D9(!0),window.chrome&&window.chrome.cast&&window.chrome.cast.isAvailable?Zta(a,c):(window.__onGCastApiAvailable=function(b,d){b?Zta(a,c):(G9("Failed to load cast API: "+d),F9(!1),D9(!1),g.fj("yt-remote-cast-available"),g.fj("yt-remote-cast-receiver"),Uta(),c(!1))},d?window.spf?window.spf.script.load("https://www.gstatic.com/cv/js/sender/v1/cast_sender.js","",void 0):bua():lua())):w9("Cannot initialize because not running Chrome")},
tua=function(a){this.B=this.A="";
this.g="/api/lounge";this.o=!0;a=a||window.document.location.href;var b=g.Vf(a)||"";b&&(this.B=":"+b);this.A=g.Uf(a)||"";a=g.fc;0<=a.search("MSIE")&&(a=a.match(/MSIE ([\d.]+)/)[1],0>g.Na(a,"10.0")&&(this.o=!1))},c$=function(a,b,c){g.H.call(this);
this.H=a;this.X=b;b.addEventListener("onVolumeChange",this.ql,this);b.addEventListener("onCaptionsTrackListChanged",this.Lv,this);b.addEventListener("captionschanged",this.zv,this);b.addEventListener("captionssettingschanged",this.Ap,this);b.addEventListener("videoplayerreset",this.ej,this);b.addEventListener("mdxautoplaycancel",this.zs,this);this.C=!1;this.g=c;c.isDisposed();c.subscribe("proxyStateChange",this.Yv,this);c.subscribe("remotePlayerChange",this.dj,this);c.subscribe("remoteQueueChange",
this.ej,this);c.subscribe("autoplayUpNext",this.xv,this);c.subscribe("previousNextChange",this.Vv,this);c.subscribe("nowAutoplaying",this.Ov,this);c.subscribe("autoplayDismissed",this.wv,this);this.suggestion=null;this.D=new g.Gl(64);this.o=new g.Kd(this.gx,500,this);g.J(this,this.o);this.A=new g.Kd(this.hx,1E3,this);g.J(this,this.A);this.B={};this.G=new g.Kd(this.yx,1E3,this);g.J(this,this.G);this.F=new g.qw(this.KN,1E3,this);g.J(this,this.F);this.J=g.w;this.Ap();this.ej();this.dj()},d$=function(a,
b){var c=a.H,d=a.X.getVideoData().lengthSeconds;
c.H=b||0;c.g.Ra("progresssync",b,d)},uua=function(a){d$(a,0);
a.o.stop();e$(a,new g.Gl(64))},h$=function(a,b){if(f$(a)&&!a.C){var c=null;
b&&(c={style:a.X.Dj()},g.Zb(c,b));a.g.Yw(g$(a),c);a.B=V9(a.g).o}},i$=function(a,b){var c=a.X.ve();
c?fua(a.g,g$(a),b,c.g,c.listId.toString()):fua(a.g,g$(a),b);e$(a,new g.Gl(1))},vua=function(a,b){if(b){var c=a.X.Ic("captions","tracklist",{Iu:1});
c&&c.length?(a.X.cf("captions","track",b),a.C=!1):(a.X.fq("captions"),a.C=!0)}else a.X.cf("captions","track",{})},f$=function(a){return V9(a.g).videoId==g$(a)},g$=function(a){return a.X.getVideoData().videoId},e$=function(a,b){a.A.stop();
var c=a.D;if(b.o!=c.o||b.g!=c.g){var d=g.S(b,2);if(d!=g.S(a.D,2)){var e=a.X;(e=g.im(e.app,e.playerType||1))&&g.TU(e,d)}a.D=b;wua(a.H,c,b)}},j$=function(){var a=qua();
!a&&H9()&&rua()&&(a={key:"cast-selector-receiver",name:rua()});return a},xua=function(){var a=dua();
H9()&&g.ej("yt-remote-cast-available")&&a.push({key:"cast-selector-receiver",name:"Cast..."});return a},yua=function(a){var b={device:"Desktop",
app:"youtube-desktop"};g.bj&&Pta();g.kj();N9||(N9=new tua,g.tj()&&(N9.g="/api/loungedev"));K9||(K9=g.u("yt.mdx.remote.deferredProxies_")||[],g.ka("yt.mdx.remote.deferredProxies_",K9,void 0));nua();var c=C9();if(!c){var d=new g.ax(N9);g.ka("yt.mdx.remote.screenService_",d,void 0);c=C9();sua(a,d,function(a){a?A9()&&b$(A9(),"YouTube TV"):d.subscribe("onlineScreenChange",function(){g.Ki("yt-remote-receiver-availability-change")})},!(!b||!b.loadCastApiSetupScript))}b&&!g.u("yt.mdx.remote.initialized_")&&
(g.ka("yt.mdx.remote.initialized_",!0,void 0),Q9("Initializing: "+g.tf(b)),k$.push(g.Gi("yt-remote-cast2-availability-change",function(){g.Ki("yt-remote-receiver-availability-change")})),k$.push(g.Gi("yt-remote-cast2-receiver-selected",function(){z9(null);
g.Ki("yt-remote-auto-connect","cast-selector-receiver")})),k$.push(g.Gi("yt-remote-cast2-receiver-resumed",function(){g.Ki("yt-remote-receiver-resumed","cast-selector-receiver")})),k$.push(g.Gi("yt-remote-cast2-session-change",pua)),k$.push(g.Gi("yt-remote-connection-change",function(a){a?b$(A9(),"YouTube TV"):P9()||(b$(null,null),kua())})),a=J9(),b.isAuto&&(a.id+="#dial"),g.Mm("desktop_enable_autoplay")&&(a.capabilities=["atp"]),a.name=b.device,a.app=b.app,Q9(" -- with channel params: "+g.tf(a)),
mua(a),c.start(),A9()||oua())},l$=function(){H9()?x9()?E9()?(w9("Requesting cast selector."),x9().requestSession()):(w9("Wait for cast API to be ready to request the session."),I9.push(g.Gi("yt-remote-cast2-api-ready",l$))):G9("requestCastSelector: Cast is not initialized."):G9("requestCastSelector: Cast API is not installed!")},m$=function(a){g.vu.call(this,a);
this.A={key:g.fi(),name:g.P("YTP_MDX_MY_COMPUTER")};this.C=null;this.D=[];this.J=this.o=null;this.G=[this.A];this.B=this.A;this.F=new g.Gl(64);this.H=0},wua=function(a,b,c){a.F=c;
a.g.Ra("presentingplayerstatechange",new g.mz(c,b))},n$=function(a,b,c){if(b.key!=a.B.key)if(b.key==a.A.key)S9();
else{a.B=b;var d;if(!c){c=a.g.ve();d=a.g.getVideoData().videoId;var e;if(c){e=[];for(var f=0;f<c.B;f++)e[f]=c.Tb(f).videoId}else e=[a.g.getVideoData().videoId];d={videoIds:e,listId:a.g.bf(),videoId:d,index:Math.max(a.g.$x(),0),currentTime:a.g.getCurrentTime()}}a=d;Q9("Connecting to: "+g.tf(b));"cast-selector-receiver"==b.key?(z9(a||null),b=a||null,E9()?x9().setLaunchParams(b):G9("setLaunchParams called before ready.")):!a&&R9()&&A9()==b.key?g.Ki("yt-remote-connection-change",!0):(S9(),z9(a||null),
a=C9().Ed(),(b=g.hi(a,b.key))&&O9(b,1))}};
g.B(v9,g.Ow);g.h=v9.prototype;g.h.Ed=function(a){return this.Oc.$_gs(a)};
g.h.contains=function(a){return!!this.Oc.$_c(a)};
g.h.get=function(a){return this.Oc.$_g(a)};
g.h.start=function(){this.Oc.$_st()};
g.h.im=function(a,b,c){this.Oc.$_a(a,b,c)};
g.h.remove=function(a,b,c){this.Oc.$_r(a,b,c)};
g.h.Ul=function(a,b,c,d){this.Oc.$_un(a,b,c,d)};
g.h.R=function(){for(var a=0,b=this.o.length;a<b;++a)this.Oc.$_ubk(this.o[a]);this.o.length=0;this.Oc=null;v9.M.R.call(this)};
g.h.DL=function(){this.$("screenChange")};
g.h.jI=function(){this.$("onlineScreenChange")};
var B9=null,I9=[],K9=null,N9=null;g.B(U9,g.Vk);g.h=U9.prototype;g.h.play=function(){1==this.g?(this.o?this.o.play(null,g.w,a$(this,"play")):W9(this,"play"),Z9(this,1,g.Xy(V9(this))),this.$("remotePlayerChange")):Y9(this,this.play)};
g.h.pause=function(){1==this.g?(this.o?this.o.pause(null,g.w,a$(this,"pause")):W9(this,"pause"),Z9(this,2,g.Xy(V9(this))),this.$("remotePlayerChange")):Y9(this,this.pause)};
g.h.Px=function(a){if(1==this.g){if(this.o){var b=V9(this),c=new window.chrome.cast.media.SeekRequest;c.currentTime=a;c.resumeState=b.gb()||3==b.g?window.chrome.cast.media.ResumeState.PLAYBACK_START:window.chrome.cast.media.ResumeState.PLAYBACK_PAUSE;this.o.seek(c,g.w,a$(this,"seekTo",{newTime:a}))}else W9(this,"seekTo",{newTime:a});Z9(this,3,a);this.$("remotePlayerChange")}else Y9(this,g.va(this.Px,a))};
g.h.stop=function(){if(1==this.g){this.o?this.o.stop(null,g.w,a$(this,"stopVideo")):W9(this,"stopVideo");var a=V9(this);a.index=-1;a.videoId="";g.Vy(a);X9(this,a);this.$("remotePlayerChange")}else Y9(this,this.stop)};
g.h.setVolume=function(a,b){if(1==this.g){var c=V9(this);if(this.A){if(c.volume!=a){var d=Math.round(a)/100;this.A.setReceiverVolumeLevel(d,(0,g.z)(function(){$9("set receiver volume: "+d)},this),(0,g.z)(function(){this.Ub("failed to set receiver volume.")},this))}c.muted!=b&&this.A.setReceiverMuted(b,(0,g.z)(function(){$9("set receiver muted: "+b)},this),(0,g.z)(function(){this.Ub("failed to set receiver muted.")},this))}else{var e={volume:a,
muted:b};-1!=c.volume&&(e.delta=a-c.volume);W9(this,"setVolume",e)}c.muted=b;c.volume=a;X9(this,c)}else Y9(this,g.va(this.setVolume,a,b))};
g.h.Yw=function(a,b){if(1==this.g){var c=V9(this),d={videoId:a};b&&(c.o={trackName:b.name,languageCode:b.languageCode,sourceLanguageCode:b.translationLanguage?b.translationLanguage.languageCode:"",languageName:b.languageName,format:b.format,kind:b.kind},d.style=g.tf(b.style),g.Zb(d,c.o));W9(this,"setSubtitlesTrack",d);X9(this,c)}else Y9(this,g.va(this.Yw,a,b))};
g.h.$p=function(a,b){if(1==this.g){W9(this,"setAudioTrack",{videoId:a,audioTrackId:b.Ec.id});var c=V9(this);c.audioTrackId=b.Ec.id;X9(this,c)}else Y9(this,g.va(this.$p,a,b))};
g.h.Ox=function(a,b){if(1==this.g){if(a&&b){var c=V9(this);g.Yy(c,a,b);X9(this,c)}W9(this,"previous")}else Y9(this,g.va(this.Ox,a,b))};
g.h.Nx=function(a,b){if(1==this.g){if(a&&b){var c=V9(this);g.Yy(c,a,b);X9(this,c)}W9(this,"next")}else Y9(this,g.va(this.Nx,a,b))};
g.h.kt=function(){1==this.g?W9(this,"dismissAutoplay"):Y9(this,this.kt)};
g.h.dispose=function(){if(3!=this.g){var a=this.g;this.g=3;this.$("proxyStateChange",a,this.g)}U9.M.dispose.call(this)};
g.h.R=function(){gua(this);this.B=null;this.C.clear();T9(this,null);U9.M.R.call(this)};
g.h.aq=function(a){if((a!=this.g||2==a)&&3!=this.g&&0!=a){var b=this.g;this.g=a;this.$("proxyStateChange",b,a);if(1==a)for(;!this.C.isEmpty();)g.Sy(this.C).apply(this);else 3==a&&this.dispose()}};
g.h.DI=function(a,b){this.$(a,b)};
g.h.AG=function(a){if(!a)this.bj(null),T9(this,null);else if(this.A.receiver.volume){a=this.A.receiver.volume;var b=V9(this),c=Math.round(100*a.level||0);if(b.volume!=c||b.muted!=a.muted)$9("Cast volume update: "+a.level+(a.muted?" muted":"")),b.volume=c,b.muted=!!a.muted,X9(this,b)}};
g.h.bj=function(a){$9("Cast media: "+!!a);this.o&&this.o.removeUpdateListener(this.G);if(this.o=a)this.o.addUpdateListener(this.G),hua(this),this.$("remotePlayerChange")};
g.h.zG=function(a){a?(hua(this),this.$("remotePlayerChange")):this.bj(null)};
g.h.KG=function(){var a=$ta();a&&T9(this,a)};
g.h.Ub=function(a){g.Kw("CP",a)};
var k$=[];g.h=tua.prototype;g.h.tg=function(a,b,c){var d=this.g;if(g.p(c)?c:this.o)d="https://"+this.A+this.B+this.g;return g.cg(d+a,b||{})};
g.h.Zp=function(a,b,c,d){c={format:"JSON",method:"POST",context:this,timeout:5E3,withCredentials:!1,Gb:g.va(this.yL,c,!0),onError:g.va(this.xL,d),Yc:g.va(this.zL,d)};b&&(c.Kb=b,c.headers={"Content-Type":"application/x-www-form-urlencoded"});return g.Oi(a,c)};
g.h.yL=function(a,b,c,d){b?a(d):a({text:c.responseText})};
g.h.xL=function(a,b){a(Error("Request error: "+b.status))};
g.h.zL=function(a){a(Error("request timed out"))};
g.B(c$,g.H);g.h=c$.prototype;
g.h.R=function(){c$.M.R.call(this);this.o.stop();this.A.stop();this.J();this.X.removeEventListener("onVolumeChange",this.ql,this);this.X.removeEventListener("onCaptionsTrackListChanged",this.Lv,this);this.X.removeEventListener("captionschanged",this.zv,this);this.X.removeEventListener("videoplayerreset",this.ej,this);this.X.removeEventListener("captionssettingschanged",this.Ap,this);this.X.removeEventListener("mdxautoplaycancel",this.zs,this);this.g.Ka("proxyStateChange",this.Yv,this);this.g.Ka("remotePlayerChange",
this.dj,this);this.g.Ka("remoteQueueChange",this.ej,this);this.g.Ka("autoplayUpNext",this.xv,this);this.g.Ka("previousNextChange",this.Vv,this);this.g.Ka("nowAutoplaying",this.Ov,this);this.g.Ka("autoplayDismissed",this.wv,this);this.g=this.H=null};
g.h.Py=function(a,b){2==this.g.g||(f$(this)?this.KD.apply(this,arguments):this.GD.apply(this,arguments))};
g.h.zv=function(a){this.Py("control_subtitles_set_track",g.Tb(a)?null:a)};
g.h.Ap=function(){var a=this.X.Ic("captions","track");g.Tb(a)||h$(this,a)};
g.h.GD=function(a,b){var c=Array.prototype.slice.call(arguments,1);switch(a){case "control_toggle_play_pause":case "control_play":case "control_pause":i$(this,this.X.getCurrentTime());break;case "control_seek":i$(this,c[0]);break;case "control_subtitles_set_track":h$(this,c[0]);break;case "control_set_audio_track":c=c[0],f$(this)&&this.g.$p(g$(this),c)}};
g.h.KD=function(a,b){if(1081!=V9(this.g).g||"control_seek"!=a){var c=Array.prototype.slice.call(arguments,1);switch(a){case "control_toggle_play_pause":V9(this.g).gb()?this.g.pause():this.g.play();break;case "control_play":this.g.play();break;case "control_pause":this.g.pause();break;case "control_seek":this.F.lh(c[0],c[1]);break;case "control_subtitles_set_track":h$(this,c[0]);break;case "control_set_audio_track":c=c[0],f$(this)&&this.g.$p(g$(this),c)}}};
g.h.ql=function(a){if(f$(this)){this.g.Ka("remotePlayerChange",this.dj,this);var b=Math.round(a.volume);a=!!a.muted;var c=V9(this.g);if(b!=c.volume||a!=c.muted)this.g.setVolume(b,a),this.G.start();this.g.subscribe("remotePlayerChange",this.dj,this)}};
g.h.Lv=function(){g.Tb(this.B)||vua(this,this.B);this.C=!1};
g.h.Yv=function(a,b){this.A.stop();2==b&&this.hx()};
g.h.dj=function(){if(f$(this)){this.o.stop();var a=V9(this.g);switch(a.g){case 1081:e$(this,new g.Gl(8));break;case 1:this.gx();e$(this,new g.Gl(8));break;case 1083:case 3:e$(this,new g.Gl(9));break;case 0:e$(this,new g.Gl(2));this.F.stop();d$(this,this.X.getVideoData().lengthSeconds);break;case 1082:e$(this,new g.Gl(4));break;case 2:e$(this,new g.Gl(4));d$(this,g.Xy(a));break;case -1:e$(this,new g.Gl(64));break;case -1E3:a={errorCode:"mdx.remoteerror",message:g.P("YTP_MDX_PLAYER_ERROR")},e$(this,
new g.Gl(128,a))}var a=V9(this.g).o,b=this.B;(a||b?a&&b&&a.trackName==b.trackName&&a.languageCode==b.languageCode&&a.languageName==b.languageName&&a.format==b.format&&a.kind==b.kind:1)||(this.B=a,vua(this,a));a=V9(this.g);-1==a.volume||Math.round(this.X.getVolume())==a.volume&&this.X.Id()==a.muted||this.G.isActive()||this.yx()}else uua(this)};
g.h.Vv=function(){this.X.Ra("mdxpreviousnextchange")};
g.h.ej=function(){f$(this)||uua(this)};
g.h.zs=function(){this.g.kt()};
g.h.xv=function(a){a&&(a=g.Oi("/watch_queue_ajax",{method:"GET",xc:{action_get_watch_queue_item:1,video_id:a},Gb:(0,g.z)(this.BJ,this)}))&&(this.J=(0,g.z)(a.abort,a))};
g.h.BJ=function(a,b){var c=new g.kt({videoId:b.videoId,title:b.title,author:b.author,murlmq_webp:b.url});this.suggestion=c;this.X.Ra("mdxautoplayupnext",c)};
g.h.Ov=function(a){(0,window.isNaN)(a)||this.X.Ra("mdxnowautoplaying",a)};
g.h.wv=function(){this.X.Ra("mdxautoplaycanceled")};
g.h.KN=function(a,b){-1==V9(this.g).g?i$(this,a):b&&this.g.Px(a)};
g.h.yx=function(){if(f$(this)){var a=V9(this.g);this.X.removeEventListener("onVolumeChange",this.ql,this);a.muted?this.X.mute():this.X.Df();this.X.setVolume(a.volume);this.X.addEventListener("onVolumeChange",this.ql,this)}};
g.h.gx=function(){this.o.stop();if(!this.g.isDisposed()){var a=V9(this.g);a.gb()&&e$(this,new g.Gl(8));d$(this,g.Xy(a));this.o.start()}};
g.h.hx=function(){this.A.stop();this.o.stop();var a=this.g.B.getReconnectTimeout();2==this.g.g&&!(0,window.isNaN)(a)&&this.A.start()};
g.B(m$,g.vu);g.h=m$.prototype;g.h.create=function(){yua("embedded"==g.U(this.g).g);this.D.push(g.Gi("yt-remote-before-disconnect",this.wG,this));this.D.push(g.Gi("yt-remote-connection-change",this.LI,this));this.D.push(g.Gi("yt-remote-receiver-availability-change",this.Wv,this));this.D.push(g.Gi("yt-remote-auto-connect",this.JI,this));this.D.push(g.Gi("yt-remote-receiver-resumed",this.II,this));this.Wv()};
g.h.load=function(){this.g.sn();m$.M.load.call(this);this.C=new c$(this,this.g,this.o);var a;a=(a=Yta())?a.currentTime:0;var b=R9()?new U9(y9(),void 0):null;0==a&&b&&(a=g.Xy(V9(b)));0!=a&&(this.H=a||0,this.g.Ra("progresssync",a,void 0));wua(this,this.F,this.F);g.o2(this.g.app,6)};
g.h.unload=function(){this.g.Ra("mdxautoplaycanceled");this.B=this.A;g.Eb(this.C,this.o);this.o=this.C=null;m$.M.unload.call(this);g.o2(this.g.app,5)};
g.h.R=function(){g.Hi(this.D);m$.M.R.call(this)};
g.h.Gj=function(a,b){this.loaded&&this.C.Py.apply(this.C,arguments)};
g.h.mD=function(){return this.loaded?this.C.suggestion:null};
g.h.Iy=function(){return this.o?V9(this.o).L:!1};
g.h.hasNext=function(){return this.o?V9(this.o).hasNext:!1};
g.h.getCurrentTime=function(){return this.H};
g.h.kN=function(){var a=V9(this.o),b=this.g.getVideoData(),c=g.ym(this.g),d=b.clipEnd,b=b.clipStart,e=this.getCurrentTime(),f=a.getDuration(),k;k=a.H?a.B+((0,g.E)()-a.A)/1E3:a.B;var l=1>=Ota(a)-this.getCurrentTime(),m=a.J,n=Ota(a),a=0<a.C?a.C+((0,g.E)()-a.A)/1E3:a.C;return{allowSeeking:c,clipEnd:d,clipStart:b,current:e,displayedStart:-1,duration:f,ingestionTime:k,isPeggedToLive:l,loaded:m,seekableEnd:n,seekableStart:a}};
g.h.lN=function(){this.o&&this.o.Nx()};
g.h.mN=function(){this.o&&this.o.Ox()};
g.h.wG=function(a){1==a&&(this.J=this.o?V9(this.o):null)};
g.h.LI=function(){var a=R9()?new U9(y9(),void 0):null;if(a){var b=this.B;this.loaded&&this.unload();this.o=a;this.J=null;b.key!=this.A.key&&(this.B=b,this.load())}else g.Db(this.o),this.o=null,this.loaded&&(this.unload(),(a=this.J)&&a.videoId==this.g.getVideoData().videoId&&this.g.Jc(g.Xy(a)));this.g.Ra("videodatachange","newdata",this.g.getVideoData(),3)};
g.h.Wv=function(){this.G=[this.A].concat(xua());var a=j$()||this.A;n$(this,a,!this.loaded);this.g.ya("onMdxReceiversChange")};
g.h.JI=function(){var a=j$();n$(this,a)};
g.h.II=function(){this.B=j$()};
g.h.jN=function(a,b){switch(a){case "casting":return this.loaded;case "receivers":return this.G;case "currentReceiver":return b&&("cast-selector-receiver"==b.key?l$():n$(this,b)),this.loaded?this.B:this.A;case "quickCast":return 2==this.G.length&&"cast-selector-receiver"==this.G[1].key?(b&&l$(),!0):!1}};
g.h.nN=function(){W9(this.o,"sendDebugCommand",{debugCommand:"stats4nerds "})};
g.h.Xd=function(){return!1};
window._exportCheck==g.xa&&g.ka("ytmod.player.remote",m$,void 0);})(_yt_player);
