(function(g){var window=this;'use strict';var qb=function(q,Z){this.K={};this.D=[];this.W2=this.size=0;var F=arguments.length;if(F>1){if(F%2)throw Error("Uneven number of arguments");for(var B=0;B 5&&(q=q.slice(q.length-5)); var Z=g.DC(QBE(),function(B){return B.loungeToken}),F=g.DC(q,function(B){return B.loungeToken}); g.yA(F,function(B){return!g.r1(Z,B)})&&$im(); g.e0("yt-remote-local-screens",q,31536E3)},ws=function(q){var Z=pKE(); Z.dispatchEvent(new di8(Z,q))},Vqu=function(q,Z){var F=q.screens.length; q.screens=g.uh(q.screens,function(B){return!(B||Z?!B!=!Z?0:B.id==Z.id:1)}); return q.screens.length0&&(F.eU=1.5*b);B=F;var N=q.Gi();if(N){var S=g.zr(N,"X-Client-Wire-Protocol");if(S){var l=B.K;!l.D&&(g.Bj(S,"spdy")||g.Bj(S,"quic")||g.Bj(S,"h2"))&&(l.G=l.Z,l.D=new Set,l.K&&(QLB(l,l.K),l.K=null))}if(B.k$){var U=g.zr(N,"X-HTTP-Session-Id");U&&(B.QC=U,g.E2(B.BG,B.k$,U))}}F.iQ=3;F.Z&&F.Z.oA();F.LB&&(F.G0=Date.now()-q.zP);B=F;var u=q;B.bb=xmt(B,B.Oc?B.Tb:null,B.VO); if(u.Oc){AV0(B.K,u);var P=u,W=B.eU;W&&P.setTimeout(W);P.Dl&&(vmB(P),se(P));B.D=u}else Xum(B);F.S.length>0&&jM(F)}else D[0]!="stop"&&D[0]!="close"||ke(F,7);else F.iQ==3&&(D[0]=="stop"||D[0]=="close"?D[0]=="stop"?ke(F,7):F.disconnect():D[0]!="noop"&&F.Z&&F.Z.yb(D),F.uL=0)}I1(4)}catch(H){}},Xv=function(q){q.D&&(nm_(q),q.D.cancel(),q.D=null)},hN=function(q){if(q.size!=q.D.length){for(var Z=0,F=0;Z=q.length)return g.nQ;if(Z in q)return g.a9(q[Z++]);Z++}}; return F}throw Error("Not implemented");},igm=function(q){window.chrome&&chrome.cast&&chrome.cast.logMessage&&chrome.cast.logMessage(q)},Ye=function(q){this.name=this.id=""; this.clientName="UNKNOWN_INTERFACE";this.app="";this.type="REMOTE_CONTROL";this.ownerObfuscatedGaiaId=this.obfuscatedGaiaId=this.avatar=this.username="";this.capabilities=new Set;this.compatibleSenderThemes=new Set;this.experiments=new Set;this.theme="u";new qb;this.model=this.brand="";this.year=0;this.chipset=this.osVersion=this.os="";this.mdxDialServerType="MDX_DIAL_SERVER_TYPE_UNKNOWN";q&&(this.id=q.id||q.name,this.name=q.name,this.clientName=q.clientName?q.clientName.toUpperCase():"UNKNOWN_INTERFACE", this.app=q.app,this.type=q.type||"REMOTE_CONTROL",this.username=q.user||"",this.avatar=q.userAvatarUri||"",this.obfuscatedGaiaId=q.obfuscatedGaiaId||"",this.ownerObfuscatedGaiaId=q.ownerObfuscatedGaiaId||"",this.theme=q.theme||"u",k55(this,q.capabilities||""),sL0(this,q.compatibleSenderThemes||""),jLm(this,q.experiments||""),this.brand=q.brand||"",this.model=q.model||"",this.year=q.year||0,this.os=q.os||"",this.osVersion=q.osVersion||"",this.chipset=q.chipset||"",this.mdxDialServerType=q.mdxDialServerType|| "MDX_DIAL_SERVER_TYPE_UNKNOWN",q=q.deviceInfo)&&(q=JSON.parse(q),this.brand=q.brand||"",this.model=q.model||"",this.year=q.year||0,this.os=q.os||"",this.osVersion=q.osVersion||"",this.chipset=q.chipset||"",this.clientName=q.clientName?q.clientName.toUpperCase():"UNKNOWN_INTERFACE",this.mdxDialServerType=q.mdxDialServerType||"MDX_DIAL_SERVER_TYPE_UNKNOWN")},pKE=function(){return IGj=IGj||new g.xl},cVE=function(q,Z,F,B,f){Cr0(q); if(q.D){var D=g.oa("ID_TOKEN"),G=q.D.Eq||{};D?G["x-youtube-identity-token"]=D:delete G["x-youtube-identity-token"];q.D.Eq=G}hOm(q);B?(B.getState()!=3&&RO6(B)==0||B.getState(),q.D.connect(Z,F,q.Dl,B.G,B.z4)):f?q.D.connect(Z,F,q.Dl,f.sessionId,f.arrayId):q.D.connect(Z,F,q.Dl)},JVj=function(q){return q.G?q.X+tN(q):q.X},Lx5=function(q,Z){return q.K?q.K==Z:q.D?q.D.has(Z):!1},pr=function(q,Z){var F=q.Z; F.D.length+F.K.length<50&&q.Z.enqueue(Z)},JN=function(){var q=g.wQ(); if(!q)return null;var Z=ds();if(!Z)return null;Z=Z.Uq();return V4(Z,q)},AV0=function(q,Z){q.K&&q.K==Z?q.K=null:q.D&&q.D.has(Z)&&q.D.delete(Z)},Ti=function(q){return new eM(q.G.getPlayerContextData())},dm_=function(q,Z){return q.VO?!0:q.vG?Object.values(Yc6).includes(Z):q.Jn?!Object.values(tTj).includes(Z):q.KB?Object.values(pum).includes(Z):!1},VTE=function(){var q=window.navigator.userAgent.match(/Chrome\/([0-9]+)/); return q?parseInt(q[1],10):0},Tb5=function(){var q=g.o7.V3(); q&&eOE(q,q.jt.Pu(!0))},od5=function(q,Z){var F; Z?F=Z.Tb:F=q.o_++;var B=q.BG.clone();g.E2(B,"SID",q.G);g.E2(B,"RID",F);g.E2(B,"AID",q.WG);Mb(q,B);q.X&&q.PG&&g.QX(B,q.X,q.PG);F=new y4(q,q.G,F,q.zP+1);q.X===null&&(F.BG=q.PG);Z&&(q.S=Z.uL.concat(q.S));Z=MTm(q,F,1E3);F.setTimeout(Math.round(q.Lp*.5)+Math.round(q.Lp*.5*Math.random()));QLB(q.K,F);Mqu(F,B,Z)},qW8=function(q){q.SI||q.YK||(q.X=1,q.YK=nr((0,g.Jy)(q.Ll,q),0),q.Sm=0)},Z1m=function(q,Z,F){q.B_=1; q.aq=bt(Z.clone());q.bF=F;q.k$=!0;Nb0(q,null)},FOm=function(q){ox("remote.onCastSessionChange_: "+rs(q)); if(q){var Z=qK();if(Z&&Z.id==q.id){if(Zh(Z.id,"YouTube TV"),q.idType=="shortLived"&&(q=q.token))FO&&(FO.token=q),(Z=xe())&&Z.OY(q)}else Z&&AN(),Bq(q,1)}else xe()&&AN()},Dh=function(q,Z){Z=Z===void 0?!1:Z; fl.call(this,"ScreenService");this.G=q;this.X=Z;this.D=this.K=null;this.S=[];this.Z={};Bdm(this)},Dnu=function(q,Z,F,B){g.L4(q.j); q.j=0;fd0(q.G,Z,function(f){f||B<0?F(f):q.j=g.OT(function(){Dnu(q,Z,F,B-1)},300)})},GMm=function(q,Z){try{q.D.xs(q,Z),q.D.u5(4)}catch(F){}},zs6=function(q){q.KF&&(g.W5.clearTimeout(q.KF),q.KF=null)},ndu=function(){},Nde=function(q,Z){if(q.D==0)throw Error("Invalid operation: sending map when state is closed"); q.K.push(new b10(q.Mw++,Z));q.D!=2&&q.D!=3||NNj(q)},gdm=function(q){q.j=g.OT(function(){GV("Connecting timeout"); q.x7(1)},2E4)},Wo=function(q,Z){var F=q.D; q.K&&(F=q.scheme+"://"+q.domain+q.port+q.D);return g.gJ(F+Z,{})},SW_=function(q,Z){var F=Z.params.videoId; delete Z.params.videoId;F==q.D.videoId&&(g.q_(Z.params)?q.D.trackData=null:q.D.trackData=Z.params,q.publish("remotePlayerChange"))},zV=function(q,Z){q.uQ&&(q=q.uQ.Fs())&&g.Hh(q,function(F,B){g.E2(Z,B,F)})},uu0=function(q){return"chrome-extension://"+q+"/cast_sender.js"},ox=function(q){Bo("remote",q)},ld0=function(q){if(q.length==0)return[]; var Z=q[0].indexOf("#"),F=Z==-1?q[0]:q[0].substring(0,Z);return g.DC(q,function(B,f){return f==0?B:B.substring(F.length)})},Un_=function(){return g.sY("yt-remote-session-browser-channel")},ud5=function(q){var Z={}; Z.index=q.index;Z.listId=q.listId;Z.videoId=q.videoId;Z.playerState=q.playerState;Z.volume=q.volume;Z.muted=q.muted;Z.audioTrackId=q.audioTrackId;Z.trackData=g.Mf(q.trackData);Z.hasPrevious=q.MS;Z.hasNext=q.jr;Z.playerTime=q.j;Z.playerTimeAt=q.Z;Z.seekableStart=q.K;Z.seekableEnd=q.X;Z.duration=q.S;Z.loadedTime=q.V;Z.liveIngestionTime=q.D;return Z},wcE=function(q,Z,F,B,f,D){q.info("getAutomaticScreenByIds "+F+" / "+Z); F||(F=q.Z[Z]);var G=q.Uq(),n=F?V4(G,F):null;F&&(q.X||n)||(n=V4(G,Z));if(n){n.uuid=Z;var b=nl(q,n);PSt(q.D,b,function(N){f(N?b:null)})}else F?rEe(q,F,(0,g.Jy)(function(N){var S=nl(this,new bB({name:B, screenId:F,loungeToken:N,dialId:Z||""}));PSt(this.D,S,function(l){f(l?S:null)})},q),D):f(null)},rEe=function(q,Z,F,B){q.info("requestLoungeToken_ for "+Z); var f={postParams:{screen_ids:Z},method:"POST",context:q,onSuccess:function(D,G){D=G&&G.screens||[];D[0]&&D[0].screenId==Z?F(D[0].loungeToken):B(Error("Missing lounge token in token response"))}, onError:function(){B(Error("Request screen lounge token failed"))}}; g.QN(Wo(q.G,"/pairing/get_lounge_token_batch"),f)},nr=function(q,Z){if(typeof q!=="function")throw Error("Fn must not be null and must be a function"); return g.W5.setTimeout(function(){q()},Z)},WOu=function(q,Z){return new g.GD(q,Z)},Nb0=function(q,Z){q.q$=Date.now(); yEt(q);q.Z4=q.aq.clone();Lr(q.Z4,"t",q.j);q.UF=0;q.WE=q.D.J4(q.D.Cq()?Z:null);q.Ev>0&&(q.RY=new g.IF((0,g.Jy)(q.hw,q,q.WE),q.Ev));q.S.listen(q.WE,"readystatechange",q.vj);Z=q.gI?g.Js(q.gI):{};q.bF?(q.wu="POST",Z["Content-Type"]="application/x-www-form-urlencoded",q.WE.send(q.Z4,q.wu,q.bF,Z)):(q.wu="GET",q.tb&&!g.YN&&(Z.Connection="close"),q.WE.send(q.Z4,q.wu,null,Z));q.D.u5(1)},ut=function(){},H1E=function(q,Z){g.In.call(this); this.j=Z;Z=(Z=g.sY("yt-remote-online-screen-ids")||"")?Z.split(","):[];for(var F={},B=this.j(),f=B.length,D=0;D0&&(q[0].nextHopProtocol=="hq"||q[0].nextHopProtocol=="h2")):q=!!(g.W5.chrome&&g.W5.chrome.loadTimes&&g.W5.chrome.loadTimes()&&g.W5.chrome.loadTimes().wasFetchedViaSpdy);this.G=q?this.Z:1;this.D=null;this.G>1&&(this.D=new Set);this.K=null;this.S=[]},cEE=function(q){var Z=q.D.j; Z!=null?(lB(5),Z?(lB(11),UG(q.D,q,!1)):(lB(12),UG(q.D,q,!0))):(q.nR=new uB(q),q.nR.gI=q.M3,Z=q.D,Z=Pq(Z,Z.Cq()?q.du:null,q.DT),lB(5),Lr(Z,"TYPE","xmlhttp"),gmt(q.nR,Z,!1,q.du,!1))},hsj=function(q){return{name:q.name, screenId:q.id,loungeToken:q.token,dialId:q.uuid,screenIdType:q.idType,screenIdSecret:q.secret}},JE0=function(){g.SL.call(this,"p")},GV=function(q){Bo("conn",q)},pcE=function(q,Z){var F=q.UF,B=Z.indexOf("\n",F); if(B==-1)return YWE;F=Number(Z.substring(F,B));if(isNaN(F))return tAE;B+=1;if(B+F>Z.length)return YWE;Z=Z.slice(B,B+F);q.UF=B+F;return Z},dne=function(q,Z,F){var B=new Image; B.onload=function(){try{rv(B),F(!0)}catch(f){}}; B.onerror=function(){try{rv(B),F(!1)}catch(f){}}; B.onabort=function(){try{rv(B),F(!1)}catch(f){}}; B.ontimeout=function(){try{rv(B),F(!1)}catch(f){}}; g.W5.setTimeout(function(){if(B.ontimeout)B.ontimeout()},Z); B.src=q},jLm=function(q,Z){q.experiments.clear(); Z.split(",").forEach(function(F){q.experiments.add(F)})},esm=function(q){var Z=Pq(q.D,q.V6,"/mail/images/cleardot.gif"); bt(Z);VAe(Z.toString(),5E3,(0,g.Jy)(q.Dc,q),3,2E3);q.u5(1)},oZ_=function(q){return new Promise(function(Z){q.Y$=$m6(); if(q.BG){var F=new chrome.cast.DialLaunchResponse(!0,Tdm(q));Z(F);MAu(q)}else q.Dl=function(){g.L4(q.PG);q.Dl=function(){}; q.PG=NaN;var B=new chrome.cast.DialLaunchResponse(!0,Tdm(q));Z(B);MAu(q)},q.PG=g.OT(function(){q.Dl()},100)})},ByB=function(q,Z,F,B,f){function D(){return new qvE(Wo(q,"/bc"),Z,!1,F,B)} F=F===void 0?function(){return""}:F; return g.cz("enable_mdx_web_channel_desktop")?new i1B(function(){return new ZG5(Wo(q,"/wc"),Z,F)}):new FGm(D,f)},DXt=function(q,Z){var F=(Date.now()-fH0)/1E3; F.toFixed&&(F=F.toFixed(3));var B=[];B.push("[",F+"s","] ");B.push("[","yt.mdx.remote","] ");B.push(q+": "+Z,"\n");return B.join("")},Gz_=function(q,Z){var F=5E3+Math.floor(Math.random()*1E4); q.isActive()||(F*=2);return F*Z},qK=function(){var q=wv(); if(!q)return null;var Z=ds().Uq();return V4(Z,q)},zK0=function(q){q=g.He(g.MA(q.D,function(Z){return Z})); g.ch(q);q.length?g.e0("yt-remote-online-screen-ids",q.join(","),60):g.qF("yt-remote-online-screen-ids")},bGE=function(q){this.S=[]; this.Tb=this.bb=this.BG=this.VO=this.D=this.QC=this.k$=this.dU=this.X=this.Gb=this.PG=null;this.Lm=this.o_=0;this.lx=Wq("failFast",!1,q);this.HG=this.Dl=this.V=this.j=this.Z=null;this.Hg=!0;this.ac=this.WG=-1;this.j$=this.uL=this.zP=0;this.OP=Wq("baseRetryDelayMs",5E3,q);this.gj=Wq("retryDelaySeedMs",1E4,q);this.yd=Wq("forwardChannelMaxRetries",2,q);this.Lp=Wq("forwardChannelRequestTimeoutMs",2E4,q);this.J0=q&&q.Obl||void 0;this.hC=q&&q.WvU||void 0;this.yC=q&&q.fLF||!1;this.eU=void 0;this.Oc=q&&q.uyp|| !1;this.G="";this.K=new Rsm(q&&q.iUa);this.ix=new nZ_;this.Jn=q&&q.l3$||!1;this.vG=q&&q.BVU||!1;this.Jn&&this.vG&&(this.vG=!1);this.oa=q&&q.Ton||!1;q&&q.oKp&&(this.Hg=!1);this.LB=!this.Jn&&this.Hg&&q&&q.zsl||!1;this.X3=void 0;q&&q.im&&q.im>0&&(this.X3=q.im);this.KB=void 0;this.G0=0;this.I_=!1;this.w2=this.Y$=null},Ny6=function(q,Z){if(yx(q)){q.sy.unsubscribe("remotePlayerChange",q.AQ,q); var F=Math.round(Z.volume);Z=!!Z.muted;var B=Ti(q.sy);if(F!==B.volume||Z!==B.muted)q.sy.setVolume(F,Z),q.PG.start();q.sy.subscribe("remotePlayerChange",q.AQ,q)}},gZE=function(q){q.Js(1,0); q.j6=Pq(q,null,q.Ks);NNj(q)},Ll=function(){var q=g.sY("yt-remote-connected-devices")||[]; g.ch(q);return q},Sv5=function(){if(!Hq){var q=g.oB(); q&&(Hq=new g.ML(q))}},lH_=function(){},OG=function(q,Z){g.In.call(this); this.config_=Z;this.K=q;this.V=Z.appId||"233637DE";this.G=Z.theme||"cl";this.PG=Z.disableCastApi||!1;this.j=Z.forceMirroring||!1;this.D=null;this.X=!1;this.S=[];this.Z=(0,g.Jy)(this.k3U,this)},co=function(q){g.w.call(this,{Y:"div", W:"ytp-remote",T:[{Y:"div",W:"ytp-remote-display-status",T:[{Y:"div",W:"ytp-remote-display-status-icon",T:[g.sY6()]},{Y:"div",W:"ytp-remote-display-status-text",Ka:"{{statustext}}"}]}]});this.api=q;this.fade=new g.L3(this,250);g.y(this,this.fade);this.N(q,"presentingplayerstatechange",this.onStateChange);this.xS(q.getPlayerStateObject())},UX5=function(q){g.SL.call(this,"serverreachability",q)},u1E=function(q){if(q.SI||q.YK||q.Sm>=3)return!1; q.X++;q.YK=nr((0,g.Jy)(q.Ll,q),Gz_(q,q.Sm));q.Sm++;return!0},Pi6=function(q,Z){var F=Z.params.hasNext=="true"; q.D.MS=Z.params.hasPrevious=="true";q.D.jr=F;q.publish("previousNextChange")},I1=function(q){var Z=pKE(); Z.dispatchEvent(new UX5(Z,q))},yx_=function(q,Z){var F=null; if(Z){var B=rxt(q);B&&(F={clientName:B.clientName,deviceMake:B.brand,deviceModel:B.model,osVersion:B.osVersion})}g.O9("yt.mdx.remote.remoteClient_",F);Z&&(wlu(q),mm8(q));F=q.K.il()&&isNaN(q.j);Z==F?Z&&(Qx(q,1),Ue(q,"getSubtitlesTrack")):Z?(q.wg()&&q.D.reset(),Qx(q,1),Ue(q,"getNowPlaying"),WGB(q)):q.x7(1)},LG6=function(){a1||(a1=g.ym("yt.mdx.remote.debug.handlers_")||[],g.O9("yt.mdx.remote.debug.handlers_",a1))},OGm=function(q){return HGm(q.D).map(function(Z){var F=q.K; Z=Z.map;"__data__"in Z?(Z=Z.__data__,F=F.G?bI8(Z):Z):F=Z;return F})},xg=function(q,Z){Bo(q.k$,Z)},Aj=function(q,Z,F){q.G.sendMessage(Z,F)},QA8=function(){},xXE=function(q){g.e0("yt-remote-connected-devices",q,86400)},Ax8=function(q,Z,F){q.info("initOnConnectedScreenDataPromise_: Received screenData: "+JSON.stringify(Z)); var B=new bB(Z);return(new Promise(function(f){Dnu(q,B,function(D){D?(q.uL=!0,nl(q.G,B),vq(q,B),XO(q,F)):g.vf(Error("DialSession, RemoteScreen from screenData: "+JSON.stringify(Z)+" is not online."));f(D)},5)})).then(function(f){return f?new chrome.cast.DialLaunchResponse(!1):oZ_(q)})},vZu=function(q){g.O9("yt.mdx.remote.currentScreenId_",q)},yx=function(q){return Ti(q.sy).videoId===q.B.getVideoData(1).videoId},Xlj=function(q){JE0.call(this); q.__headers__&&(this.headers=q.__headers__,this.statusCode=q.__status__,delete q.__headers__,delete q.__status__);var Z=q.__sm__;Z?this.data=(this.D=g.i9(Z))?g.Z1(Z,this.D):Z:this.data=q},KGm=function(q,Z){var F=q.screens.length!=Z.length; q.screens=g.uh(q.screens,function(D){return!!n7e(Z,D)}); for(var B=Z.length,f=0;f=q.G:!1},fl=function(q){g.In.call(this); this.j=q;this.screens=[]},XO=function(q,Z){q.info("getDialAppInfoWithTimeout_ "+Z); kg(q)&&(g.L4(q.X),q.X=0,Z==0?hKE(q):q.X=g.OT(function(){hKE(q)},Z))},tN=function(q){return q.isPlaying()?(g.i$()-q.Z)/1E3:0},Fx6=function(){this.S=null; this.D="";this.K=!1},k55=function(q,Z){q.capabilities.clear(); g.uh(Z.split(","),g.sy(RKj,cxu)).forEach(function(F){q.capabilities.add(F)})},dXu=function(q,Z){Sv5(); if(!Hq||!Hq.get("yt-remote-disable-remote-module-for-dev")){Z=g.oa("MDX_CONFIG")||Z;Tb5();$X6();sG||(sG=new j9(Z?Z.loungeApiHost:void 0),IHB()&&(sG.D="/api/loungedev"));Ix||(Ix=g.ym("yt.mdx.remote.deferredProxies_")||[],g.O9("yt.mdx.remote.deferredProxies_",Ix));Jx0();var F=ds();if(!F){var B=new Dh(sG,Z?Z.disableAutomaticScreenCache||!1:!1);g.O9("yt.mdx.remote.screenService_",B);F=ds();var f={};Z&&(f={appId:Z.appId,disableDial:Z.disableDial,theme:Z.theme,loadCastApiSetupScript:Z.loadCastApiSetupScript, disableCastApi:Z.disableCastApi,enableDialLoungeToken:Z.enableDialLoungeToken,enableCastLoungeToken:Z.enableCastLoungeToken,forceMirroring:Z.forceMirroring});g.O9("yt.mdx.remote.enableConnectWithInitialState_",Z?Z.enableConnectWithInitialState||!1:!1);Yvm(q,B,function(D){D?wv()&&Zh(wv(),"YouTube TV"):B.subscribe("onlineScreenChange",function(){Ho("yt-remote-receiver-availability-change")})},f)}Z&&!g.ym("yt.mdx.remote.initialized_")&&(g.O9("yt.mdx.remote.initialized_",!0),ox("Initializing: "+g.eX(Z)), Cl.push(g.NQ("yt-remote-cast2-api-ready",function(){Ho("yt-remote-api-ready")})),Cl.push(g.NQ("yt-remote-cast2-availability-change",function(){Ho("yt-remote-receiver-availability-change")})),Cl.push(g.NQ("yt-remote-cast2-receiver-selected",function(){hj(null); Ho("yt-remote-auto-connect","cast-selector-receiver")})),Cl.push(g.NQ("yt-remote-cast2-receiver-resumed",function(){Ho("yt-remote-receiver-resumed","cast-selector-receiver")})),Cl.push(g.NQ("yt-remote-cast2-session-change",FOm)),Cl.push(g.NQ("yt-remote-connection-change",function(D){D?Zh(wv(),"YouTube TV"):JN()||(Zh(null,null),tvB())})),Cl.push(g.NQ("yt-remote-cast2-session-failed",function(){Ho("yt-remote-connection-failed")})),q=Wx_(),Z.isAuto&&(q.id+="#dial"),f=Z.capabilities||[],f.length>0&&(q.capabilities= f),q.name=Z.device,q.app=Z.app,(Z=Z.theme)&&(q.theme=Z),ox(" -- with channel params: "+g.eX(q)),q?(g.e0("yt-remote-session-app",q.app),g.e0("yt-remote-session-name",q.name)):(g.qF("yt-remote-session-app"),g.qF("yt-remote-session-name")),g.O9("yt.mdx.remote.channelParams_",q),F.start(),wv()||pl5())}},Rx=function(q){Bo("Controller",q)},NK=function(q){q.publish("handlerOpened"); q.eU.HL("BROWSER_CHANNEL")},kzB=function(){this.D=[]; this.K=[]},RO6=function(q){var Z=0; q.SI&&Z++;q.j5&&Z++;return Z},PSt=function(q,Z,F){var B=Wo(q.Z,"/pairing/get_screen_availability"); q.Z.sendRequest("POST",B,{lounge_token:Z.token},(0,g.Jy)(function(f){f=f.screens||[];for(var D=f.length,G=0;G0&&XO(q,F)},function(Z){q.Z=function(){}; q.F$(Z)})},BIm=function(q){q.ZR&&(q.ZR.abort(),q.ZR=null); q.SI&&(q.SI.cancel(),q.SI=null);q.YK&&(g.W5.clearTimeout(q.YK),q.YK=null);Jj(q);q.j5&&(q.j5.cancel(),q.j5=null);q.vz&&(g.W5.clearTimeout(q.vz),q.vz=null)},fTm=function(q,Z){for(var F=q.screens.length,B=0;B0&&(q.HG=new g.IF((0,g.Jy)(q.jk,q,q.D),q.eU));q.Jn.listen(q.D,"readystatechange",q.C1);Z=q.BG?g.Js(q.BG):{};q.PG?(q.Y$||(q.Y$="POST"),Z["Content-Type"]="application/x-www-form-urlencoded",q.D.send(q.o_,q.Y$,q.PG,Z)):(q.Y$="GET",q.D.send(q.o_,q.Y$,null,Z));I1(1)},qUm=function(q){WtE(q,"getLoungeToken"); g.L4(q.Z);q.Z=g.OT(function(){yeB(q,null)},3E4)},gv=function(){return!!g.sY("yt-remote-cast-installed")},Ltj=function(q){g.SL.call(this,"statevent",q)},HBj=function(q,Z){q.D=0; q.uQ&&q.uQ.IA(Z);uim(q);BIm(q)},lGj=function(){var q=VTE(),Z=[]; if(q>1){var F=q-1;Z.push("//www.gstatic.com/eureka/clank/"+q+"/cast_sender.js");Z.push("//www.gstatic.com/eureka/clank/"+F+"/cast_sender.js")}return Z},xe=function(){return g.ym("yt.mdx.remote.connection_")},pl5=function(){var q=JN(); q?(ox("Resume connection to: "+rs(q)),Bq(q,0)):($g(),tvB(),ox("Skipping connecting because no session screen found."))},eM=function(q){this.index=-1; this.videoId=this.listId="";this.volume=this.playerState=-1;this.muted=!1;this.audioTrackId=null;this.Z=this.j=0;this.trackData=null;this.jr=this.MS=!1;this.V=this.S=this.X=this.K=0;this.D=NaN;this.G=!1;this.reset(q)},OBu=function(q){q.player.getPlayerStateObject().isPlaying()?q.player.pauseVideo():(q.yl=function(Z){!q.gz&&g.YM(Z,8)&&(q.player.pauseVideo(),Vx(q))},q.player.addEventListener("presentingplayerstatechange",q.yl)); q.jR&&q.jR.Ic();xe()||(e9=!0)},cq=function(q,Z){Vvm(q); q.G.setPlayerContextData(ud5(Z));sA6(q)},Qk0=function(){gv()?Oe()?ZF()?(fr("Requesting cast selector."),Oe().requestSession()):(fr("Wait for cast API to be ready to request the session."),xnm.push(g.NQ("yt-remote-cast2-api-ready",Qk0))):Q4("requestCastSelector: Cast is not initialized."):Q4("requestCastSelector: Cast API is not installed!")},xqB=function(q){q.D=new y4(q,q.G,"rpc",q.j$); q.X===null&&(q.D.BG=q.PG);q.D.eU=0;var Z=q.bb.clone();g.E2(Z,"RID","rpc");g.E2(Z,"SID",q.G);g.E2(Z,"AID",q.WG);g.E2(Z,"CI",q.HG?"0":"1");!q.HG&&q.X3&&g.E2(Z,"TO",q.X3);g.E2(Z,"TYPE","xmlhttp");Mb(q,Z);q.X&&q.PG&&g.QX(Z,q.X,q.PG);q.eU&&q.D.setTimeout(q.eU);var F=q.D;q=q.Tb;F.WG=1;F.V=bt(Z.clone());F.PG=null;F.k$=!0;TNE(F,q)},KO5=function(q){q.Z=g.sY("yt-remote-device-id-map")||{}},$n0=function(q,Z){if(q.D){var F=q.D.Eq||{}; Z&&Object.keys(Z).length>0?F=Object.assign({},F,Z):delete F.Authorization;q.D.Eq=F}},Eum=function(q,Z){Z=Z.message; Z.params?GV("Received: action="+Z.action+", params="+g.eX(Z.params)):GV("Received: action="+Z.action+" {}");switch(Z.action){case "loungeStatus":Z=zi(Z.params.devices);q.S=g.DC(Z,function(B){return new Ye(B)}); Z=!!g.s3(q.S,function(B){return B.type=="LOUNGE_SCREEN"}); yx_(q,Z);Z=q.BS("mlm");q.publish("multiStateLoopEnabled",Z);break;case "loungeScreenDisconnected":g.ni7(q.S,function(B){return B.type=="LOUNGE_SCREEN"}); yx_(q,!1);break;case "remoteConnected":var F=new Ye(zi(Z.params.device));g.s3(q.S,function(B){return B.equals(F)})||Dim(q.S,F); break;case "remoteDisconnected":F=new Ye(zi(Z.params.device));g.ni7(q.S,function(B){return B.equals(F)}); break;case "gracefulDisconnect":break;case "playlistModified":guE(q,Z,"QUEUE_MODIFIED");break;case "nowPlaying":lTm(q,Z);break;case "onStateChange":SUE(q,Z);break;case "onAdStateChange":Aem(q,Z);break;case "onVolumeChanged":qc8(q,Z);break;case "onSubtitlesTrackChanged":SW_(q,Z);break;case "nowAutoplaying":Pn6(q,Z);break;case "autoplayDismissed":q.publish("autoplayDismissed");break;case "autoplayUpNext":vuu(q,Z);break;case "onAutoplayModeChanged":Xhe(q,Z);break;case "onHasPreviousNextChanged":Pi6(q, Z);break;case "requestAssistedSignIn":q.publish("assistedSignInRequested",Z.params.authCode);break;case "onLoopModeChanged":q.publish("loopModeChange",Z.params.loopMode);break;default:GV("Unrecognized action: "+Z.action)}},Ktm=function(q){g.SL.call(this,"channelError"); this.error=q},$q8=function(q){var Z=Math.min(q.K.length,1E3),F=["count="+Z]; if(q.xr>6&&Z>0){var B=q.K[0].D;F.push("ofs="+B)}else B=0;for(var f={},D=0;D=0&&(q=q.match(/MSIE ([\d.]+)/)[1],g.ql(q,"10.0")<0&&(this.K=!1))},Jj=function(q){q.VU!=null&&(g.W5.clearTimeout(q.VU),q.VU=null)},aTt=function(q,Z){if(Z)if(q.xr>6){q.K=q.S.concat(q.K); q.S.length=0;var F=q.Tf-1;Z=$q8(q)}else F=Z.X,Z=Z.bF;else F=q.Tf++,Z=$q8(q);var B=q.j6.clone();g.E2(B,"SID",q.G);g.E2(B,"RID",F);g.E2(B,"AID",q.z4);zV(q,B);F=new uB(q,q.G,F,q.G4+1);F.gI=q.Eq;F.setTimeout(1E4+Math.round(1E4*Math.random()));q.j5=F;Z1m(F,B,Z)},mqt=function(q,Z){if(q.Dl!=null)throw Error("WatchDog timer not null"); q.Dl=mK((0,g.Jy)(q.q5,q),Z)},wlu=function(q){g.L4(q.j); q.j=NaN},iBe=function(){var q=igm; LG6();a1.push(q);yVm()},Xum=function(q){q.D||q.V||(q.j$=1,g.iJ(q.Xs,q),q.uL=0)},kQj=function(q,Z,F){g.J.call(this); var B=this;this.D=q;this.B=Z;this.sy=F;this.events=new g.pO(this);this.Z=!1;this.j=new g.h1(64);this.K=new g.im(this.Mn,500,this);this.S=new g.im(this.PQ,1E3,this);this.V=new Kr(this.obL,0,this);this.G={};this.PG=new g.im(this.Pc,1E3,this);this.X=new g.IF(this.seekTo,1E3,this);this.Dl=this.events.N(this.B,"onVolumeChange",function(f){Ny6(B,f)}); g.y(this,this.events);this.events.N(Z,"onCaptionsTrackListChanged",this.ipU);this.events.N(Z,"captionschanged",this.wgF);this.events.N(Z,"captionssettingschanged",this.A2);this.events.N(Z,"videoplayerreset",this.OV);this.events.N(Z,"mdxautoplaycancel",function(){B.sy.Xi()}); Z.U("enable_mdx_video_play_directly")&&this.events.N(Z,"videodatachange",function(){znm(B.D)||yx(B)||TV(B,0)}); q=this.sy;q.jU();q.subscribe("proxyStateChange",this.QY,this);q.subscribe("remotePlayerChange",this.AQ,this);q.subscribe("remoteQueueChange",this.OV,this);q.subscribe("previousNextChange",this.GC,this);q.subscribe("nowAutoplaying",this.PF,this);q.subscribe("autoplayDismissed",this.xP,this);g.y(this,this.K);g.y(this,this.S);g.y(this,this.V);g.y(this,this.PG);g.y(this,this.X);this.A2();this.OV();this.AQ()},MK=function(q){isNaN(q.S)||g.L4(q.S); q.S=g.OT((0,g.Jy)(q.Df,q),q.G>0&&q.G0||!(B==1&&taE(q,Z)||B==2&&Hg5(q)))switch(F&&F.length>0&&(Z=q.K,Z.S=Z.S.concat(F)),f){case 1:ke(q,5);break;case 4:ke(q,10);break;case 3:ke(q,6);break;default:ke(q,2)}}},phm=function(q,Z){if(yx(q)&&!q.Z){var F=null; Z&&(F={style:q.B.getSubtitlesUserSettings()},Object.assign(F,Z));q.sy.MK(q.B.getVideoData(1).videoId,F);q.G=Ti(q.sy).trackData}},Ogt=function(q){return q.K?1:q.D?q.D.size:0},$X6=function(){var q=Ll(),Z=Kl(); g.wQ()&&g.fm(q,Z);q=ld0(q);if(q.length==0)try{g.L_("remote_sid")}catch(F){}else try{g.aA("remote_sid",q.join(","),-1)}catch(F){}},dqm=function(q){var Z=q.zP(); Z?q.G["x-youtube-lounge-xsrf-token"]=Z:delete q.G["x-youtube-lounge-xsrf-token"]},ds=function(){if(!Vam){var q=g.ym("yt.mdx.remote.screenService_"); Vam=q?new enB(q):null}return Vam},Cr=function(q,Z){return Object.prototype.hasOwnProperty.call(q,Z)},Fl=function(q,Z,F){Z!=q.D&&(g.dN(q.D),(q.D=Z)?(F?q.publish("yt-remote-cast2-receiver-resumed",Z.K):q.publish("yt-remote-cast2-receiver-selected",Z.K),Z.subscribe("sessionScreen",(0,g.Jy)(q.ZX,q,Z)),Z.subscribe("sessionFailed",function(){return wum(q,Z)}),Z.D?q.publish("yt-remote-cast2-session-change",Z.D):F&&q.D.LJ(null)):q.publish("yt-remote-cast2-session-change",null))},wKm=function(q,Z){return Z? g.s3(q.S,function(F){return Fv(Z,F.label)},q):null},Tdm=function(q){var Z={}; Z.pairingCode=q.Y$;Z.theme=q.WG;IHB()&&(Z.env_useStageMdx=1);return g.Ru(Z)},se=function(q){q.vG=Date.now()+q.I_; mqt(q,q.I_)},DF=function(q,Z,F){g.In.call(this); this.k$=F;this.G=q;this.K=Z;this.D=null},TI_=function(q,Z){var F=!1; Oe()||(q=new OG(q,Z),q.subscribe("yt-remote-cast2-availability-change",function(B){g.e0("yt-remote-cast-available",B);Ho("yt-remote-cast2-availability-change",B)}),q.subscribe("yt-remote-cast2-receiver-selected",function(B){fr("onReceiverSelected: "+B.friendlyName); g.e0("yt-remote-cast-receiver",B);Ho("yt-remote-cast2-receiver-selected",B)}),q.subscribe("yt-remote-cast2-receiver-resumed",function(B){fr("onReceiverResumed: "+B.friendlyName); g.e0("yt-remote-cast-receiver",B);Ho("yt-remote-cast2-receiver-resumed",B)}),q.subscribe("yt-remote-cast2-session-change",function(B){fr("onSessionChange: "+rs(B)); B||g.qF("yt-remote-cast-receiver");Ho("yt-remote-cast2-session-change",B)}),g.O9("yt.mdx.remote.cloudview.instance_",q),F=!0); fr("cloudview.createSingleton_: "+F);return F},BQ=function(q,Z){if(Z.key!==q.Bp.key)if(Z.key===q.Y9.key)AN(); else if(znm(q)&&OBu(q),q.Bp=Z,!g.SQ(q.player.C())){var F=q.player.getPlaylistId();var B=q.player.getVideoData(1);var f=B.videoId;if(!F&&!f||(q.player.getAppState()===2||q.player.getAppState()===1)&&q.player.C().U("should_clear_video_data_on_player_cued_unstarted"))B=null;else{var D=q.player.getPlaylist();if(D){var G=[];for(var n=0;n0?(D=f[0].D,G.push("ofs="+D)):D=0:G.push("ofs="+D);for(var n=!0,b=0;b=q.K.G-(q.j?1:0))return!1; if(q.j)return q.S=Z.uL.concat(q.S),!0;if(q.iQ==1||q.iQ==2||q.zP>=(q.lx?0:q.yd))return!1;q.j=mK((0,g.Jy)(q.Ny,q,Z),Ft_(q,q.zP));q.zP++;return!0},fCj=function(q,Z){var F=new S9; if(g.W5.Image){var B=new Image;B.onload=g.sy(b4,F,"TestLoadImage: loaded",!0,Z,B);B.onerror=g.sy(b4,F,"TestLoadImage: error",!1,Z,B);B.onabort=g.sy(b4,F,"TestLoadImage: abort",!1,Z,B);B.ontimeout=g.sy(b4,F,"TestLoadImage: timeout",!1,Z,B);g.W5.setTimeout(function(){if(B.ontimeout)B.ontimeout()},1E4); B.src=q}else Z(!1)},zL5=function(q,Z){var F=q.X,B=Z.indexOf("\n",F); if(B==-1)return D_j;F=Number(Z.substring(F,B));if(isNaN(F))return G1e;B+=1;if(B+F>Z.length)return D_j;Z=Z.slice(B,B+F);q.X=B+F;return Z},b4=function(q,Z,F,B,f){try{f&&(f.onload=null,f.onerror=null,f.onabort=null,f.ontimeout=null),B(F)}catch(D){}},gf=function(q){fl.call(this,"LocalScreenService"); this.K=q;this.D=NaN;NV(this);this.info("Initializing with "+omu(this.screens))},QLB=function(q,Z){q.D?q.D.add(Z):q.K=Z},SW=function(q){return q.X||!!q.S.length||!!q.D},qhe=function(){var q=Po(); this.D=q;q.i6("/client_streamz/youtube/living_room/mdx/channel/message_received",g.pW("channel_type"))},TV=function(q,Z){var F=q.B.getPlaylist(); if(F==null?0:F.listId){var B=F.index;var f=F.listId.toString()}F=q.B.getVideoData(1);q.sy.playVideo(F.videoId,Z,B,f,F.playerParams,F.uL,kMu(F));q.ib(new g.h1(1))},yeB=function(q,Z){g.L4(q.Z); q.Z=0;var F=null;if(Z)if(Z.loungeToken){var B;((B=q.D)==null?void 0:B.token)==Z.loungeToken&&(F="staleLoungeToken")}else F="missingLoungeToken";else F="noLoungeTokenResponse";F?(q.info("Did not receive a new lounge token in onLoungeToken_ with data: "+(JSON.stringify(Z)+", error: "+F)),q.PG=F,ZBm(q,3E4)):(nEj(q,Z.loungeToken),q.zP=!1,q.PG="unknown",ZBm(q,Z.loungeTokenRefreshIntervalMs))},Hg5=function(q){if(q.D||q.V||q.uL>=3)return!1; q.j$++;q.V=mK((0,g.Jy)(q.Xs,q),Ft_(q,q.uL));q.uL++;return!0},wv=function(){return g.ym("yt.mdx.remote.currentScreenId_")},$e=function(q){q.length?bBm(q.shift(),function(){$e(q)}):NIm()},Aem=function(q,Z){if(q.D.playerState!=-1E3){var F=1085; switch(parseInt(Z.params.adState,10)){case 1:F=1081;break;case 2:F=1084;break;case 0:F=1083}q.D.playerState=F;Z=parseInt(Z.params.currentTime,10);vo(q.D,isNaN(Z)?0:Z);q.publish("remotePlayerChange")}},vuu=function(q,Z){q.X=Z.params.videoId||null; q.publish("autoplayUpNext",q.X)},eOE=function(q,Z){fGe(q,Z).forEach(function(F){g.Fs.prototype.remove.call(this,F)},q)},nZ_=function(){this.D=new ut},NV=function(q){if(g.cz("deprecate_pair_servlet_enabled"))return KGm(q,[]); var Z=bh6(QBE());Z=g.uh(Z,function(F){return!F.uuid}); return KGm(q,Z)},ITm=function(q,Z){Z?(q.info("onConnectedScreenId_: Received screenId: "+Z),q.D&&q.D.id==Z||q.XO(Z,function(F){vq(q,F)},function(){return q.F$()},5)):q.F$(Error("Waiting for session status timed out."))},Nh6=function(){Scm(); var q=lGj();q.push("//www.gstatic.com/eureka/clank/cast_sender.js");$e(q)},NIm=function(){var q=aH8(); q&&q(!1,"No cast extension found")},Sh8=function(q){if(!gEj(q))return g.q6(q.D); var Z=g.DX(q.D);if(Z==="")return"";var F="",B=Z.length,f=g.rJ(q.D)==4;if(!q.K.S){if(typeof TextDecoder==="undefined")return l4(q),tj(q),"";q.K.S=new g.W5.TextDecoder}for(var D=0;D=0; return g.l2||q},rdE=function(q){g.SL.call(this,"serverreachability",q)},Bdm=function(q){KO5(q); q.K=new gf(q.G);q.K.subscribe("screenChange",(0,g.Jy)(q.jf,q));wI6(q);q.X||(q.S=bh6(g.sY("yt-remote-automatic-screen-cache")||[]));KO5(q);q.info("Initializing automatic screens: "+omu(q.S));q.D=new H1E(q.G,(0,g.Jy)(q.Uq,q,!0));q.D.subscribe("screenChange",(0,g.Jy)(function(){this.publish("onlineScreenChange")},q))},Wr_=function(q){g.od(q.channel,"m",function(){q.j=3; q.S.reset();q.V=null;q.X=0;for(var Z=g.E(q.uL),F=Z.next();!F.done;F=Z.next())F=F.value,q.channel&&q.channel.send(F);q.uL=[];q.publish("webChannelOpened");q.BG.HL("WEB_CHANNEL")}); g.od(q.channel,"n",function(){q.j=0;q.S.isActive()||q.publish("webChannelClosed");var Z,F=(Z=q.channel)==null?void 0:OGm(new O1B(Z,Z.D));F&&(q.uL=[].concat(g.YB(F)));q.Y$.HL("WEB_CHANNEL")}); g.od(q.channel,"p",function(Z){var F=Z.data;F[0]==="gracefulReconnect"?(q.S.start(),q.channel&&q.channel.close()):q.publish("webChannelMessage",new ree(F[0],F[1]));q.lw=Z.statusCode;q.dU.HL("WEB_CHANNEL")}); g.od(q.channel,"o",function(){q.lw===401||q.S.start();q.publish("webChannelError");q.k$.HL("WEB_CHANNEL","")})},ke=function(q,Z){if(Z==2){var F=(0,g.Jy)(q.Q1c,q),B=q.hC,f=!B; B=new g.pq(B||"//www.google.com/images/cleardot.gif");g.W5.location&&g.W5.location.protocol=="http"||g.dA(B,"https");bt(B);f?fCj(B.toString(),F):yd0(B.toString(),F)}else ws(2);q.iQ=0;q.Z&&q.Z.Ot(Z);U_m(q);bg5(q)},Lr6=function(q){var Z,F; g.h(function(B){if(B.D==1)return g.KI(B,2),g.R(B,Uij(q),2);g.nm(B);Z=q.S;q.S=[];F=Z.length;vd0(q,Z,F);NK(q);return g.mD(B,0)})},hKE=function(q){kg(q)&&q.S.getDialAppInfo(function(Z){q.info("getDialAppInfo dialLaunchData: "+JSON.stringify(Z)); Z=Z.extraData||{};var F=null;if(Z.loungeToken){var B;((B=q.D)==null?void 0:B.token)==Z.loungeToken&&(F="staleLoungeToken")}else F="missingLoungeToken";F?(q.zP=F,XO(q,3E4)):(q.uL=!1,q.zP="unknown",nEj(q,Z.loungeToken),XO(q,Z.loungeTokenRefreshIntervalMs))},function(Z){q.info("getDialAppInfo error: "+Z); q.zP="noLoungeTokenResponse";XO(q,3E4)})},Hhj=function(q,Z){var F=q.V.receiver.label,B=q.K.friendlyName; return(new Promise(function(f){wcE(q.G,F,Z,B,function(D){D&&D.token&&vq(q,D);f(D)},function(D){xg(q,"Failed to get DIAL screen: "+D); f(null)})})).then(function(f){return f&&f.token?new chrome.cast.DialLaunchResponse(!1):oZ_(q)})},OhE=function(q,Z){this.D=q; this.map=Z;this.context=null},Ua=function(q){zs6(q); g.dN(q.RY);q.RY=null;q.Z.stop();q.S.removeAll();if(q.WE){var Z=q.WE;q.WE=null;Z.abort();Z.dispose()}q.lj&&(q.lj=null)},Qt0=function(q){q.audioTrackId=null; q.trackData=null;q.playerState=-1;q.MS=!1;q.jr=!1;q.j=0;q.Z=g.i$();q.K=0;q.X=0;q.S=0;q.V=0;q.D=NaN;q.G=!1},D9=function(q,Z){g.J.call(this); this.D=new g.im(this.JPF,0,this);g.y(this,this.D);this.Ke=5E3;this.K=0;if(typeof q==="function")Z&&(q=(0,g.Jy)(q,Z));else if(q&&typeof q.handleEvent==="function")q=(0,g.Jy)(q.handleEvent,q);else throw Error("Invalid listener argument");this.S=q},UG=function(q,Z,F){q.Bt=q.j==null?F:!q.j; q.BK=Z.Am;q.V||gZE(q)},x_E=function(q,Z){g.UY.call(this,q); this.D=Z},u4=function(q){switch(q.playerState){case 1:case 1081:return(g.i$()-q.Z)/1E3+q.j; case -1E3:return 0}return q.j},Ad8=function(q,Z,F,B){g.L4(q.j); q.j=0;fd0(q.G,Z,function(f){f||B<0?F(f):q.j=g.OT(function(){Ad8(q,Z,F,B-1)},300)})},vE_=function(q,Z){Oe().init(q,Z)},jAe=function(){return gv()?Oe()?Oe().getCastSession():(Q4("getCastSelector: Cast is not initialized."),null):(Q4("getCastSelector: Cast API is not installed!"),null)},enB=function(q){fl.call(this,"ScreenServiceProxy"); this.R1=q;this.D=[];this.D.push(this.R1.$_s("screenChange",(0,g.Jy)(this.AL,this)));this.D.push(this.R1.$_s("onlineScreenChange",(0,g.Jy)(this.Zpa,this)))},Mb=function(q,Z){q.dU&&g.Hh(q.dU,function(F,B){g.E2(Z,B,F)}); q.Z&&g.Hh({},function(F,B){g.E2(Z,B,F)})},PQ=function(q,Z,F){return(0,g.Jy)(function(B){this.Zz("Failed to "+Z+" with cast v2 channel. Error code: "+B.code); B.code!=chrome.cast.ErrorCode.TIMEOUT&&(this.Zz("Retrying "+Z+" using MDx browser channel."),Aj(this,Z,F))},q)},yd0=function(q,Z){var F=new S9,B=new AbortController,f=setTimeout(function(){B.abort(); b4(F,"TestPingServer: timeout",!1,Z)},1E4); fetch(q,{signal:B.signal}).then(function(D){clearTimeout(f);D.ok?b4(F,"TestPingServer: ok",!0,Z):b4(F,"TestPingServer: server error",!1,Z)}).catch(function(){clearTimeout(f); b4(F,"TestPingServer: error",!1,Z)})},WtE=function(q,Z){q.info("sendYoutubeMessage_: "+Z+" "+g.eX()); var F={};F.type=Z;q.S?q.S.sendMessage("urn:x-cast:com.google.youtube.mdx",F,function(){},(0,g.Jy)(function(){xg(this,"Failed to send message: "+Z+".")},q)):xg(q,"Sending yt message without session: "+g.eX(F))},Cn5=function(q,Z,F){q.info("onConnectedScreenData_: Received screenData: "+JSON.stringify(Z)); var B=new bB(Z);Ad8(q,B,function(f){f?(q.zP=!0,nl(q.G,B),vq(q,B),q.PG="unknown",ZBm(q,F)):(g.vf(Error("CastSession, RemoteScreen from screenData: "+JSON.stringify(Z)+" is not online.")),q.F$())},5)},Qx=function(q,Z){q.publish("proxyStateChange",Z)},DqE=function(q){if(q.K!=null)return q.S.concat(q.K.uL); if(q.D!=null&&q.D.size!==0){var Z=q.S;q=g.E(q.D.values());for(var F=q.next();!F.done;F=q.next())Z=Z.concat(F.value.uL);return Z}return g.D4(q.S)},hj=function(q){g.O9("yt.mdx.remote.connectData_",q)},XI5=function(q,Z){if(q.D==1){if(!Z){q.Tf=Math.floor(Math.random()*1E5); Z=q.Tf++;var F=new uB(q,"",Z);F.gI=q.Eq;var B=$q8(q),f=q.j6.clone();g.E2(f,"RID",Z);g.E2(f,"CVER","1");zV(q,f);Z1m(F,f,B);q.j5=F;q.D=2}}else q.D==3&&(Z?aTt(q,Z):q.K.length==0||q.j5||aTt(q))},fL=function(q,Z,F){var B=q.videoId; q.videoId=Z;q.index=F;Z!=B&&Qt0(q)},Gq=function(q,Z,F,B){B=B===void 0?!1:B; g.In.call(this);var f=this;this.j=NaN;this.Y$=!1;this.PG=this.V=this.uL=this.zP=NaN;this.Dl=[];this.Z=this.X=this.G=this.D=this.K=null;this.BG=q;this.dU=B;this.Dl.push(g.h4(window,"beforeunload",function(){f.x7(2)})); this.S=[];this.D=new eM;this.WG=Z.id;this.k$=Z.idType;this.K=ByB(this.BG,F,this.P$,this.k$=="shortLived",this.WG);this.K.listen("channelOpened",function(){EE5(f)}); this.K.listen("channelClosed",function(){GV("Channel closed");isNaN(f.j)?$g(!0):$g();f.dispose()}); this.K.listen("channelError",function(D){$g();isNaN(f.e8())?(D==1&&f.k$=="shortLived"&&f.publish("browserChannelAuthError",D),GV("Channel error: "+D+" without reconnection"),f.dispose()):(f.Y$=!0,GV("Channel error: "+D+" with reconnection in "+f.e8()+" ms"),Qx(f,2))}); this.K.listen("channelMessage",function(D){Eum(f,D)}); this.K.OY(Z.token);this.subscribe("remoteQueueChange",function(){var D=f.D.videoId;g.wQ()&&g.e0("yt-remote-session-video-id",D)})},hOm=function(q){q.dU&&!q.Z&&$n0(q,q.dU())},bB=function(q){q=q||{}; this.name=q.name||"";this.id=q.id||q.screenId||"";this.token=q.token||q.loungeToken||"";this.uuid=q.uuid||q.dialId||"";this.idType=q.screenIdType||"normal";this.secret=q.screenIdSecret||""},$m6=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(q){var Z=Math.random()*16|0; return(q=="x"?Z:Z&3|8).toString(16)})},Kr0=function(q,Z){a:if(GRE(Z)!=GRE(q.D))var F=!1; else{F=g.He(Z);for(var B=F.length,f=0;f=0&&window.navigator.userAgent.indexOf("Chrome/")>=0&&window.navigator.presentation?VTE()>=60&&Nh6():!window.chrome||!window.navigator.presentation||window.navigator.userAgent.indexOf("Edge")>=0?NIm():VTE()>=89?PrB():(Scm(),$e(Umm.map(uu0))))):fr("Cannot initialize because not running Chrome")},rxt=function(q){return g.s3(q.S,function(Z){return Z.type=="LOUNGE_SCREEN"})},aCm=function(q,Z){PQE(!0); f$E(!1);vE_(q,function(F){F?(Qse(!0),g.k3("yt-remote-cast2-api-ready")):(Q4("Failed to initialize cast API."),PQE(!1),g.qF("yt-remote-cast-available"),g.qF("yt-remote-cast-receiver"),AE5());Z(F)})},DmE=function(q){var Z=xe(); hj(null);q||vZu("");g.O9("yt.mdx.remote.connection_",q);Ix&&(g.yn(Ix,function(F){F(q)}),Ix.length=0); Z&&!q?Ho("yt-remote-connection-change",!1):!Z&&q&&Ho("yt-remote-connection-change",!0)},bh6=function(q){return Array.isArray(q)?g.DC(q,hn8):[]},Vx=function(q){q.yl&&(q.player.removeEventListener("presentingplayerstatechange",q.yl),q.yl=null)},Qse=function(q){fr("setApiReady_ "+q); g.O9("yt.mdx.remote.cloudview.apiReady_",q)},Wq=function(q,Z,F){return F&&F.Ju?F.Ju[q]||Z:Z},WGB=function(q){g.L4(q.PG); q.PG=g.OT(function(){q.x7(1)},864E5)},zq=function(q){this.D=q},ssE=function(q,Z,F,B){var f=new g.pq(null); q&&g.dA(f,q);Z&&g.f6(f,Z);F&&g.O0(f,F);B&&(f.K=B);return f}; g.nM.prototype.vv=g.nS(49,function(){this.app.I1().vv()}); g.Sl.prototype.vv=g.nS(48,function(){this.X9=null}); g.nM.prototype.UG=g.nS(47,function(q){this.app.I1().UG(q)}); g.Sl.prototype.UG=g.nS(46,function(q){this.X9=q}); rVj.prototype.HL=function(q){this.D.Jj("/client_streamz/youtube/living_room/mdx/channel/opened",q)}; oEB.prototype.HL=function(q){this.D.Jj("/client_streamz/youtube/living_room/mdx/channel/closed",q)}; qhe.prototype.HL=function(q){this.D.Jj("/client_streamz/youtube/living_room/mdx/channel/message_received",q)}; Zgu.prototype.HL=function(){this.D.Jj("/client_streamz/youtube/living_room/mdx/channel/success")}; zOj.prototype.HL=function(q,Z){this.D.Jj("/client_streamz/youtube/living_room/mdx/channel/error",q,Z)}; HIe.prototype.HL=function(){this.D.Jj("/client_streamz/youtube/living_room/mdx/browser_channel/pending_maps")}; Zhm.prototype.HL=function(){this.D.Jj("/client_streamz/youtube/living_room/mdx/browser_channel/undelivered_maps")}; g.r=qb.prototype;g.r.pQ=function(){hN(this);for(var q=[],Z=0;Z2*this.size&&hN(this),!0):!1}; g.r.get=function(q,Z){return Cr(this.K,q)?this.K[q]:Z}; g.r.set=function(q,Z){Cr(this.K,q)||(this.size+=1,this.D.push(q),this.W2++);this.K[q]=Z}; g.r.forEach=function(q,Z){for(var F=this.Cx(),B=0;B=B.D.length)return g.nQ;var D=B.D[Z++];return g.a9(q?D:B.K[D])}; return f}; var cxu={Kh$:"atp",Sfs:"ska",tir:"que",Rxs:"mus",uDL:"sus",CIG:"dsp",a9U:"seq",zxr:"mic",uXP:"dpa",kQc:"mlm",DBp:"dsdtr",t7r:"ntb",Txa:"vsp",RtE:"scn",X3r:"rpe",vxL:"dcn",JqG:"dcp",a2$:"pas",PI_:"drq",l2s:"opf",pXU:"els",kYs:"isg",FpE:"svq",pus:"mvp",GAr:"ads",Yfn:"stcp",sbU:"sads",M5p:"dloc",SXc:"dcw",n6E:"asw",zfn:"apw",cWs:"wrc",u8P:"pcw",yjs:"ipv",f2s:"ndt",hAp:"ctops"},RnB={C_l:"u",tgE:"cl",xdE:"k",nul:"i",IiP:"cr",ZQa:"m",yVa:"g",wL:"up"},Yc6={rC:"adPlaying",cn:"onAdStateChange"},tTj={Xus:"nowPlaying", gEc:"onStateChange",rC:"adPlaying",cn:"onAdStateChange",zS:"nowPlayingShorts",Qy:"onShortsStateChange"},pum={zS:"nowPlayingShorts",Qy:"onShortsStateChange"};Ye.prototype.equals=function(q){return q?this.id==q.id:!1}; var $_u="",Hq=null;g.V(ndu,g.$Y9);var pl,nu6=OIm("loadCastFramework")||OIm("loadCastApplicationFramework"),Umm=["pkedcjkdefgpdelpbcmbmeomcjbeemfm","enhhojjnijigcajfphajepfemndkmdlo"];g.JC(Kr,g.J);g.r=Kr.prototype;g.r.I$=function(q){this.G=arguments;this.D=!1;this.Cp?this.S=g.i$()+this.Ke:this.Cp=g.YX(this.Z,this.Ke)}; g.r.stop=function(){this.Cp&&(g.W5.clearTimeout(this.Cp),this.Cp=null);this.S=null;this.D=!1;this.G=[]}; g.r.pause=function(){++this.K}; g.r.resume=function(){this.K&&(--this.K,!this.K&&this.D&&(this.D=!1,this.j.apply(null,this.G)))}; g.r.SU=function(){this.stop();Kr.Km.SU.call(this)}; g.r.eV=function(){this.Cp&&(g.W5.clearTimeout(this.Cp),this.Cp=null);this.S?(this.Cp=g.YX(this.Z,this.S-g.i$()),this.S=null):this.K?this.D=!0:(this.D=!1,this.j.apply(null,this.G))};ut.prototype.stringify=function(q){return g.W5.JSON.stringify(q,void 0)}; ut.prototype.parse=function(q){return g.W5.JSON.parse(q,void 0)};g.JC(JE0,g.SL);g.JC(mn_,g.SL);var IGj=null;g.JC(UX5,g.SL);g.JC(di8,g.SL);g.JC(eKu,g.SL);S9.prototype.debug=function(){}; S9.prototype.info=function(){}; S9.prototype.warning=function(){};var G1e={},D_j={};g.r=y4.prototype;g.r.setTimeout=function(q){this.I_=q}; g.r.C1=function(q){q=q.target;var Z=this.HG;Z&&g.rJ(q)==3?Z.Nk():this.jk(q)}; g.r.jk=function(q){try{if(q==this.D)a:{var Z=g.rJ(this.D),F=this.D.K,B=this.D.getStatus();if(!(Z<3)&&(Z!=3||this.D&&(this.K.K||g.q6(this.D)||g.DX(this.D)))){this.dU||Z!=4||F==7||(F==8||B<=0?I1(3):I1(2));vmB(this);var f=this.D.getStatus();this.KB=f;var D=Sh8(this);if(this.j=f==200){if(this.Gb&&!this.Oc){b:{if(this.D){var G=g.zr(this.D,"X-HTTP-Initial-Response");if(G&&!g.lO(G)){var n=G;break b}}n=null}if(q=n)this.Oc=!0,Emm(this,q);else{this.j=!1;this.Z=3;ws(12);l4(this);tj(this);break a}}if(this.k$){q= !0;for(var b;!this.dU&&this.X0&&!this.w2&&(this.w2=!0,this.S.qU(this)):(l4(this),tj(this))}else Emm(this,D);Z==4&&l4(this);this.j&&!this.dU&&(Z==4?UqB(this.S,this):(this.j=!1,se(this)))}else g.udD(this.D),f==400&&D.indexOf("Unknown SID")> 0?(this.Z=3,ws(12)):(this.Z=0,ws(13)),l4(this),tj(this)}}}catch(N){}finally{}}; g.r.cancel=function(){this.dU=!0;l4(this)}; g.r.q5=function(){this.Dl=null;var q=Date.now();q-this.vG>=0?(this.WG!=2&&(I1(3),ws(17)),l4(this),this.Z=2,tj(this)):mqt(this,this.vG-q)}; g.r.getLastError=function(){return this.Z}; g.r.Gi=function(){return this.D};Rsm.prototype.cancel=function(){this.S=DqE(this);if(this.K)this.K.cancel(),this.K=null;else if(this.D&&this.D.size!==0){for(var q=g.E(this.D.values()),Z=q.next();!Z.done;Z=q.next())Z.value.cancel();this.D.clear()}};g.r=bGE.prototype;g.r.WU=8;g.r.iQ=1;g.r.connect=function(q,Z,F,B){ws(0);this.VO=q;this.dU=Z||{};F&&B!==void 0&&(this.dU.OSID=F,this.dU.OAID=B);this.HG=this.Hg;this.BG=xmt(this,null,this.VO);jM(this)}; g.r.disconnect=function(){bg5(this);if(this.iQ==3){var q=this.o_++,Z=this.BG.clone();g.E2(Z,"SID",this.G);g.E2(Z,"RID",q);g.E2(Z,"TYPE","terminate");Mb(this,Z);q=new y4(this,this.G,q);q.WG=2;q.V=bt(Z.clone());Z=!1;if(g.W5.navigator&&g.W5.navigator.sendBeacon)try{Z=g.W5.navigator.sendBeacon(q.V.toString(),"")}catch(F){}!Z&&g.W5.Image&&((new Image).src=q.V,Z=!0);Z||(q.D=GQ0(q.S,null),q.D.send(q.V));q.zP=Date.now();se(q)}U_m(this)}; g.r.TD=function(){return this.iQ==0}; g.r.getState=function(){return this.iQ}; g.r.Ny=function(q){if(this.j)if(this.j=null,this.iQ==1){if(!q){this.o_=Math.floor(Math.random()*1E5);q=this.o_++;var Z=new y4(this,"",q),F=this.PG;this.Gb&&(F?(F=g.Js(F),g.gN(F,this.Gb)):F=this.Gb);this.X!==null||this.vG||(Z.BG=F,F=null);var B;if(this.Jn)a:{for(var f=B=0;f4096){B=f;break a}if(B===4096||f===this.S.length-1){B=f+1;break a}}B= 1E3}else B=1E3;B=MTm(this,Z,B);f=this.BG.clone();g.E2(f,"RID",q);g.E2(f,"CVER",22);this.k$&&g.E2(f,"X-HTTP-Session-Id",this.k$);Mb(this,f);F&&(this.vG?B="headers="+g.y5(g.Utk(F))+"&"+B:this.X&&g.QX(f,this.X,F));QLB(this.K,Z);this.oa&&g.E2(f,"TYPE","init");this.Jn?(g.E2(f,"$req",B),g.E2(f,"SID","null"),Z.Gb=!0,Mqu(Z,f,null)):Mqu(Z,f,B);this.iQ=2}}else this.iQ==3&&(q?od5(this,q):this.S.length==0||Ci0(this.K)||od5(this))}; g.r.Xs=function(){this.V=null;xqB(this);if(this.LB&&!(this.I_||this.D==null||this.G0<=0)){var q=4*this.G0;this.Y$=mK((0,g.Jy)(this.B2s,this),q)}}; g.r.B2s=function(){this.Y$&&(this.Y$=null,this.HG=!1,this.I_=!0,ws(10),Xv(this),xqB(this))}; g.r.qU=function(q){this.D==q&&this.LB&&!this.I_&&(nm_(this),this.I_=!0,ws(11))}; g.r.Fd=function(){this.Dl!=null&&(this.Dl=null,Xv(this),Hg5(this),ws(19))}; g.r.Q1c=function(q){q?ws(2):ws(1)}; g.r.isActive=function(){return!!this.Z&&this.Z.isActive(this)}; g.r=QA8.prototype;g.r.oA=function(){}; g.r.yb=function(){}; g.r.Ot=function(){}; g.r.fl=function(){}; g.r.isActive=function(){return!0}; g.r.T2=function(){};g.JC(nL,g.xl);nL.prototype.open=function(){this.D.Z=this.S;this.j&&(this.D.Oc=!0);this.D.connect(this.Z,this.K||void 0)}; nL.prototype.close=function(){this.D.disconnect()}; nL.prototype.send=function(q){var Z=this.D;if(typeof q==="string"){var F={};F.__data__=q;q=F}else this.G&&(F={},F.__data__=g.eX(q),q=F);Z.S.push(new OhE(Z.Lm++,q));Z.iQ==3&&jM(Z)}; nL.prototype.SU=function(){this.D.Z=null;delete this.S;this.D.disconnect();delete this.D;nL.Km.SU.call(this)}; g.JC(Xlj,JE0);g.JC(YUm,mn_);g.JC(zq,QA8);zq.prototype.oA=function(){this.D.dispatchEvent("m")}; zq.prototype.yb=function(q){this.D.dispatchEvent(new Xlj(q))}; zq.prototype.Ot=function(q){this.D.dispatchEvent(new YUm(q))}; zq.prototype.fl=function(){this.D.dispatchEvent("n")}; O1B.prototype.commit=function(q){this.D.KB=q};var qV=new g.xl;g.V(Ltj,g.SL);g.r=uB.prototype;g.r.gI=null;g.r.sY=!1;g.r.KF=null;g.r.vt=null;g.r.q$=null;g.r.B_=null;g.r.aq=null;g.r.Z4=null;g.r.bF=null;g.r.WE=null;g.r.UF=0;g.r.lj=null;g.r.wu=null;g.r.oZ=null;g.r.ej=-1;g.r.tb=!0;g.r.Iq=!1;g.r.Ev=0;g.r.RY=null;var tAE={},YWE={};g.r=uB.prototype;g.r.setTimeout=function(q){this.K=q}; g.r.vj=function(q){q=q.target;var Z=this.RY;Z&&g.rJ(q)==3?Z.Nk():this.hw(q)}; g.r.hw=function(q){try{if(q==this.WE)a:{var Z=g.rJ(this.WE),F=this.WE.K,B=this.WE.getStatus();if(g.YN&&!g.Jw("420+")){if(Z<4)break a}else if(Z<3||Z==3&&!g.q6(this.WE))break a;this.Iq||Z!=4||F==7||(F==8||B<=0?this.D.u5(3):this.D.u5(2));zs6(this);var f=this.WE.getStatus();this.ej=f;var D=g.q6(this.WE);if(this.sY=f==200){Z==4&&Ua(this);if(this.k$){for(q=!0;!this.Iq&&this.UF0?(this.oZ=3,lB(13)):(this.oZ=0,lB(14)),Ua(this),ad6(this)}}catch(n){}finally{}}; g.r.cancel=function(){this.Iq=!0;Ua(this)}; g.r.En=function(){this.KF=null;var q=Date.now();q-this.vt>=0?(this.B_!=2&&this.D.u5(3),Ua(this),this.oZ=2,lB(18),ad6(this)):iGm(this,this.vt-q)}; g.r.getLastError=function(){return this.oZ};g.r=lC8.prototype;g.r.M3=null;g.r.nR=null;g.r.QF=!1;g.r.DT=null;g.r.Ts=null;g.r.Am=-1;g.r.du=null;g.r.V6=null;g.r.connect=function(q){this.DT=q;q=Pq(this.D,null,this.DT);lB(3);Date.now();var Z=this.D.PG;Z!=null?(this.du=Z[0],(this.V6=Z[1])?(this.Ts=1,esm(this)):(this.Ts=2,cEE(this))):(Lr(q,"MODE","init"),this.nR=new uB(this),this.nR.gI=this.M3,gmt(this.nR,q,!1,null,!0),this.Ts=0)}; g.r.Dc=function(q){if(q)this.Ts=2,cEE(this);else{lB(4);var Z=this.D;Z.BK=Z.ZR.Am;oT(Z,9)}q&&this.u5(2)}; g.r.J4=function(q){return this.D.J4(q)}; g.r.abort=function(){this.nR&&(this.nR.cancel(),this.nR=null);this.Am=-1}; g.r.TD=function(){return!1}; g.r.xs=function(q,Z){this.Am=q.ej;if(this.Ts==0)if(Z){try{var F=this.K.parse(Z)}catch(B){q=this.D;q.BK=this.Am;oT(q,2);return}this.du=F[0];this.V6=F[1]}else q=this.D,q.BK=this.Am,oT(q,2);else this.Ts==2&&(this.QF?(lB(7),Date.now()):Z=="11111"?(lB(6),this.QF=!0,Date.now(),this.Am=200,this.nR.cancel(),lB(12),UG(this.D,this,!0)):(lB(8),Date.now(),this.QF=!1))}; g.r.Px=function(){this.Am=this.nR.ej;if(this.nR.sY)this.Ts==0?this.V6?(this.Ts=1,esm(this)):(this.Ts=2,cEE(this)):this.Ts==2&&(this.QF?(lB(12),UG(this.D,this,!0)):(lB(11),UG(this.D,this,!1)));else{this.Ts==0?lB(9):this.Ts==2&&lB(10);var q=this.D;this.nR.getLastError();q.BK=this.Am;oT(q,2)}}; g.r.Cq=function(){return this.D.Cq()}; g.r.isActive=function(){return this.D.isActive()}; g.r.u5=function(q){this.D.u5(q)};g.r=LD5.prototype;g.r.Eq=null;g.r.Fp=null;g.r.j5=null;g.r.SI=null;g.r.Ks=null;g.r.j6=null;g.r.Vb=null;g.r.u3=null;g.r.Tf=0;g.r.Mw=0;g.r.uQ=null;g.r.vz=null;g.r.YK=null;g.r.VU=null;g.r.ZR=null;g.r.Bt=null;g.r.z4=-1;g.r.HU=-1;g.r.BK=-1;g.r.G4=0;g.r.Sm=0;g.r.xr=8;var ihE={OK:0,ySE:2,P6r:4,NsP:5,qfr:6,STOP:7,GS:8,cqL:9,GUl:10,nxp:11,QVE:12};g.JC(wh8,g.SL);g.JC(rdE,g.SL);g.r=LD5.prototype; g.r.connect=function(q,Z,F,B,f){lB(0);this.Ks=Z;this.Fp=F||{};B&&f!==void 0&&(this.Fp.OSID=B,this.Fp.OAID=f);this.V?(nr((0,g.Jy)(this.SD,this,q),100),gZE(this)):this.SD(q)}; g.r.disconnect=function(){BIm(this);if(this.D==3){var q=this.Tf++,Z=this.j6.clone();g.E2(Z,"SID",this.G);g.E2(Z,"RID",q);g.E2(Z,"TYPE","terminate");zV(this,Z);q=new uB(this,this.G,q);q.B_=2;q.aq=bt(Z.clone());(new Image).src=q.aq.toString();q.q$=Date.now();yEt(q)}uim(this)}; g.r.SD=function(q){this.ZR=new lC8(this);this.ZR.M3=this.Eq;this.ZR.K=this.Z;this.ZR.connect(q)}; g.r.TD=function(){return this.D==0}; g.r.getState=function(){return this.D}; g.r.aA=function(q){this.vz=null;XI5(this,q)}; g.r.Ll=function(){this.YK=null;this.SI=new uB(this,this.G,"rpc",this.X);this.SI.gI=this.Eq;this.SI.Ev=0;var q=this.Vb.clone();g.E2(q,"RID","rpc");g.E2(q,"SID",this.G);g.E2(q,"CI",this.Bt?"0":"1");g.E2(q,"AID",this.z4);zV(this,q);g.E2(q,"TYPE","xmlhttp");gmt(this.SI,q,!0,this.u3,!1)}; g.r.xs=function(q,Z){if(this.D!=0&&(this.SI==q||this.j5==q))if(this.BK=q.ej,this.j5==q&&this.D==3)if(this.xr>7){try{var F=this.Z.parse(Z)}catch(B){F=null}if(Array.isArray(F)&&F.length==3)if(q=F,q[0]==0)a:{if(!this.YK){if(this.SI)if(this.SI.q$+3E30)){if(B=Z==1)this.j5||this.vz||this.D==1||this.G4>=2?B=!1:(this.vz=nr((0,g.Jy)(this.aA,this,q),Gz_(this,this.G4)),this.G4++, B=!0);B=!(B||Z==2&&u1E(this))}if(B)switch(F){case 1:oT(this,5);break;case 4:oT(this,10);break;case 3:oT(this,6);break;case 7:oT(this,12);break;default:oT(this,2)}}}; g.r.Js=function(q){if(!g.r1(arguments,this.D))throw Error("Unexpected channel state: "+this.D);}; g.r.c1_=function(q){q?lB(2):(lB(1),HBj(this,8))}; g.r.J4=function(q){if(q)throw Error("Can't create secondary domain capable XhrIo object.");q=new g.vu;q.X=!1;return q}; g.r.isActive=function(){return!!this.uQ&&this.uQ.isActive(this)}; g.r.u5=function(q){var Z=qV;Z.dispatchEvent(new rdE(Z,q))}; g.r.Cq=function(){return!1}; g.r=Bh_.prototype;g.r.qy=function(){}; g.r.ek=function(){}; g.r.Cl=function(){}; g.r.IA=function(){}; g.r.Sl=function(){}; g.r.Fs=function(){return{}}; g.r.isActive=function(){return!0};g.r=kzB.prototype;g.r.enqueue=function(q){this.K.push(q)}; g.r.isEmpty=function(){return this.D.length===0&&this.K.length===0}; g.r.clear=function(){this.D=[];this.K=[]}; g.r.contains=function(q){return g.r1(this.D,q)||g.r1(this.K,q)}; g.r.remove=function(q){var Z=this.D;var F=(0,g.AYm)(Z,q);F>=0?(g.rt(Z,F),Z=!0):Z=!1;return Z||g.NL(this.K,q)}; g.r.pQ=function(){for(var q=[],Z=this.D.length-1;Z>=0;--Z)q.push(this.D[Z]);Z=this.K.length;for(var F=0;F=k1B.length?this.publish("pairingFailed",Error("DIAL polling timed out")):(q=k1B[this.K],this.Cp=g.OT((0,g.Jy)(this.IN,this),q),this.K++):this.publish("pairingFailed",Error("Server error "+q.status))}; g.r.S9=function(){this.D=null;this.publish("pairingFailed",Error("Server not responding"))}; var k1B=[2E3,2E3,1E3,1E3,1E3,2E3,2E3,5E3,5E3,1E4];g.JC(gf,fl);g.r=gf.prototype;g.r.start=function(){NV(this)&&this.publish("screenChange");!g.sY("yt-remote-lounge-token-expiration")&&ecm(this);g.L4(this.D);this.D=g.OT((0,g.Jy)(this.start,this),1E4)}; g.r.add=function(q,Z){NV(this);EZm(this,q);Z9(this,!1);this.publish("screenChange");Z(q);q.token||ecm(this)}; g.r.remove=function(q,Z){var F=NV(this);Vqu(this,q)&&(Z9(this,!1),F=!0);Z(q);F&&this.publish("screenChange")}; g.r.Z0=function(q,Z,F,B){var f=NV(this),D=this.get(q.id);D?(D.name!=Z&&(D.name=Z,Z9(this,!1),f=!0),F(q)):B(Error("no such local screen."));f&&this.publish("screenChange")}; g.r.SU=function(){g.L4(this.D);gf.Km.SU.call(this)}; g.r.Au=function(q){NV(this);var Z=this.screens.length;q=q&&q.screens||[];for(var F=q.length,B=0;B20)break a;n=Z(D,G)}D=n}f.name=D}F(nl(this,f))},this), onError:(0,g.Jy)(function(f){B(Error("pairing request failed: "+f.status))},this), onTimeout:(0,g.Jy)(function(){B(Error("pairing request timed out."))},this)})}; g.r.SU=function(){g.dN(this.K);g.dN(this.D);Dh.Km.SU.call(this)}; g.r.jf=function(){wI6(this);this.publish("screenChange");this.D.update()}; Dh.prototype.dispose=Dh.prototype.dispose;g.JC(DF,g.In);g.r=DF.prototype;g.r.F$=function(q){this.jU()||(q&&(xg(this,""+q),this.publish("sessionFailed")),this.D=null,this.publish("sessionScreen",null))}; g.r.info=function(q){Bo(this.k$,q)}; g.r.vU=function(){return null}; g.r.Ww=function(q){var Z=this.K;q?(Z.displayStatus=new chrome.cast.ReceiverDisplayStatus(q,[]),Z.displayStatus.showStop=!0):Z.displayStatus=null;chrome.cast.setReceiverDisplayStatus(Z,(0,g.Jy)(function(){this.info("Updated receiver status for "+Z.friendlyName+": "+q)},this),(0,g.Jy)(function(){xg(this,"Failed to update receiver status for: "+Z.friendlyName)},this))}; g.r.SU=function(){this.Ww("");DF.Km.SU.call(this)};g.V(Gi,DF);g.r=Gi.prototype;g.r.U2=function(q){if(this.S){if(this.S==q)return;xg(this,"Overriding cast session with new session object");skj(this);this.zP=!1;this.PG="unknown";this.S.removeUpdateListener(this.uL);this.S.removeMessageListener("urn:x-cast:com.google.youtube.mdx",this.Y$)}this.S=q;this.S.addUpdateListener(this.uL);this.S.addMessageListener("urn:x-cast:com.google.youtube.mdx",this.Y$);WtE(this,"getMdxSessionStatus")}; g.r.LJ=function(q){this.info("launchWithParams no-op for Cast: "+g.eX(q))}; g.r.stop=function(){this.S?this.S.stop((0,g.Jy)(function(){this.F$()},this),(0,g.Jy)(function(){this.F$(Error("Failed to stop receiver app."))},this)):this.F$(Error("Stopping cast device without session."))}; g.r.Ww=function(){}; g.r.SU=function(){this.info("disposeInternal");skj(this);this.S&&(this.S.removeUpdateListener(this.uL),this.S.removeMessageListener("urn:x-cast:com.google.youtube.mdx",this.Y$));this.S=null;DF.prototype.SU.call(this)}; g.r.mEc=function(q,Z){if(!this.jU())if(Z)if(Z=zi(Z),g.yF(Z))switch(q=""+Z.type,Z=Z.data||{},this.info("onYoutubeMessage_: "+q+" "+g.eX(Z)),q){case "mdxSessionStatus":zcu(this,Z);break;case "loungeToken":yeB(this,Z);break;default:xg(this,"Unknown youtube message: "+q)}else xg(this,"Unable to parse message.");else xg(this,"No data in message.")}; g.r.XO=function(q,Z,F,B){g.L4(this.V);this.V=0;wcE(this.G,this.K.label,q,this.K.friendlyName,(0,g.Jy)(function(f){f?Z(f):B>=0?(xg(this,"Screen "+q+" appears to be offline. "+B+" retries left."),this.V=g.OT((0,g.Jy)(this.XO,this,q,Z,F,B-1),300)):F(Error("Unable to fetch screen."))},this),F)}; g.r.vU=function(){return this.S}; g.r.zL=function(q){this.jU()||q||(xg(this,"Cast session died."),this.F$())};g.V(Yg,DF);g.r=Yg.prototype;g.r.U2=function(q){this.S=q;this.S.addUpdateListener(this.dU)}; g.r.LJ=function(q){this.BG=q;this.Dl()}; g.r.stop=function(){ce0(this);this.S?this.S.stop((0,g.Jy)(this.F$,this,null),(0,g.Jy)(this.F$,this,"Failed to stop DIAL device.")):this.F$()}; g.r.SU=function(){ce0(this);this.S&&this.S.removeUpdateListener(this.dU);this.S=null;DF.prototype.SU.call(this)}; g.r.n4=function(q){this.jU()||q||(xg(this,"DIAL session died."),this.Z(),this.Z=function(){},this.F$())};g.V(EG,DF);EG.prototype.stop=function(){this.F$()}; EG.prototype.U2=function(){}; EG.prototype.LJ=function(){g.L4(this.S);this.S=NaN;var q=V4(this.G.Uq(),this.K.label);q?vq(this,q):this.F$(Error("No such screen"))}; EG.prototype.SU=function(){g.L4(this.S);this.S=NaN;DF.prototype.SU.call(this)};g.V(OG,g.In);g.r=OG.prototype; g.r.init=function(q,Z){chrome.cast.timeout.requestSession=3E4;var F=new chrome.cast.SessionRequest(this.V,[chrome.cast.Capability.AUDIO_OUT]);g.cz("desktop_enable_cast_connect")&&(F.androidReceiverCompatible=!0);this.PG||(F.dialRequest=new chrome.cast.DialRequest("YouTube"));var B=chrome.cast.AutoJoinPolicy.TAB_AND_ORIGIN_SCOPED;q=q||this.j?chrome.cast.DefaultActionPolicy.CAST_THIS_TAB:chrome.cast.DefaultActionPolicy.CREATE_SESSION;var f=(0,g.Jy)(this.ZPs,this);F=new chrome.cast.ApiConfig(F,(0,g.Jy)(this.Yw, this),f,B,q);F.customDialLaunchCallback=(0,g.Jy)(this.ok$,this);chrome.cast.initialize(F,(0,g.Jy)(function(){this.jU()||(chrome.cast.addReceiverActionListener(this.Z),iBe(),this.K.subscribe("onlineScreenChange",(0,g.Jy)(this.Jw,this)),this.S=WDE(this),chrome.cast.setCustomReceivers(this.S,function(){},(0,g.Jy)(function(D){this.Zz("Failed to set initial custom receivers: "+g.eX(D))},this)),this.publish("yt-remote-cast2-availability-change",SW(this)),Z(!0))},this),(0,g.Jy)(function(D){this.Zz("Failed to initialize API: "+ g.eX(D)); Z(!1)},this))}; g.r.NRl=function(q,Z){Rx("Setting connected screen ID: "+q+" -> "+Z);if(this.D){var F=this.D.D;if(!q||F&&F.id!=q)Rx("Unsetting old screen status: "+this.D.K.friendlyName),Fl(this,null)}if(q&&Z){if(!this.D){q=V4(this.K.Uq(),q);if(!q){Rx("setConnectedScreenStatus: Unknown screen.");return}if(q.idType=="shortLived"){Rx("setConnectedScreenStatus: Screen with id type to be short lived.");return}F=wKm(this,q);F||(Rx("setConnectedScreenStatus: Connected receiver not custom..."),F=new chrome.cast.Receiver(q.uuid? q.uuid:q.id,q.name),F.receiverType=chrome.cast.ReceiverType.CUSTOM,this.S.push(F),chrome.cast.setCustomReceivers(this.S,function(){},(0,g.Jy)(function(B){this.Zz("Failed to set initial custom receivers: "+g.eX(B))},this))); Rx("setConnectedScreenStatus: new active receiver: "+F.friendlyName);Fl(this,new EG(this.K,F),!0)}this.D.Ww(Z)}else Rx("setConnectedScreenStatus: no screen.")}; g.r.y8c=function(q){this.jU()?this.Zz("Setting connection data on disposed cast v2"):this.D?this.D.LJ(q):this.Zz("Setting connection data without a session")}; g.r.QS=function(){this.jU()?this.Zz("Stopping session on disposed cast v2"):this.D?(this.D.stop(),Fl(this,null)):Rx("Stopping non-existing session")}; g.r.requestSession=function(){chrome.cast.requestSession((0,g.Jy)(this.Yw,this),(0,g.Jy)(this.HPP,this))}; g.r.SU=function(){this.K.unsubscribe("onlineScreenChange",(0,g.Jy)(this.Jw,this));window.chrome&&chrome.cast&&chrome.cast.removeReceiverActionListener(this.Z);var q=igm,Z=g.ym("yt.mdx.remote.debug.handlers_");g.NL(Z||[],q);g.dN(this.D);g.In.prototype.SU.call(this)}; g.r.Zz=function(q){Bo("Controller",q)}; g.r.ZX=function(q,Z){this.D==q&&(Z||Fl(this,null),this.publish("yt-remote-cast2-session-change",Z))}; g.r.k3U=function(q,Z){if(!this.jU())if(q)switch(q.friendlyName=chrome.cast.unescape(q.friendlyName),Rx("onReceiverAction_ "+q.label+" / "+q.friendlyName+"-- "+Z),Z){case chrome.cast.ReceiverAction.CAST:if(this.D)if(this.D.K.label!=q.label)Rx("onReceiverAction_: Stopping active receiver: "+this.D.K.friendlyName),this.D.stop();else{Rx("onReceiverAction_: Casting to active receiver.");this.D.D&&this.publish("yt-remote-cast2-session-change",this.D.D);break}switch(q.receiverType){case chrome.cast.ReceiverType.CUSTOM:Fl(this, new EG(this.K,q));break;case chrome.cast.ReceiverType.DIAL:Fl(this,new Yg(this.K,q,this.G,this.config_));break;case chrome.cast.ReceiverType.CAST:Fl(this,new Gi(this.K,q,this.config_));break;default:this.Zz("Unknown receiver type: "+q.receiverType)}break;case chrome.cast.ReceiverAction.STOP:this.D&&this.D.K.label==q.label?this.D.stop():this.Zz("Stopping receiver w/o session: "+q.friendlyName)}else this.Zz("onReceiverAction_ called without receiver.")}; g.r.ok$=function(q){if(this.jU())return Promise.reject(Error("disposed"));var Z=q.receiver;Z.receiverType!=chrome.cast.ReceiverType.DIAL&&(this.Zz("Not DIAL receiver: "+Z.friendlyName),Z.receiverType=chrome.cast.ReceiverType.DIAL);var F=this.D?this.D.K:null;if(!F||F.label!=Z.label)return this.Zz("Receiving DIAL launch request for non-clicked DIAL receiver: "+Z.friendlyName),Promise.reject(Error("illegal DIAL launch"));if(F&&F.label==Z.label&&F.receiverType!=chrome.cast.ReceiverType.DIAL){if(this.D.D)return Rx("Reselecting dial screen."), this.publish("yt-remote-cast2-session-change",this.D.D),Promise.resolve(new chrome.cast.DialLaunchResponse(!1));this.Zz('Changing CAST intent from "'+F.receiverType+'" to "dial" for '+Z.friendlyName);Fl(this,new Yg(this.K,Z,this.G,this.config_))}Z=this.D;Z.V=q;Z.V.appState==chrome.cast.DialAppState.RUNNING?(q=Z.V.extraData||{},F=q.screenId||null,kg(Z)&&q.loungeToken?q.loungeTokenRefreshIntervalMs?q=Ax8(Z,{name:Z.K.friendlyName,screenId:q.screenId,loungeToken:q.loungeToken,dialId:Z.V.receiver.label, screenIdType:"shortLived"},q.loungeTokenRefreshIntervalMs):(g.vf(Error("No loungeTokenRefreshIntervalMs presents in additionalData: "+JSON.stringify(q)+".")),q=Hhj(Z,F)):q=Hhj(Z,F)):q=oZ_(Z);return q}; g.r.Yw=function(q){var Z=this;if(!this.jU()&&!this.j){Rx("New cast session ID: "+q.sessionId);var F=q.receiver;if(F.receiverType!=chrome.cast.ReceiverType.CUSTOM){if(!this.D)if(F.receiverType==chrome.cast.ReceiverType.CAST)Rx("Got resumed cast session before resumed mdx connection."),F.friendlyName=chrome.cast.unescape(F.friendlyName),Fl(this,new Gi(this.K,F,this.config_),!0);else{this.Zz("Got non-cast session without previous mdx receiver event, or mdx resume.");return}var B=this.D.K,f=V4(this.K.Uq(), B.label);f&&Fv(f,F.label)&&B.receiverType!=chrome.cast.ReceiverType.CAST&&F.receiverType==chrome.cast.ReceiverType.CAST&&(Rx("onSessionEstablished_: manual to cast session change "+F.friendlyName),g.dN(this.D),this.D=new Gi(this.K,F,this.config_),this.D.subscribe("sessionScreen",(0,g.Jy)(this.ZX,this,this.D)),this.D.subscribe("sessionFailed",function(){return wum(Z,Z.D)}),this.D.LJ(null)); this.D.U2(q)}}}; g.r.cA=function(){return this.D?this.D.vU():null}; g.r.HPP=function(q){this.jU()||(this.Zz("Failed to estabilish a session: "+g.eX(q)),q.code!=chrome.cast.ErrorCode.CANCEL&&Fl(this,null),this.publish("yt-remote-cast2-session-failed"))}; g.r.ZPs=function(q){Rx("Receiver availability updated: "+q);if(!this.jU()){var Z=SW(this);this.X=q==chrome.cast.ReceiverAvailability.AVAILABLE;SW(this)!=Z&&this.publish("yt-remote-cast2-availability-change",SW(this))}}; g.r.Jw=function(){this.jU()||(this.S=WDE(this),Rx("Updating custom receivers: "+g.eX(this.S)),chrome.cast.setCustomReceivers(this.S,function(){},(0,g.Jy)(function(){this.Zz("Failed to set custom receivers.")},this)),this.publish("yt-remote-cast2-availability-change",SW(this)))}; OG.prototype.setLaunchParams=OG.prototype.y8c;OG.prototype.setConnectedScreenStatus=OG.prototype.NRl;OG.prototype.stopSession=OG.prototype.QS;OG.prototype.getCastSession=OG.prototype.cA;OG.prototype.requestSession=OG.prototype.requestSession;OG.prototype.init=OG.prototype.init;OG.prototype.dispose=OG.prototype.dispose;var stm=g.ue(["https://www.gstatic.com/cv/js/sender/v1/cast_sender.js"]),xnm=[],m_B=g.ly(stm);g.r=eM.prototype; g.r.reset=function(q){this.listId="";this.index=-1;this.videoId="";Qt0(this);this.volume=-1;this.muted=!1;q&&(this.index=q.index,this.listId=q.listId,this.videoId=q.videoId,this.playerState=q.playerState,this.volume=q.volume,this.muted=q.muted,this.audioTrackId=q.audioTrackId,this.trackData=q.trackData,this.MS=q.hasPrevious,this.jr=q.hasNext,this.j=q.playerTime,this.Z=q.playerTimeAt,this.K=q.seekableStart,this.X=q.seekableEnd,this.S=q.duration,this.V=q.loadedTime,this.D=q.liveIngestionTime,this.G= !isNaN(this.D))}; g.r.isPlaying=function(){return this.playerState==1}; g.r.isBuffering=function(){return this.playerState==3}; g.r.Va=function(q){this.S=isNaN(q)?0:q}; g.r.getDuration=function(){return this.G?this.S+tN(this):this.S}; g.r.clone=function(){return new eM(ud5(this))};g.V(iB,g.In);g.r=iB.prototype;g.r.getState=function(){return this.S}; g.r.Hp=function(){return this.G.getReconnectTimeout()}; g.r.A$=function(){this.G.reconnect()}; g.r.play=function(){dv(this)?(this.D?this.D.play(null,g.Ww,PQ(this,"play")):Aj(this,"play"),uWE(this,1,u4(Ti(this))),this.publish("remotePlayerChange")):pr(this,this.play)}; g.r.pause=function(){dv(this)?(this.D?this.D.pause(null,g.Ww,PQ(this,"pause")):Aj(this,"pause"),uWE(this,2,u4(Ti(this))),this.publish("remotePlayerChange")):pr(this,this.pause)}; g.r.seekTo=function(q){if(dv(this)){if(this.D){var Z=Ti(this),F=new chrome.cast.media.SeekRequest;F.currentTime=q;Z.isPlaying()||Z.isBuffering()?F.resumeState=chrome.cast.media.ResumeState.PLAYBACK_START:F.resumeState=chrome.cast.media.ResumeState.PLAYBACK_PAUSE;this.D.seek(F,g.Ww,PQ(this,"seekTo",{newTime:q}))}else Aj(this,"seekTo",{newTime:q});uWE(this,3,q);this.publish("remotePlayerChange")}else pr(this,g.sy(this.seekTo,q))}; g.r.stop=function(){if(dv(this)){this.D?this.D.stop(null,g.Ww,PQ(this,"stopVideo")):Aj(this,"stopVideo");var q=Ti(this);q.index=-1;q.videoId="";Qt0(q);cq(this,q);this.publish("remotePlayerChange")}else pr(this,this.stop)}; g.r.setVolume=function(q,Z){if(dv(this)){var F=Ti(this);if(this.K){if(F.volume!=q){var B=Math.round(q)/100;this.K.setReceiverVolumeLevel(B,(0,g.Jy)(function(){ax("set receiver volume: "+B)},this),(0,g.Jy)(function(){this.Zz("failed to set receiver volume.")},this))}F.muted!=Z&&this.K.setReceiverMuted(Z,(0,g.Jy)(function(){ax("set receiver muted: "+Z)},this),(0,g.Jy)(function(){this.Zz("failed to set receiver muted.")},this))}else{var f={volume:q, muted:Z};F.volume!=-1&&(f.delta=q-F.volume);Aj(this,"setVolume",f)}F.muted=Z;F.volume=q;cq(this,F)}else pr(this,g.sy(this.setVolume,q,Z))}; g.r.MK=function(q,Z){if(dv(this)){var F=Ti(this);q={videoId:q};Z&&(F.trackData={trackName:Z.name,languageCode:Z.languageCode,sourceLanguageCode:Z.translationLanguage?Z.translationLanguage.languageCode:"",languageName:Z.languageName,kind:Z.kind},q.style=g.eX(Z.style),g.gN(q,F.trackData));Aj(this,"setSubtitlesTrack",q);cq(this,F)}else pr(this,g.sy(this.MK,q,Z))}; g.r.setAudioTrack=function(q,Z){dv(this)?(Z=Z.getLanguageInfo().getId(),Aj(this,"setAudioTrack",{videoId:q,audioTrackId:Z}),q=Ti(this),q.audioTrackId=Z,cq(this,q)):pr(this,g.sy(this.setAudioTrack,q,Z))}; g.r.playVideo=function(q,Z,F,B,f,D,G){B=B===void 0?null:B;f=f===void 0?null:f;D=D===void 0?null:D;G=G===void 0?null:G;var n=Ti(this),b={videoId:q};F!==void 0&&(b.currentIndex=F);fL(n,q,F||0);Z!==void 0&&(vo(n,Z),b.currentTime=Z);B&&(b.listId=B);f&&(b.playerParams=f);D&&(b.clickTrackingParams=D);G&&(b.locationInfo=g.eX(G));Aj(this,"setPlaylist",b);B||cq(this,n)}; g.r.Dw=function(q,Z){if(dv(this)){if(q&&Z){var F=Ti(this);fL(F,q,Z);cq(this,F)}Aj(this,"previous")}else pr(this,g.sy(this.Dw,q,Z))}; g.r.nextVideo=function(q,Z){if(dv(this)){if(q&&Z){var F=Ti(this);fL(F,q,Z);cq(this,F)}Aj(this,"next")}else pr(this,g.sy(this.nextVideo,q,Z))}; g.r.pZ=function(){if(dv(this)){Aj(this,"clearPlaylist");var q=Ti(this);q.reset();cq(this,q);this.publish("remotePlayerChange")}else pr(this,this.pZ)}; g.r.Xi=function(){dv(this)?Aj(this,"dismissAutoplay"):pr(this,this.Xi)}; g.r.dispose=function(){if(this.S!=3){var q=this.S;this.S=3;this.publish("proxyStateChange",q,this.S)}g.In.prototype.dispose.call(this)}; g.r.SU=function(){Vvm(this);this.G=null;this.Z.clear();m2(this,null);g.In.prototype.SU.call(this)}; g.r.O2=function(q){if((q!=this.S||q==2)&&this.S!=3&&q!=0){var Z=this.S;this.S=q;this.publish("proxyStateChange",Z,q);if(q==1)for(;!this.Z.isEmpty();)Z=q=this.Z,Z.D.length===0&&(Z.D=Z.K,Z.D.reverse(),Z.K=[]),q.D.pop().apply(this);else q==3&&this.dispose()}}; g.r.mil=function(q,Z){this.publish(q,Z)}; g.r.jhF=function(q){if(!q)this.SE(null),m2(this,null);else if(this.K.receiver.volume){q=this.K.receiver.volume;var Z=Ti(this),F=Math.round(100*q.level||0);if(Z.volume!=F||Z.muted!=q.muted)ax("Cast volume update: "+q.level+(q.muted?" muted":"")),Z.volume=F,Z.muted=!!q.muted,cq(this,Z)}}; g.r.SE=function(q){ax("Cast media: "+!!q);this.D&&this.D.removeUpdateListener(this.V);if(this.D=q)this.D.addUpdateListener(this.V),out(this),this.publish("remotePlayerChange")}; g.r.dlG=function(q){q?(out(this),this.publish("remotePlayerChange")):this.SE(null)}; g.r.zx=function(){Aj(this,"sendDebugCommand",{debugCommand:"stats4nerds "})}; g.r.W6a=function(){var q=jAe();q&&m2(this,q)}; g.r.Zz=function(q){Bo("CP",q)};g.V(Gq,g.In);g.r=Gq.prototype; g.r.connect=function(q,Z){if(Z){var F=Z.listId,B=Z.videoId,f=Z.videoIds,D=Z.playerParams,G=Z.clickTrackingParams,n=Z.index,b={videoId:B},N=Z.currentTime,S=Z.locationInfo;Z=Z.loopMode;N!==void 0&&(b.currentTime=N<=5?0:N);D&&(b.playerParams=D);S&&(b.locationInfo=S);G&&(b.clickTrackingParams=G);F&&(b.listId=F);f&&f.length>0&&(b.videoIds=f.join(","));n!==void 0&&(b.currentIndex=n);this.dU&&(b.loopMode=Z||"LOOP_MODE_OFF");F&&(this.D.listId=F);this.D.videoId=B;this.D.index=n||0;this.D.state=3;vo(this.D, N);this.Z="UNSUPPORTED";F=this.dU?"setInitialState":"setPlaylist";GV("Connecting with "+F+" and params: "+g.eX(b));this.K.connect({method:F,params:g.eX(b)},q,Un_())}else GV("Connecting without params"),this.K.connect({},q,Un_());gdm(this)}; g.r.OY=function(q){this.K.OY(q)}; g.r.dispose=function(){this.jU()||(g.O9("yt.mdx.remote.remoteClient_",null),this.publish("beforeDispose"),Qx(this,3));g.In.prototype.dispose.call(this)}; g.r.SU=function(){wlu(this);g7m(this);mm8(this);g.L4(this.V);this.V=NaN;g.L4(this.PG);this.PG=NaN;this.G=null;g.Cb(this.Dl);this.Dl.length=0;this.K.dispose();g.In.prototype.SU.call(this);this.Z=this.X=this.S=this.D=this.K=null}; g.r.BS=function(q){if(!this.S||this.S.length===0)return!1;for(var Z=g.E(this.S),F=Z.next();!F.done;F=Z.next())if(!F.value.capabilities.has(q))return!1;return!0}; g.r.Ii=function(){var q=3;this.jU()||(q=0,isNaN(this.e8())?this.K.il()&&isNaN(this.j)&&(q=1):q=2);return q}; g.r.x7=function(q){GV("Disconnecting with "+q);g.O9("yt.mdx.remote.remoteClient_",null);wlu(this);this.publish("beforeDisconnect",q);q==1&&$g();this.K.disconnect(q);this.dispose()}; g.r.bK=function(){var q=this.D;this.G&&(q=this.D.clone(),fL(q,this.G,q.index));return ud5(q)}; g.r.hJa=function(q){var Z=this,F=new eM(q);F.videoId&&F.videoId!=this.D.videoId&&(this.G=F.videoId,g.L4(this.V),this.V=g.OT(function(){if(Z.G){var f=Z.G;Z.G=null;Z.D.videoId!=f&&Ue(Z,"getNowPlaying")}},5E3)); var B=[];this.D.listId==F.listId&&this.D.videoId==F.videoId&&this.D.index==F.index||B.push("remoteQueueChange");this.D.playerState==F.playerState&&this.D.volume==F.volume&&this.D.muted==F.muted&&u4(this.D)==u4(F)&&g.eX(this.D.trackData)==g.eX(F.trackData)||B.push("remotePlayerChange");this.D.reset(q);g.yn(B,function(f){this.publish(f)},this)}; g.r.wg=function(){var q=this.K.getDeviceId(),Z=g.s3(this.S,function(F){return F.type=="REMOTE_CONTROL"&&F.id!=q}); return Z?Z.id:""}; g.r.e8=function(){return this.K.Hp()}; g.r.wk=function(){return this.Z||"UNSUPPORTED"}; g.r.Uw=function(){return this.X||""}; g.r.mL=function(){!isNaN(this.e8())&&this.K.A$()}; g.r.j4G=function(q,Z){Ue(this,q,Z);WGB(this)}; g.r.P$=function(){var q=g.$0("SAPISID","")||g.$0("__Secure-1PAPISID")||"",Z=g.$0("__Secure-3PAPISID","")||"";if(!q&&!Z)return"";q=g.MR(g.J4(q),2);Z=g.MR(g.J4(Z),2);return g.MR(g.J4(","+q+","+Z),2)}; Gq.prototype.subscribe=Gq.prototype.subscribe;Gq.prototype.unsubscribeByKey=Gq.prototype.DI;Gq.prototype.getProxyState=Gq.prototype.Ii;Gq.prototype.disconnect=Gq.prototype.x7;Gq.prototype.getPlayerContextData=Gq.prototype.bK;Gq.prototype.setPlayerContextData=Gq.prototype.hJa;Gq.prototype.getOtherConnectedRemoteId=Gq.prototype.wg;Gq.prototype.getReconnectTimeout=Gq.prototype.e8;Gq.prototype.getAutoplayMode=Gq.prototype.wk;Gq.prototype.getAutoplayVideoId=Gq.prototype.Uw;Gq.prototype.reconnect=Gq.prototype.mL; Gq.prototype.sendMessage=Gq.prototype.j4G;Gq.prototype.getXsrfToken=Gq.prototype.P$;Gq.prototype.isCapabilitySupportedOnConnectedDevices=Gq.prototype.BS;g.V(enB,fl);g.r=enB.prototype;g.r.Uq=function(q){return this.R1.$_gs(q)}; g.r.contains=function(q){return!!this.R1.$_c(q)}; g.r.get=function(q){return this.R1.$_g(q)}; g.r.start=function(){this.R1.$_st()}; g.r.add=function(q,Z,F){this.R1.$_a(q,Z,F)}; g.r.remove=function(q,Z,F){this.R1.$_r(q,Z,F)}; g.r.Z0=function(q,Z,F,B){this.R1.$_un(q,Z,F,B)}; g.r.SU=function(){for(var q=this.D.length,Z=0;Z1&&!this.B.getOption("remote","quickCast")?(this.T7=g.Gp(q,this.D,this),this.Qk(g.DC(q,this.D)),q=this.B.getOption("remote","currentReceiver"),q=this.D(q),this.options[q]&&this.SN(q),this.enable(!0)):this.enable(!1)}; R1.prototype.D=function(q){return q.key}; R1.prototype.QM=function(q){return q==="cast-selector-receiver"?"Transmitir\u2026":this.T7[q].name}; R1.prototype.GH=function(q){g.qB.prototype.GH.call(this,q);this.B.setOption("remote","currentReceiver",this.T7[q]);this.Pg.Uy()};g.V(aG6,g.a3);g.r=aG6.prototype; g.r.create=function(){var q=this.player.C(),Z=g.H_(q);q={device:"Desktop",app:"youtube-desktop",loadCastApiSetupScript:q.U("mdx_load_cast_api_bootstrap_script"),enableDialLoungeToken:q.U("enable_dial_short_lived_lounge_token"),enableCastLoungeToken:q.U("enable_cast_short_lived_lounge_token")};dXu(Z,q);this.subscriptions.push(g.NQ("yt-remote-before-disconnect",this.rZE,this));this.subscriptions.push(g.NQ("yt-remote-connection-change",this.rPE,this));this.subscriptions.push(g.NQ("yt-remote-receiver-availability-change",this.cF, this));this.subscriptions.push(g.NQ("yt-remote-auto-connect",this.Rrn,this));this.subscriptions.push(g.NQ("yt-remote-receiver-resumed",this.pZc,this));this.subscriptions.push(g.NQ("mdx-privacy-popup-confirm",this.LY$,this));this.subscriptions.push(g.NQ("mdx-privacy-popup-cancel",this.HwP,this));this.cF()}; g.r.load=function(){this.player.cancelPlayback();g.a3.prototype.load.call(this);this.X9=new x_E(this.player.C(),this);this.player.UG(this.X9);this.D2=new kQj(this,this.player,this.sy);var q=(q=ufu())?q.currentTime:0;var Z=Je6()?new iB(xe(),void 0):null;q==0&&Z&&(q=u4(Ti(Z)));q!==0&&this.y5(q);jk_(this,this.CP,this.CP);this.player.H5(6)}; g.r.unload=function(){this.player.publish("mdxautoplaycanceled");this.player.vv();this.Bp=this.Y9;g.AG(this.D2,this.sy);this.sy=this.X9=this.D2=null;g.a3.prototype.unload.call(this);this.player.H5(5);Vx(this)}; g.r.SU=function(){g.B8(this.subscriptions);g.a3.prototype.SU.call(this)}; g.r.Yh=function(q){var Z=g.CF.apply(1,arguments);this.loaded&&this.D2.XX.apply(this.D2,[q].concat(g.YB(Z)))}; g.r.getAdState=function(){return this.tW}; g.r.MS=function(){return this.sy?Ti(this.sy).MS:!1}; g.r.jr=function(){return this.sy?Ti(this.sy).jr:!1}; g.r.y5=function(q,Z){this.yB=q||0;this.player.publish("progresssync",q,Z);this.player.Ry("onVideoProgress",q||0)}; g.r.getCurrentTime=function(){return this.yB}; g.r.getDuration=function(){return Ti(this.sy).getDuration()||0}; g.r.rh=function(){var q=Ti(this.sy);return q.G?q.D+tN(q):q.D}; g.r.WX=function(){return Ti(this.sy).V}; g.r.xx=function(){return JVj(Ti(this.sy))}; g.r.l2=function(){var q=Ti(this.sy);return q.K>0?q.K+tN(q):q.K}; g.r.getProgressState=function(){var q=Ti(this.sy),Z=this.player.getVideoData();return{airingStart:0,airingEnd:0,allowSeeking:q.playerState!=1081&&this.player.v1(),clipEnd:Z.clipEnd,clipStart:Z.clipStart,current:this.getCurrentTime(),displayedStart:-1,duration:this.getDuration(),ingestionTime:this.rh(),isAtLiveHead:this.isAtLiveHead(),loaded:this.WX(),seekableEnd:this.xx(),seekableStart:this.l2(),offset:0,viewerLivestreamJoinMediaTime:0}}; g.r.isAtLiveHead=function(){return JVj(Ti(this.sy))-this.getCurrentTime()<=1}; g.r.nextVideo=function(){this.sy&&this.sy.nextVideo()}; g.r.Dw=function(){this.sy&&this.sy.Dw()}; g.r.rZE=function(q){q===1&&(this.oU=this.sy?Ti(this.sy):null)}; g.r.rPE=function(){var q=Je6()?new iB(xe(),void 0):null;if(q){var Z=this.Bp;this.loaded&&this.unload();this.sy=q;this.oU=null;Z.key!==this.Y9.key&&(this.Bp=Z,this.load())}else g.dN(this.sy),this.sy=null,this.loaded&&(this.unload(),(q=this.oU)&&q.videoId===this.player.getVideoData().videoId&&this.player.cueVideoById(q.videoId,u4(q)));this.player.publish("videodatachange","newdata",this.player.getVideoData(),3)}; g.r.cF=function(){var q=[this.Y9],Z=q.concat,F=Tyj();gv()&&g.sY("yt-remote-cast-available")&&F.push({key:"cast-selector-receiver",name:"Cast..."});this.T7=Z.call(q,F);q=CSm()||this.Y9;BQ(this,q);this.player.Ry("onMdxReceiversChange")}; g.r.Rrn=function(){var q=CSm();BQ(this,q)}; g.r.pZc=function(){this.Bp=CSm()}; g.r.LY$=function(){this.gz=!0;Vx(this);e9=!1;FO&&Bq(FO,1);FO=null}; g.r.HwP=function(){this.gz=!1;Vx(this);BQ(this,this.Y9);this.Bp=this.Y9;e9=!1;FO=null;this.player.playVideo()}; g.r.zA=function(q,Z){switch(q){case "casting":return this.loaded;case "receivers":return this.T7;case "currentReceiver":return Z&&(Z.key==="cast-selector-receiver"?Qk0():BQ(this,Z)),this.loaded?this.Bp:this.Y9;case "quickCast":return this.T7.length===2&&this.T7[1].key==="cast-selector-receiver"?(Z&&Qk0(),!0):!1}}; g.r.zx=function(){this.sy.zx()}; g.r.hM=function(){return!1}; g.r.getOptions=function(){return["casting","receivers","currentReceiver","quickCast"]}; g.r.isLoggedIn=function(){var q,Z;return((q=g.oa("PLAYER_CONFIG"))==null?void 0:(Z=q.args)==null?void 0:Z.authuser)!==void 0?!0:!(!g.oa("SESSION_INDEX")&&!g.oa("LOGGED_IN"))};g.Nx("remote",aG6);})(_yt_player);