(function(g){var window=this;'use strict';var mlg=function(b,R){return g.FH(b,R)},Pl3=function(b){if(b instanceof g.g3)return b; if(typeof b.sz=="function")return b.sz(!1);if(g.mq(b)){let R=0;const h=new g.g3;h.next=function(){for(;;){if(R>=b.length)return g.e_;if(R in b)return g.Wk(b[R++]);R++}}; return h}throw Error("Not implemented");},ZV3=function(b,R,h){if(g.mq(b))g.pr(b,R,h); else for(b=Pl3(b);;){const {done:K,value:I}=b.next();if(K)break;R.call(h,I,void 0,b)}},I9=function(b){g.$O(b,"zx",Math.floor(Math.random()*2147483648).toString(36)+Math.abs(Math.floor(Math.random()*2147483648)^g.wK()).toString(36)); return b},NO=function(b,R,h){Array.isArray(h)||(h=[String(h)]); g.aI(b.V,R,h)},cSz=function(b,R){const h=[]; ZV3(R,function(K){let I;try{I=g.PX.prototype.bO.call(this,K,!0)}catch(N){if(N=="Storage: Invalid value was encountered")return;throw N;}I===void 0?h.push(K):g.mA(I)&&h.push(K)},b); return h},ugn=function(b,R){cSz(b,R).forEach(function(h){g.PX.prototype.remove.call(this,h)},b)},X6n=function(b){if(b.PH){if(b.PH.locationOverrideToken)return{locationOverrideToken:b.PH.locationOverrideToken}; if(b.PH.latitudeE7!=null&&b.PH.longitudeE7!=null)return{latitudeE7:b.PH.latitudeE7,longitudeE7:b.PH.longitudeE7}}return null},VXz=function(b,R){g.iR(b,R)||b.push(R)},pF=function(b){let R=0; for(const h in b)R++;return R},Cl2=function(b){try{return g.JD.JSON.parse(b)}catch(R){}b=String(b); if(/^\s*$/.test(b)?0:/^[\],:{}\s\u2028\u2029]*$/.test(b.replace(/\\["\\\/bfnrtu]/g,"@").replace(/(?:"[^"\\\n\r\u2028\u2029\x00-\x08\x0a-\x1f]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)[\s\u2028\u2029]*(?=:|,|]|}|$)/g,"]").replace(/(?:^|:|,)(?:[\s\u2028\u2029]*\[)+/g,"")))try{return eval("("+b+")")}catch(R){}throw Error("Invalid JSON string: "+b);},lB=function(b){if(g.JD.JSON)try{return g.JD.JSON.parse(b)}catch(R){}return Cl2(b)},MXU=function(b,R,h,K){const I=new g.Fx(null); b&&g.o_(I,b);R&&g.Da(I,R);h&&g.bL(I,h);K&&(I.Y=K);return I},rSH=function(b,R){return new g.W4x(b,R)},a9=function(b,R){return Object.prototype.hasOwnProperty.call(b,R)},Lkn=function(b,R){return b===R},vB=function(b,R){this.Y={}; this.G=[];this.eG=this.size=0;var h=arguments.length;if(h>1){if(h%2)throw Error("Uneven number of arguments");for(var K=0;K{b.capabilities.add(h)})},Fkz=function(b,R){b.compatibleSenderThemes.clear(); g.lR(R.split(","),g.Lw(mlg,bfR)).forEach(h=>{b.compatibleSenderThemes.add(h)})},ooR=function(b,R){b.experiments.clear(); R.split(",").forEach(h=>{b.experiments.add(h)})},qO=function(b){b=b||{}; this.name=b.name||"";this.id=b.id||b.screenId||"";this.token=b.token||b.loungeToken||"";this.uuid=b.uuid||b.dialId||"";this.idType=b.screenIdType||"normal";this.secret=b.screenIdSecret||""},dQ=function(b,R){return!!R&&(b.id==R||b.uuid==R)},RN3=function(b){return{name:b.name, screenId:b.id,loungeToken:b.token,dialId:b.uuid,screenIdType:b.idType,screenIdSecret:b.secret}},hNr=function(b){return new qO(b)},KRn=function(b){return Array.isArray(b)?g.an(b,hNr):[]},fF=function(b){return b?`{name:"${b.name}",id:${b.id.substr(0,6)}..,token:${b.token?".."+b.token.slice(-6):"-"},uuid:${b.uuid?".."+b.uuid.slice(-6):"-"},idType:${b.idType},secret:${b.secret?".."+b.secret.slice(-6):"-"}}`:"null"},yn=function(b){return Array.isArray(b)?"["+g.an(b,fF).join(",")+"]":"null"},tZ=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(b){const R=Math.random()*16|0; return(b=="x"?R:R&3|8).toString(16)})},sZR=function(b){return g.an(b,function(R){return{key:R.id, name:R.name}})},jQ=function(b,R){return g.jc(b,function(h){return h||R?!h!=!R?!1:h.id==R.id:!0})},AZ=function(b,R){return g.jc(b,function(h){return dQ(h,R)})},$3R=function(){const b=g.$9.y8(); b&&ugn(b,b.OC.sz(!0))},iB=function(){const b=g.NC("yt-remote-connected-devices")||[]; g.Ot(b);return b},ITr=function(b){if(b.length==0)return[]; const R=b[0].indexOf("#"),h=R==-1?b[0]:b[0].substring(0,R);return g.an(b,function(K,I){return I==0?K:K.substring(h.length)})},N3n=function(b){g.Iz("yt-remote-connected-devices",b,86400)},Up=function(){if(zB)return zB; let b=g.NC("yt-remote-device-id");b||(b=tZ(),g.Iz("yt-remote-device-id",b,31536E3));const R=iB();let h=1,K=b;for(;g.iR(R,K);)h++,K=b+"#"+h;return zB=K},GB=function(){let b=iB(); const R=Up();g.lQ()&&g.xz(b,R);b=ITr(b);if(b.length==0)try{g.lG("remote_sid")}catch(h){}else try{g.Nj("remote_sid",b.join(","),-1)}catch(h){}},pkH=function(){return g.NC("yt-remote-session-browser-channel")},lTz=function(){return g.NC("yt-remote-local-screens")||[]},aTz=function(){g.Iz("yt-remote-lounge-token-expiration",!0,86400)},vlx=function(b){b.length>5&&(b=b.slice(b.length-5)); const R=g.an(lTz(),function(K){return K.loungeToken}),h=g.an(b,function(K){return K.loungeToken}); g.fr(h,function(K){return!g.iR(R,K)})&&aTz(); g.Iz("yt-remote-local-screens",b,31536E3)},gQ=function(b){b||(g.pk("yt-remote-session-screen-id"),g.pk("yt-remote-session-video-id")); GB();b=iB();g.G3(b,Up());N3n(b)},B3R=function(){if(!WB){const b=g.Mv(); b&&(WB=new g.Yd(b))}},HfR=function(){B3R(); return WB?!!WB.get("yt-remote-use-staging-server"):!1},SQ=function(b,R){g.sM[b]=!0; const h=g.hF();h&&h.publish.apply(h,arguments);g.sM[b]=!1},nF=function(){let b=window.navigator.userAgent.match(/Chrome\/([0-9]+)/); return b?parseInt(b[1],10):0},qVp=function(b){return!!document.currentScript&&(document.currentScript.src.indexOf("?"+b)!=-1||document.currentScript.src.indexOf("&"+b)!=-1)},d3z=function(){return typeof window.__onGCastApiAvailable=="function"?window.__onGCastApiAvailable:null},Ep=function(b){b.length?fTr(b.shift(),function(){Ep(b)}):TB()},TB=function(){let b=d3z(); b&&b(!1,"No cast extension found")},fTr=function(b,R,h){let K=document.createElement("script"); K.onerror=R;h&&(K.onload=h);g.vE(K,g.IA(b));(document.head||document.documentElement).appendChild(K)},yaz=function(b){return"chrome-extension://"+b+"/cast_sender.js"},tDn=function(){const b=nF(),R=[]; if(b>1){const h=b-1;R.push("//www.gstatic.com/eureka/clank/"+b+"/cast_sender.js");R.push("//www.gstatic.com/eureka/clank/"+h+"/cast_sender.js")}return R},JZ=function(){if(jZz){var b=2,R=d3z(),h=function(){b--; b==0&&R&&R(!0)}; window.__onGCastApiAvailable=h;fTr("//www.gstatic.com/cast/sdk/libs/sender/1.0/cast_framework.js",TB,h)}},Aaz=function(){JZ(); let b=tDn();b.push("//www.gstatic.com/eureka/clank/cast_sender.js");Ep(b)},zN3=function(){JZ(); let b=tDn();b.push(...ifn.map(yaz));b.push("//www.gstatic.com/eureka/clank/cast_sender.js");Ep(b)},kf=function(b,R,h){g.N3.call(this); this.J=h!=null?(0,g.Ms)(b,h):b;this.zk=R;this.S=(0,g.Ms)(this.au,this);this.G=!1;this.Y=0;this.X=this.i5=null;this.V=[]},Yf=function(){this.G=g.wK()},U3r=function(){eQ||(eQ=new Yf)},Ggn=function(){eQ||(eQ=new Yf)},Op=function(){g.av.call(this,"p")},Qn=function(){g.av.call(this,"o")},xf=function(){return glH=glH||new g.TD},WRR=function(b){g.av.call(this,"serverreachability",b)},mE=function(b){const R=xf(); R.dispatchEvent(new WRR(R,b))},SV2=function(b){g.av.call(this,"statevent",b)},PB=function(b){const R=xf(); R.dispatchEvent(new SV2(R,b))},nl2=function(b,R,h,K){g.av.call(this,"timingevent",b); this.size=R;this.rtt=h;this.retries=K},ZK=function(b,R){if(typeof b!=="function")throw Error("Fn must not be null and must be a function"); return g.JD.setTimeout(function(){b()},R)},cB=function(){},uB=function(b,R,h,K){this.X=b; this.V=R;this.Ty=h;this.PH=K||1;this.wp=new g.HP(this);this.xZ=45E3;this.SY=null;this.J=!1;this.U=this.Zr=this.K=this.vY=this.nR=this.KR=this.G6=null;this.C=[];this.G=null;this.D=0;this.S=this.T6=null;this.fR=-1;this.gp=!1;this.pR=0;this.NJ=null;this.RH=this.JX=this.CR=this.MJ=!1;this.Y=new El3},El3=function(){this.X=null; this.G="";this.Y=!1},Xs=function(b,R,h){b.vY=1; b.K=I9(R.clone());b.U=h;b.MJ=!0;T3H(b,null)},T3H=function(b,R){b.nR=Date.now(); Vn(b);b.Zr=b.K.clone();NO(b.Zr,"t",b.PH);b.D=0;const h=b.X.JX;b.Y=new El3;b.G=Ja3(b.X,h?R:null,!b.U);b.pR>0&&(b.NJ=new g.RP((0,g.Ms)(b.Rn,b,b.G),b.pR));b.wp.listen(b.G,"readystatechange",b.Zf);R=b.SY?g.$T(b.SY):{};b.U?(b.T6||(b.T6="POST"),R["Content-Type"]="application/x-www-form-urlencoded",b.G.send(b.Zr,b.T6,b.U,R)):(b.T6="GET",b.G.send(b.Zr,b.T6,null,R));mE(1)},YVU=function(b){if(!kg3(b))return g.x5(b.G); const R=g.mr(b.G);if(R==="")return"";let h="";const K=R.length,I=g.eS(b.G)==4;if(!b.Y.X){if(typeof TextDecoder==="undefined")return CF(b),MO(b),"";b.Y.X=new g.JD.TextDecoder}for(let N=0;NR.length)return rQ;R=R.slice(K,K+h);b.D=K+h;return R},Vn=function(b){b.KR=Date.now()+b.xZ; QZH(b,b.xZ)},QZH=function(b,R){if(b.G6!=null)throw Error("WatchDog timer not null"); b.G6=ZK((0,g.Ms)(b.Df,b),R)},LF=function(b){b.G6&&(g.JD.clearTimeout(b.G6),b.G6=null)},MO=function(b){b.X.r4()||b.gp||x33(b.X,b)},CF=function(b){LF(b); g.$l(b.NJ);b.NJ=null;b.wp.removeAll();if(b.G){const R=b.G;b.G=null;R.abort();R.dispose()}},sc=function(b,R){try{var h=b.X; if(h.cI!=0&&(h.G==b||wQ(h.Y,b)))if(!b.JX&&wQ(h.Y,b)&&h.cI==3){try{var K=h.HR.G.parse(R)}catch(v){K=null}if(Array.isArray(K)&&K.length==3){var I=K;if(I[0]==0)a:{if(!h.K){if(h.G)if(h.G.nR+3E30&&(h.pR=1.5*q);K=h;const d=b.H8();if(d){const t=g.Zg(d,"X-Client-Wire-Protocol");if(t){var N=K.Y;!N.G&&(g.yX(t,"spdy")||g.yX(t,"quic")||g.yX(t,"h2"))&&(N.V=N.S,N.G=new Set,N.Y&&(hv(N,N.Y),N.Y=null))}if(K.MJ){const S=g.Zg(d,"X-HTTP-Session-Id");S&&(K.Kh=S,g.$O(K.SY,K.MJ,S))}}h.cI=3;h.S&&h.S.Y3();h.FM&&(h.EW=Date.now()-b.nR);K=h;var p=b;K.m_=m3t(K,K.JX? K.Ty:null,K.Zl);if(p.JX){P4n(K.Y,p);var l=p,a=K.pR;a&&l.setTimeout(a);l.G6&&(LF(l),Vn(l));K.G=p}else Zft(K);h.X.length>0&&Kv(h)}else v[0]!="stop"&&v[0]!="close"||RO(h,7);else h.cI==3&&(v[0]=="stop"||v[0]=="close"?v[0]=="stop"?RO(h,7):h.disconnect():v[0]!="noop"&&h.S&&h.S.Gc(v),h.C=0)}mE(4)}catch(v){}},car=function(b){this.S=b||10; g.JD.PerformanceNavigationTiming?(b=g.JD.performance.getEntriesByType("navigation"),b=b.length>0&&(b[0].nextHopProtocol=="hq"||b[0].nextHopProtocol=="h2")):b=!!(g.JD.chrome&&g.JD.chrome.loadTimes&&g.JD.chrome.loadTimes()&&g.JD.chrome.loadTimes().wasFetchedViaSpdy);this.V=b?this.S:1;this.G=null;this.V>1&&(this.G=new Set);this.Y=null;this.X=[]},uCU=function(b){return b.Y?!0:b.G?b.G.size>=b.V:!1},b7=function(b){return b.Y?1:b.G?b.G.size:0},wQ=function(b,R){return b.Y?b.Y==R:b.G?b.G.has(R):!1},hv=function(b, R){b.G?b.G.add(R):b.Y=R},P4n=function(b,R){b.Y&&b.Y==R?b.Y=null:b.G&&b.G.has(R)&&b.G.delete(R)},$D=function(b){if(b.Y!=null)return b.X.concat(b.Y.C); if(b.G!=null&&b.G.size!==0){let R=b.X;for(const h of b.G.values())R=R.concat(h.C);return R}return g.Sc(b.X)},Xk3=function(b,R){const h=new cB; if(g.JD.Image){const K=new Image;K.onload=g.Lw(IO,h,"TestLoadImage: loaded",!0,R,K);K.onerror=g.Lw(IO,h,"TestLoadImage: error",!1,R,K);K.onabort=g.Lw(IO,h,"TestLoadImage: abort",!1,R,K);K.ontimeout=g.Lw(IO,h,"TestLoadImage: timeout",!1,R,K);g.JD.setTimeout(function(){if(K.ontimeout)K.ontimeout()},1E4); K.src=b}else R(!1)},VDn=function(b,R){const h=new cB,K=new AbortController,I=setTimeout(()=>{K.abort(); IO(h,"TestPingServer: timeout",!1,R)},1E4); fetch(b,{signal:K.signal}).then(N=>{clearTimeout(I);N.ok?IO(h,"TestPingServer: ok",!0,R):IO(h,"TestPingServer: server error",!1,R)}).catch(()=>{clearTimeout(I); IO(h,"TestPingServer: error",!1,R)})},IO=function(b,R,h,K,I){try{I&&(I.onload=null,I.onerror=null,I.onabort=null,I.ontimeout=null),K(h)}catch(N){}},C4t=function(){this.G=new Ni},pv=function(b,R,h){return h&&h.PN?h.PN[b]||R:R},MDz=function(b){this.X=[]; this.Ty=this.m_=this.SY=this.Zl=this.G=this.Kh=this.MJ=this.gp=this.D=this.CR=this.U=null;this.gB=this.Zr=0;this.s8=pv("failFast",!1,b);this.NJ=this.G6=this.K=this.J=this.S=null;this.Sn=!0;this.hc=this.vY=-1;this.PH=this.C=this.nR=0;this.K0=pv("baseRetryDelayMs",5E3,b);this.vD=pv("retryDelaySeedMs",1E4,b);this.wi=pv("forwardChannelMaxRetries",2,b);this.Ys=pv("forwardChannelRequestTimeoutMs",2E4,b);this.SK=b&&b.DUX||void 0;this.wB=b&&b.vVZ||void 0;this.ri=b&&b.asY||!1;this.pR=void 0;this.JX=b&&b.yF|| !1;this.V="";this.Y=new car(b&&b.eJ5);this.jn=Math.min(b&&b.XrH||1E3,1E3);this.HR=new C4t;this.wp=b&&b.SgZ||!1;this.KR=b&&b.YgX||!1;this.wp&&this.KR&&(this.KR=!1);this.K5=b&&b.b0v||!1;b&&b.AhX&&(this.Sn=!1);this.FM=!this.wp&&this.Sn&&b&&b.PjY||!1;this.pz=void 0;b&&b.mE&&b.mE>0&&(this.pz=b.mE);this.fR=void 0;this.EW=0;this.xZ=!1;this.RH=this.T6=null},o9=function(b){b.G&&(l7(b),b.G.cancel(),b.G=null)},rac=function(b){o9(b); b.K&&(g.JD.clearTimeout(b.K),b.K=null);Fs(b);b.Y.cancel();b.J&&(typeof b.J==="number"&&g.JD.clearTimeout(b.J),b.J=null)},Kv=function(b){uCU(b.Y)||b.J||(b.J=!0,g.Mq(b.Qo,b),b.nR=0)},wkr=function(b,R){if(b7(b.Y)>=b.Y.V-(b.J?1:0))return!1; if(b.J)return b.X=R.C.concat(b.X),!0;if(b.cI==1||b.cI==2||b.nR>=(b.s8?0:b.wi))return!1;b.J=ZK((0,g.Ms)(b.Qo,b,R),LRz(b,b.nR));b.nR++;return!0},olt=function(b,R){var h; R?h=R.Ty:h=b.Zr++;const K=b.SY.clone();g.$O(K,"SID",b.V);g.$O(K,"RID",h);g.$O(K,"AID",b.vY);aO(b,K);b.D&&b.U&&g.BP(K,b.D,b.U);h=new uB(b,b.V,h,b.nR+1);b.D===null&&(h.SY=b.U);R&&(b.X=R.C.concat(b.X));R=FRg(b,h,b.jn);h.setTimeout(Math.round(b.Ys*.5)+Math.round(b.Ys*.5*Math.random()));hv(b.Y,h);Xs(h,K,R)},aO=function(b,R){b.gp&&g.Z2(b.gp,function(h,K){g.$O(R,K,h)}); b.S&&g.Z2({},function(h,K){g.$O(R,K,h)})},FRg=function(b,R,h){h=Math.min(b.X.length,h); const K=b.S?(0,g.Ms)(b.S.q0,b.S,b):null;a:{var I=b.X;let l=-1;for(;;){const a=["count="+h];l==-1?h>0?(l=I[0].G,a.push("ofs="+l)):l=0:a.push("ofs="+l);let v=!0;for(let B=0;B=3)return!1; b.PH++;b.K=ZK((0,g.Ms)(b.kc,b),LRz(b,b.C));b.C++;return!0},l7=function(b){b.T6!=null&&(g.JD.clearTimeout(b.T6),b.T6=null)},D32=function(b){b.G=new uB(b,b.V,"rpc",b.PH); b.D===null&&(b.G.SY=b.U);b.G.pR=0;var R=b.m_.clone();g.$O(R,"RID","rpc");g.$O(R,"SID",b.V);g.$O(R,"AID",b.vY);g.$O(R,"CI",b.NJ?"0":"1");!b.NJ&&b.pz&&g.$O(R,"TO",b.pz);g.$O(R,"TYPE","xmlhttp");aO(b,R);b.D&&b.U&&g.BP(R,b.D,b.U);b.pR&&b.G.setTimeout(b.pR);var h=b.G;b=b.Ty;h.vY=1;h.K=I9(R.clone());h.U=null;h.MJ=!0;T3H(h,b)},Fs=function(b){b.G6!=null&&(g.JD.clearTimeout(b.G6),b.G6=null)},x33=function(b,R){var h=null; if(b.G==R){Fs(b);l7(b);b.G=null;var K=2}else if(wQ(b.Y,R))h=R.C,P4n(b.Y,R),K=1;else return;if(b.cI!=0)if(R.J)if(K==1){h=R.U?R.U.length:0;R=Date.now()-R.nR;var I=b.nR;K=xf();K.dispatchEvent(new nl2(K,h,R,I));Kv(b)}else Zft(b);else{var N=R.fR;I=R.getLastError();if(I==3||I==0&&N>0||!(K==1&&wkr(b,R)||K==2&&DK(b)))switch(h&&h.length>0&&(R=b.Y,R.X=R.X.concat(h)),I){case 1:RO(b,5);break;case 4:RO(b,10);break;case 3:RO(b,6);break;default:RO(b,2)}}},LRz=function(b,R){let h=b.K0+Math.floor(Math.random()*b.vD); b.isActive()||(h*=2);return h*R},RO=function(b,R){if(R==2){var h=(0,g.Ms)(b.lM,b),K=b.wB; const I=!K;K=new g.Fx(K||"//www.google.com/images/cleardot.gif");g.JD.location&&g.JD.location.protocol=="http"||g.o_(K,"https");I9(K);I?Xk3(K.toString(),h):VDn(K.toString(),h)}else PB(2);b.cI=0;b.S&&b.S.nK(R);bSU(b);rac(b)},bSU=function(b){b.cI=0; b.RH=[];if(b.S){const R=$D(b.Y);if(R.length!=0||b.X.length!=0)g.nr(b.RH,R),g.nr(b.RH,b.X),b.Y.X.length=0,g.Sc(b.X),b.X.length=0;b.S.Px()}},RQc=function(b){if(b.cI==0)return b.RH; let R=[];g.nr(R,$D(b.Y));g.nr(R,b.X);return R},m3t=function(b,R,h){var K=g.II(h); K.G!=""?(R&&g.Da(K,R+"."+K.G),g.bL(K,K.X)):(K=g.JD.location,K=MXU(K.protocol,R?R+"."+K.hostname:K.hostname,+K.port,h));R=b.MJ;h=b.Kh;R&&h&&g.$O(K,R,h);g.$O(K,"VER",b.tY);aO(b,K);return K},Ja3=function(b,R,h){if(R&&!b.JX)throw Error("Can't create secondary domain capable XhrIo object."); R=b.ri&&!b.SK?new g.ni(new g.CT({QQ:h})):new g.ni(b.SK);R.D=b.JX;return R},hQR=function(){},K7g=function(){},BT=function(b,R){g.TD.call(this); this.G=new MDz(R);this.J=b;this.Y=R&&R.wZ||null;b=R&&R.LS||null;R&&R.maY&&(b?b["X-Client-Protocol"]="webchannel":b={"X-Client-Protocol":"webchannel"});this.G.U=b;b=R&&R.eBR||null;R&&R.R5&&(b?b["X-WebChannel-Content-Type"]=R.R5:b={"X-WebChannel-Content-Type":R.R5});R&&R.lE&&(b?b["X-WebChannel-Client-Profile"]=R.lE:b={"X-WebChannel-Client-Profile":R.lE});this.G.CR=b;(b=R&&R.E46)&&!g.fj(b)&&(this.G.D=b);this.D=R&&R.yF||!1;this.S=R&&R.fPO||!1;(R=R&&R.fk)&&!g.fj(R)&&(this.G.MJ=R,g.wx(this.Y,R)&&(b=this.Y, R in b&&delete b[R]));this.X=new vT(this)},sSt=function(b){Op.call(this); b.__headers__&&(this.headers=b.__headers__,this.statusCode=b.__status__,delete b.__headers__,delete b.__status__);const R=b.__sm__;R?this.data=(this.G=g.Cr(R))?g.Kj(R,this.G):R:this.data=b},$5x=function(b){Qn.call(this); this.status=1;this.errorCode=b},vT=function(b){this.G=b},HT=function(b,R){this.V=b; this.G=R},qi=function(b,R){if(typeof b!=="function")throw Error("Fn must not be null and must be a function"); return g.JD.setTimeout(function(){b()},R)},fv=function(){dr.dispatchEvent(new IQ2)},yl=function(b,R,h,K){this.G=b; this.V=R;this.D=h;this.J=K||1;this.Y=45E3;this.X=new g.HP(this);this.S=new g.IG;this.S.setInterval(250)},pyr=function(b,R,h){b.wr=1; b.dU=I9(R.clone());b.kh=h;b.MJ=!0;Npz(b,null)},tv=function(b,R,h,K,I){b.wr=1; b.dU=I9(R.clone());b.kh=null;b.MJ=h;I&&(b.rb=!1);Npz(b,K)},Npz=function(b,R){b.e8=Date.now(); j3(b);b.LW=b.dU.clone();NO(b.LW,"t",b.J);b.fW=0;b.IU=b.G.Sl(b.G.LG()?R:null);b.VE>0&&(b.ev=new g.RP((0,g.Ms)(b.Tc,b,b.IU),b.VE));b.X.listen(b.IU,"readystatechange",b.zB);R=b.td?g.$T(b.td):{};b.kh?(b.OH="POST",R["Content-Type"]="application/x-www-form-urlencoded",b.IU.send(b.LW,b.OH,b.kh,R)):(b.OH="GET",b.rb&&!g.qN&&(R.Connection="close"),b.IU.send(b.LW,b.OH,null,R));b.G.OT(1)},aQU=function(b,R){var h=b.fW,K=R.indexOf("\n",h); if(K==-1)return Av;h=Number(R.substring(h,K));if(isNaN(h))return lQH;K+=1;if(K+h>R.length)return Av;R=R.slice(K,K+h);b.fW=K+h;return R},j3=function(b){b.lm=Date.now()+b.Y; v33(b,b.Y)},v33=function(b,R){if(b.Ju!=null)throw Error("WatchDog timer not null"); b.Ju=qi((0,g.Ms)(b.xS,b),R)},Bpr=function(b){b.Ju&&(g.JD.clearTimeout(b.Ju),b.Ju=null)},i7=function(b){b.G.r4()||b.E0||b.G.AN(b)},z8=function(b){Bpr(b); g.$l(b.ev);b.ev=null;b.S.stop();b.X.removeAll();if(b.IU){const R=b.IU;b.IU=null;R.abort();R.dispose()}b.FL&&(b.FL=null)},HSn=function(b,R){try{b.G.IW(b,R),b.G.OT(4)}catch(h){}},d5t=function(b,R,h,K,I){if(K==0)h(!1); else{var N=I||0;K--;qER(b,R,function(p){p?h(!0):g.JD.setTimeout(function(){d5t(b,R,h,K,N)},N)})}},qER=function(b,R,h){const K=new Image; K.onload=function(){try{Uc(K),h(!0)}catch(I){}}; K.onerror=function(){try{Uc(K),h(!1)}catch(I){}}; K.onabort=function(){try{Uc(K),h(!1)}catch(I){}}; K.ontimeout=function(){try{Uc(K),h(!1)}catch(I){}}; g.JD.setTimeout(function(){if(K.ontimeout)K.ontimeout()},R); K.src=b},Uc=function(b){b.onload=null; b.onerror=null;b.onabort=null;b.ontimeout=null},fQH=function(b){this.G=b; this.Y=new Ni},yKn=function(b){const R=G8(b.G,b.hD,"/mail/images/cleardot.gif"); I9(R);d5t(R.toString(),5E3,(0,g.Ms)(b.kF,b),3,2E3);b.OT(1)},WT=function(b){var R=b.G.J; R!=null?(fv(),R?(fv(),gr(b.G,b,!1)):(fv(),gr(b.G,b,!0))):(b.s_=new yl(b),b.s_.td=b.Bb,R=b.G,R=G8(R,R.LG()?b.Ws:null,b.Fj),fv(),NO(R,"TYPE","xmlhttp"),tv(b.s_,R,!1,b.Ws,!1))},S3=function(b,R,h){this.G=1; this.Y=[];this.X=[];this.S=new Ni;this.U=b||null;this.J=R!=null?R:null;this.K=h||!1},tdz=function(b,R){this.G=b; this.map=R;this.context=null},jSp=function(b,R,h,K){g.av.call(this,"timingevent",b); this.size=R;this.rtt=h;this.retries=K},AKx=function(b){g.av.call(this,"serverreachability",b)},iS3=function(b){b.pF(1,0); b.UH=G8(b,null,b.NR);nv(b)},zQU=function(b){b.RQ&&(b.RQ.abort(),b.RQ=null); b.iP&&(b.iP.cancel(),b.iP=null);b.Qg&&(g.JD.clearTimeout(b.Qg),b.Qg=null);Ec(b);b.tE&&(b.tE.cancel(),b.tE=null);b.bN&&(g.JD.clearTimeout(b.bN),b.bN=null)},T8=function(b,R){if(b.G==0)throw Error("Invalid operation: sending map when state is closed"); b.Y.push(new tdz(b.cw++,R));b.G!=2&&b.G!=3||nv(b)},U5p=function(b){let R=0; b.iP&&R++;b.tE&&R++;return R},nv=function(b){b.tE||b.bN||(b.bN=qi((0,g.Ms)(b.u2,b),0),b.rM=0)},g3c=function(b,R){if(b.G==1){if(!R){b.O0=Math.floor(Math.random()*1E5); R=b.O0++;const h=new yl(b,"",R);h.td=b.cM;const K=Jv(b),I=b.UH.clone();g.$O(I,"RID",R);g.$O(I,"CVER","1");kD(b,I);pyr(h,I,K);b.tE=h;b.G=2}}else b.G==3&&(R?GW3(b,R):b.Y.length==0||b.tE||GW3(b))},GW3=function(b,R){if(R)if(b.Q9>6){b.Y=b.X.concat(b.Y); b.X.length=0;var h=b.O0-1;R=Jv(b)}else h=R.D,R=R.kh;else h=b.O0++,R=Jv(b);const K=b.UH.clone();g.$O(K,"SID",b.V);g.$O(K,"RID",h);g.$O(K,"AID",b.HQ);kD(b,K);h=new yl(b,b.V,h,b.rM+1);h.td=b.cM;h.setTimeout(1E4+Math.round(1E4*Math.random()));b.tE=h;pyr(h,K,R)},kD=function(b,R){b.bR&&(b=b.bR.Bx())&&g.Z2(b,function(h,K){g.$O(R,K,h)})},Jv=function(b){const R=Math.min(b.Y.length,1E3),h=["count="+R]; let K;b.Q9>6&&R>0?(K=b.Y[0].G,h.push("ofs="+K)):K=0;for(let I=0;I=3)return!1; b.D++;b.Qg=qi((0,g.Ms)(b.h4,b),SEt(b,b.NH));b.NH++;return!0},gr=function(b,R,h){b.po=b.J==null?h:!b.J; b.D5=R.kY;b.K||iS3(b)},Ec=function(b){b.P2!=null&&(g.JD.clearTimeout(b.P2),b.P2=null)},SEt=function(b,R){let h=5E3+Math.floor(Math.random()*1E4); b.isActive()||(h*=2);return h*R},e3=function(b,R){if(R==2||R==9){var h=null; b.bR&&(h=null);var K=(0,g.Ms)(b.VF,b);h||(h=new g.Fx("//www.google.com/images/cleardot.gif"),I9(h));qER(h.toString(),1E4,K)}else fv();n3z(b,R)},n3z=function(b,R){b.G=0; b.bR&&b.bR.vx(R);E3r(b);zQU(b)},E3r=function(b){b.G=0; b.D5=-1;if(b.bR)if(b.X.length==0&&b.Y.length==0)b.bR.Hb();else{const R=g.Sc(b.X),h=g.Sc(b.Y);b.X.length=0;b.Y.length=0;b.bR.Hb(R,h)}},G8=function(b,R,h){let K=g.II(h); if(K.G!="")R&&g.Da(K,R+"."+K.G),g.bL(K,K.X);else{const I=window.location;K=MXU(I.protocol,R?R+"."+I.hostname:I.hostname,+I.port,h)}b.wU&&g.Z2(b.wU,function(I,N){g.$O(K,N,I)}); g.$O(K,"VER",b.Q9);kD(b,K);return K},Tp3=function(){},JKz=function(){this.G=[]; this.Y=[]},kW2=function(b,R){this.action=b; this.params=R||{}},Oc=function(b,R){g.N3.call(this); this.G=new g.bI(this.ib,0,this);g.n(this,this.G);this.zk=5E3;this.retryCount=this.Az=0;if(typeof b==="function")R&&(b=(0,g.Ms)(b,R));else if(b&&typeof b.handleEvent==="function")b=(0,g.Ms)(b.handleEvent,b);else throw Error("Invalid listener argument");this.Y=b},Ql=function(b,R,h=!1,K=()=>"",I=!1,N=!1,p=!1,l=()=>g.Xp({}),a=!1,v,B){this.JX=b; this.nR=R;this.D=new g.kd;this.J=B;this.Y=(this.X=!!v)?v(()=>{this.ek()}):new Oc(this.ek,this); this.G=null;this.U=!1;this.C=null;this.MJ="";this.T6=this.G6=0;this.V=[];this.fR=h;this.SY=K;this.K=N;this.vY=l;this.CR=p;this.gp=null;this.S=g.Xp();this.RH=I;this.wp=a;this.xZ=new YEz;this.NJ=new eQz;this.KR=new OSt;this.pR=new QSR;this.Zr=new x5x;this.PH=new m5z;this.Ty=new PVt},ZS3=function(b,R,h,K,I){xD(b); if(b.G){const N=g.x("ID_TOKEN"),p=b.G.cM||{};N?p["x-youtube-identity-token"]=N:delete p["x-youtube-identity-token"];b.G.cM=p}K?(K.getState()!=3&&U5p(K)==0||K.getState(),b.G.connect(R,h,b.nR,K.V,K.HQ)):I?b.G.connect(R,h,b.nR,I.sessionId,I.arrayId):b.G.connect(R,h,b.nR);b.X&&!b.Y.isActive()&&b.Y.start();b.J&&b.J.VS5()},uac=function(b,R){return b.wp?!Object.values(cKn).includes(R):!1},Xyc=async function(b){try{await mG(b)}finally{var R=b.V; b.V=[];var h=R;R=R.length;for(let K=0;K{if(b.G){let h=b.G.cM||{}; R&&Object.keys(R).length>0?h={...h,...R}:delete h.Authorization;b.G.cM=h}}).xb(()=>{}),()=>{b.gp=null})},ZJ=function(b){this.scheme="https"; this.port=this.domain="";this.G="/api/lounge";this.Y=!0;b=b||document.location.href;const R=Number(g.ai(b)[4]||null)||"";R&&(this.port=":"+R);this.domain=g.B6(b)||"";b=g.zK();b.search("MSIE")>=0&&(b=b.match(/MSIE ([\d.]+)/)[1],g.A_(b,"10.0")<0&&(this.Y=!1))},cT=function(b,R){let h=b.G; b.Y&&(h=b.scheme+"://"+b.domain+b.port+b.G);return g.z9(h+R,{})},CVp=function(b){g.jy(b.channel,"m",()=>{b.J=3; b.X.reset();b.K=null;b.D=0;for(const R of b.C)b.channel&&b.channel.send(R);b.C=[];b.publish("webChannelOpened");b.SY.G("WEB_CHANNEL")}); g.jy(b.channel,"n",()=>{b.J=0;b.X.isActive()||b.publish("webChannelClosed");const R=b.channel?.V().X();R&&(b.C=[...R]);b.T6.G("WEB_CHANNEL")}); g.jy(b.channel,"p",R=>{const h=R.data;h[0]==="gracefulReconnect"?(b.X.start(),b.channel&&b.channel.close()):b.publish("webChannelMessage",new kW2(h[0],h[1]));b.g4=R.statusCode;b.gp.G("WEB_CHANNEL")}); g.jy(b.channel,"o",()=>{b.g4===401||b.X.start();b.publish("webChannelError");b.MJ.G("WEB_CHANNEL","")})},u7=function(b){const R=b.nR(); R?b.V["x-youtube-lounge-xsrf-token"]=R:delete b.V["x-youtube-lounge-xsrf-token"]},wyH=function(b,R,h=()=>"",K,I){const N=()=>new Ql(cT(b,"/bc"),R,!1,h,K); return g.cg("enable_mdx_web_channel_desktop")?new Mdz(()=>new rKx(cT(b,"/wc"),R,h)):new L73(N,I)},b23=function(){var b=F7g; o33();X0.push(b);D5c()},Vl=function(b,R){o33(); const h=Rfn(b,String(R));X0.length==0?hfn(h):(D5c(),g.pr(X0,function(K){K(h)}))},Cv=function(b){Vl("CP",b)},o33=function(){X0||(X0=g.YB("yt.mdx.remote.debug.handlers_")||[],g.kB("yt.mdx.remote.debug.handlers_",X0))},hfn=function(b){const R=(Mi+1)%50; Mi=R;rr[R]=b;Lv||(Lv=R==49)},D5c=function(){var b=X0; if(rr[0]){var R=Lv?Mi:-1;do{R=(R+1)%50;const h=rr[R];g.pr(b,function(K){K(h)})}while(R!=Mi); rr=Array(50);Mi=-1;Lv=!1}},Rfn=function(b,R){let h=(Date.now()-KtR)/1E3; h.toFixed&&(h=h.toFixed(3));const K=[];K.push("[",h+"s","] ");K.push("[","yt.mdx.remote","] ");K.push(b+": "+R,"\n");return K.join("")},wr=function(b){g.NU.call(this); this.J=b;this.screens=[]},sUU=function(b,R){const h=b.get(R.uuid)||b.get(R.id); if(h)return b=h.name,h.id=R.id||h.id,h.name=R.name,h.token=R.token,h.uuid=R.uuid||h.uuid,h.name!=b;b.screens.push(R);return!0},$T3=function(b,R){let h=b.screens.length!=R.length; b.screens=g.lR(b.screens,function(I){return!!jQ(R,I)}); const K=R.length;for(let I=0;I0&&b.VR.idType!="shortLived"); g.Iz("yt-remote-automatic-screen-cache",g.an(b,RN3))},I3=function(b){b.S=g.NC("yt-remote-device-id-map")||{}},N7=function(b,R,h){g.NU.call(this); this.MJ=h;this.V=b;this.Y=R;this.G=null},p$=function(b,R){b.G=R; b.publish("sessionScreen",b.G)},tGr=function(b,R){b.G&&(b.G.token=R,$L(b.V,b.G)); b.publish("sessionScreen",b.G)},lc=function(b,R){Vl(b.MJ,R)},Aor=function(b,R){g.m8(b.G6); b.G6=0;R?b.config_.enableCastLoungeToken&&R.loungeToken?R.deviceId?b.G&&b.G.uuid==R.deviceId||(R.loungeTokenRefreshIntervalMs?jUc(b,{name:b.Y.friendlyName,screenId:R.screenId,loungeToken:R.loungeToken,dialId:R.deviceId,screenIdType:"shortLived"},R.loungeTokenRefreshIntervalMs):(g.qc(Error(`No loungeTokenRefreshIntervalMs presents in mdxSessionStatusData: ${JSON.stringify(R)}.`)),a3(b,R.screenId))):(g.qc(Error(`No device id presents in mdxSessionStatusData: ${JSON.stringify(R)}.`)),a3(b,R.screenId)): a3(b,R.screenId):b.N8(Error("Waiting for session status timed out."))},i2H=function(b){g.m8(b.U); b.U=0;g.m8(b.D);b.D=0;g.m8(b.G6);b.G6=0;g.m8(b.S);b.S=0;g.m8(b.K);b.K=0},zf3=function(b,R){b.info("sendYoutubeMessage_: "+R+" "+g.z1()); const h={};h.type=R;b.X?b.X.sendMessage("urn:x-cast:com.google.youtube.mdx",h,()=>{},(0,g.Ms)(function(){lc(this,"Failed to send message: "+R+".")},b)):lc(b,"Sending yt message without session: "+g.z1(h))},Gkg=function(b){zf3(b,"getLoungeToken"); g.m8(b.S);b.S=g.QB(()=>{UTt(b,null)},3E4)},vh=function(b,R){g.m8(b.K); b.K=0;R==0?Gkg(b):b.K=g.QB(()=>{Gkg(b)},R)},UTt=function(b,R){g.m8(b.S); b.S=0;let h=null;R?R.loungeToken?b.G?.token==R.loungeToken&&(h="staleLoungeToken"):h="missingLoungeToken":h="noLoungeTokenResponse";h?(b.info("Did not receive a new lounge token in onLoungeToken_ with "+`data: ${JSON.stringify(R)}, error: ${h}`),vh(b,3E4)):(tGr(b,R.loungeToken),vh(b,R.loungeTokenRefreshIntervalMs))},a3=function(b,R){R?(b.info("onConnectedScreenId_: Received screenId: "+R),b.G&&b.G.id==R||b.gp(R,h=>{p$(b,h)},()=>b.N8(),5)):b.N8(Error("Waiting for session status timed out."))},gWr= function(b,R,h,K){g.m8(b.D); b.D=0;qhU(b.V,R,I=>{I||K<0?h(I):b.D=g.QB(()=>{gWr(b,R,h,K-1)},300)})},jUc=function(b,R,h){b.info(`onConnectedScreenData_: Received screenData: ${JSON.stringify(R)}`); const K=new qO(R);gWr(b,K,I=>{I?($L(b.V,K),p$(b,K),vh(b,h)):(g.qc(Error(`CastSession, RemoteScreen from screenData: ${JSON.stringify(R)} is not online.`)),b.N8())},5)},Bh=function(b){return new Promise(R=>{b.nR=tZ(); if(b.SY){const h=new chrome.cast.DialLaunchResponse(!0,Wtx(b));R(h);Shc(b)}else b.C=()=>{g.m8(b.G6);b.C=()=>{}; b.G6=NaN;const h=new chrome.cast.DialLaunchResponse(!0,Wtx(b));R(h);Shc(b)},b.G6=g.QB(()=>{b.C()},100)})},nWz=function(b){g.m8(b.D); b.D=0;g.m8(b.K);b.K=0;b.S();b.S=()=>{}; g.m8(b.G6)},Hh=function(b){return!(!b.config_.enableDialLoungeToken||!b.X?.getDialAppInfo)},q7=function(b,R){b.info(`getDialAppInfoWithTimeout_ ${R}`); Hh(b)&&(g.m8(b.K),b.K=0,R==0?EWp(b):b.K=g.QB(()=>{EWp(b)},R))},Shc=function(b){b.S=b.V.Fm(b.nR,b.Y.label,b.Y.friendlyName,Hh(b),(R,h)=>{b.S=()=>{}; p$(b,R);R.idType=="shortLived"&&h>0&&q7(b,h)},R=>{b.S=()=>{}; b.N8(R)})},Wtx=function(b){var R={}; R.pairingCode=b.nR;R.theme=b.vY;HfR()&&(R.env_useStageMdx=1);return g.il(R)},TaR=function(b,R){const h=b.U.receiver.label,K=b.Y.friendlyName; return(new Promise(I=>{Bag(b.V,h,R,K,N=>{N&&N.token&&p$(b,N);I(N)},N=>{lc(b,"Failed to get DIAL screen: "+N); I(null)})})).then(I=>I&&I.token?new chrome.cast.DialLaunchResponse(!1):Bh(b))},kkt=function(b,R,h){b.info(`initOnConnectedScreenDataPromise_: Received screenData: ${JSON.stringify(R)}`); const K=new qO(R);return(new Promise(I=>{Jo2(b,K,N=>{N?($L(b.V,K),p$(b,K),q7(b,h)):g.qc(Error(`DialSession, RemoteScreen from screenData: ${JSON.stringify(R)} is not online.`));I(N)},5)})).then(I=>I?new chrome.cast.DialLaunchResponse(!1):Bh(b))},Jo2=function(b,R,h,K){g.m8(b.D); b.D=0;qhU(b.V,R,I=>{I||K<0?h(I):b.D=g.QB(()=>{Jo2(b,R,h,K-1)},300)})},EWp=function(b){Hh(b)&&b.X.getDialAppInfo(R=>{b.info(`getDialAppInfo dialLaunchData: ${JSON.stringify(R)}`); R=R.extraData||{};let h=null;R.loungeToken?b.G?.token==R.loungeToken&&(h="staleLoungeToken"):h="missingLoungeToken";h?q7(b,3E4):(tGr(b,R.loungeToken),q7(b,R.loungeTokenRefreshIntervalMs))},R=>{b.info(`getDialAppInfo error: ${R}`); q7(b,3E4)})},F7g=function(b){window.chrome&&chrome.cast&&chrome.cast.logMessage&&chrome.cast.logMessage(b)},ef3=function(b){const R=b.Y.A4(); let h=b.G&&b.G.Y;b=g.an(R,function(K){h&&dQ(K,h.label)&&(h=null);const I=K.uuid?K.uuid:K.id;let N=Yhg(this,K);N?(N.label=I,N.friendlyName=K.name):(N=new chrome.cast.Receiver(I,K.name),N.receiverType=chrome.cast.ReceiverType.CUSTOM);return N},b); h&&(h.receiverType!=chrome.cast.ReceiverType.CUSTOM&&(h=new chrome.cast.Receiver(h.label,h.friendlyName),h.receiverType=chrome.cast.ReceiverType.CUSTOM),b.push(h));return b},dN=function(b){return b.K||!!b.X.length||!!b.G},f$=function(b){Vl("Controller",b)},y_=function(b,R,h){R!=b.G&&(g.$l(b.G),(b.G=R)?(h?b.publish("yt-remote-cast2-receiver-resumed",R.Y):b.publish("yt-remote-cast2-receiver-selected",R.Y),R.subscribe("sessionScreen",(0,g.Ms)(b.G6,b,R)),R.subscribe("sessionFailed",()=>O2r(b,R)),R.G? b.publish("yt-remote-cast2-session-change",R.G):h&&b.G.J(null)):b.publish("yt-remote-cast2-session-change",null))},Yhg=function(b,R){return R?g.jc(b.X,function(h){return dQ(R,h.label)},b):null},O2r=function(b,R){b.G==R&&b.publish("yt-remote-cast2-session-failed")},cop=function(b,R,h,K){K.disableCastApi?td("Cannot initialize because disabled by Mdx config."):QUp()?xTx(R,K)&&(jN(!0),window.chrome&&chrome.cast&&chrome.cast.isAvailable?mTn(b,h):(window.__onGCastApiAvailable=function(I,N){I?mTn(b,h):(Ad("Failed to load cast API: "+ N),ic(!1),jN(!1),g.pk("yt-remote-cast-available"),g.pk("yt-remote-cast-receiver"),PXt(),h(!1))},K.loadCastApiSetupScript?g.l$(Z2t):window.navigator.userAgent.indexOf("Android")>=0&&window.navigator.userAgent.indexOf("Chrome/")>=0&&window.navigator.presentation?nF()>=60&&Aaz():!window.chrome||!window.navigator.presentation||window.navigator.userAgent.indexOf("Edge")>=0?TB():nF()>=89?zN3():(JZ(),Ep(ifn.map(yaz))))):td("Cannot initialize because not running Chrome")},PXt=function(){td("dispose"); const b=zy();b&&b.dispose();g.kB("yt.mdx.remote.cloudview.instance_",null);uEt(!1);g.Nt(US);US.length=0},Gy=function(){return!!g.NC("yt-remote-cast-installed")},X9c=function(){const b=g.NC("yt-remote-cast-receiver"); return b?b.friendlyName:null},VGH=function(){td("clearCurrentReceiver"); g.pk("yt-remote-cast-receiver")},CXH=function(){return Gy()?zy()?zy().getCastSession():(Ad("getCastSelector: Cast is not initialized."),null):(Ad("getCastSelector: Cast API is not installed!"),null)},Wh=function(){Gy()?zy()?gN()?(td("Requesting cast selector."),zy().requestSession()):(td("Wait for cast API to be ready to request the session."),US.push(g.Iq("yt-remote-cast2-api-ready",Wh))):Ad("requestCastSelector: Cast is not initialized."):Ad("requestCastSelector: Cast API is not installed!")},SN= function(b,R){gN()?zy().setConnectedScreenStatus(b,R):Ad("setConnectedScreenStatus called before ready.")},QUp=function(){var b=g.zK().search(/ (CrMo|Chrome|CriOS)\//)>=0; return g.I5||b},MGU=function(b,R){zy().init(b,R)},xTx=function(b,R){let h=!1; zy()||(b=new n$(b,R),b.subscribe("yt-remote-cast2-availability-change",function(K){g.Iz("yt-remote-cast-available",K);SQ("yt-remote-cast2-availability-change",K)}),b.subscribe("yt-remote-cast2-receiver-selected",function(K){td("onReceiverSelected: "+K.friendlyName); g.Iz("yt-remote-cast-receiver",K);SQ("yt-remote-cast2-receiver-selected",K)}),b.subscribe("yt-remote-cast2-receiver-resumed",function(K){td("onReceiverResumed: "+K.friendlyName); g.Iz("yt-remote-cast-receiver",K);SQ("yt-remote-cast2-receiver-resumed",K)}),b.subscribe("yt-remote-cast2-session-change",function(K){td("onSessionChange: "+fF(K)); K||g.pk("yt-remote-cast-receiver");SQ("yt-remote-cast2-session-change",K)}),g.kB("yt.mdx.remote.cloudview.instance_",b),h=!0); td("cloudview.createSingleton_: "+h);return h},zy=function(){return g.YB("yt.mdx.remote.cloudview.instance_")},mTn=function(b,R){ic(!0); jN(!1);MGU(b,function(h){h?(uEt(!0),g.pQ("yt-remote-cast2-api-ready")):(Ad("Failed to initialize cast API."),ic(!1),g.pk("yt-remote-cast-available"),g.pk("yt-remote-cast-receiver"),PXt());R(h)})},td=function(b){Vl("cloudview",b)},Ad=function(b){Vl("cloudview",b)},ic=function(b){td("setCastInstalled_ "+b); g.Iz("yt-remote-cast-installed",b)},gN=function(){return!!g.YB("yt.mdx.remote.cloudview.apiReady_")},uEt=function(b){td("setApiReady_ "+b); g.kB("yt.mdx.remote.cloudview.apiReady_",b)},jN=function(b){g.kB("yt.mdx.remote.cloudview.initializing_",b)},ES=function(b){this.index=-1; this.videoId=this.listId="";this.volume=this.playerState=-1;this.muted=!1;this.audioTrackId=null;this.S=this.J=0;this.trackData=null;this.hasNext=this.hasPrevious=!1;this.loadedTime=this.X=this.D=this.Y=0;this.G=NaN;this.V=!1;this.reset(b)},Ty=function(b){b.audioTrackId=null; b.trackData=null;b.playerState=-1;b.hasPrevious=!1;b.hasNext=!1;b.J=0;b.S=g.wK();b.Y=0;b.D=0;b.X=0;b.loadedTime=0;b.G=NaN;b.V=!1},Jd=function(b){return b.isPlaying()?(g.wK()-b.S)/1E3:0},kL=function(b,R){b.J=R; b.S=g.wK()},YL=function(b){switch(b.playerState){case 1:case 1081:return(g.wK()-b.S)/1E3+b.J; case -1E3:return 0}return b.J},rox=function(b){return b.V?b.D+Jd(b):b.D},eN=function(b,R,h){const K=b.videoId; b.videoId=R;b.index=h;R!=K&&Ty(b)},OS=function(b){const R={}; R.index=b.index;R.listId=b.listId;R.videoId=b.videoId;R.playerState=b.playerState;R.volume=b.volume;R.muted=b.muted;R.audioTrackId=b.audioTrackId;R.trackData=g.IT(b.trackData);R.hasPrevious=b.hasPrevious;R.hasNext=b.hasNext;R.playerTime=b.J;R.playerTimeAt=b.S;R.seekableStart=b.Y;R.seekableEnd=b.D;R.duration=b.X;R.loadedTime=b.loadedTime;R.liveIngestionTime=b.G;return R},Ltt=function(b){g.pr("nowAutoplaying autoplayDismissed remotePlayerChange remoteQueueChange autoplayModeChange autoplayUpNext previousNextChange multiStateLoopEnabled loopModeChange".split(" "), function(R){this.D.push(this.V.subscribe(R,g.Lw(this.JX,R),this))},b)},Q_=function(b,R){b.Y&&(b.Y.removeUpdateListener(b.C),b.Y.removeMediaListener(b.U),b.J(null)); b.Y=R;b.Y&&(Cv("Setting cast session: "+b.Y.sessionId),b.Y.addUpdateListener(b.C),b.Y.addMediaListener(b.U),b.Y.media.length&&b.J(b.Y.media[0]))},xL=function(b){return new ES(b.V.getPlayerContextData())},mm=function(b){return b.getState()==1},Zh=function(b,R,h){return(0,g.Ms)(function(K){this.t9("Failed to "+R+" with cast v2 channel. Error code: "+K.code); K.code!=chrome.cast.ErrorCode.TIMEOUT&&(this.t9("Retrying "+R+" using MDx browser channel."),Ph(this,R,h))},b)},Ph=function(b,R,h){b.V.sendMessage(R,h)},uc=function(b,R,h){const K=xL(b); kL(K,h);K.playerState!=-1E3&&(K.playerState=R);ch(b,K)},Xm=function(b,R){var h=b.S; h.G.length+h.Y.length<50&&b.S.enqueue(R)},ch=function(b,R){w9z(b); b.V.setPlayerContextData(OS(R));Ltt(b)},w9z=function(b){g.pr(b.D,function(R){this.V.unsubscribeByKey(R)},b); b.D.length=0},FtH=function(b){const R=b.G.media,h=b.G.customData; if(R&&h){var K=xL(b);R.contentId!=K.videoId&&Cv("Cast changing video to: "+R.contentId);K.videoId=R.contentId;K.playerState=h.playerState;kL(K,b.G.getEstimatedTime());ch(b,K)}else Cv("No cast media video. Ignoring state update.")},oWz=function(b){V_("Channel opened"); b.gp&&(b.gp=!1,C$(b),b.MJ=g.QB(()=>{V_("Timing out waiting for a screen.");b.D(1)},15E3))},aG2=function(b,R){R=R.message; R.params?V_("Received: action="+R.action+", params="+g.z1(R.params)):V_("Received: action="+R.action+" {}");switch(R.action){case "loungeStatus":R=lB(R.params.devices);b.X=g.an(R,function(K){return new HB(K)}); R=!!g.jc(b.X,function(K){return K.type=="LOUNGE_SCREEN"}); DTz(b,R);R=b.Zr("mlm");b.publish("multiStateLoopEnabled",R);break;case "loungeScreenDisconnected":g.gx(b.X,function(K){return K.type=="LOUNGE_SCREEN"}); DTz(b,!1);break;case "remoteConnected":let h=new HB(lB(R.params.device));g.jc(b.X,function(K){return K.equals(h)})||VXz(b.X,h); break;case "remoteDisconnected":h=new HB(lB(R.params.device));g.gx(b.X,function(K){return K.equals(h)}); break;case "gracefulDisconnect":break;case "playlistModified":bUc(b,R,"QUEUE_MODIFIED");break;case "nowPlaying":R7c(b,R);break;case "onStateChange":h7z(b,R);break;case "onAdStateChange":K2c(b,R);break;case "onVolumeChanged":svz(b,R);break;case "onSubtitlesTrackChanged":$qc(b,R);break;case "nowAutoplaying":IGt(b,R);break;case "autoplayDismissed":b.publish("autoplayDismissed");break;case "autoplayUpNext":Nqn(b,R);break;case "onAutoplayModeChanged":pjp(b,R);break;case "onHasPreviousNextChanged":lGt(b, R);break;case "requestAssistedSignIn":b.publish("assistedSignInRequested",R.params.authCode);break;case "onLoopModeChanged":b.publish("loopModeChange",R.params.loopMode);break;default:V_("Unrecognized action: "+R.action)}},V_=function(b){Vl("conn",b)},vXz=function(b){b.J=g.QB(()=>{V_("Connecting timeout"); b.D(1)},2E4)},M7=function(b,R){b.publish("proxyStateChange",R)},rN=function(b){g.m8(b.J); b.J=NaN},L$=function(b){g.m8(b.T6); b.T6=NaN},C$=function(b){g.m8(b.MJ); b.MJ=NaN},Bqx=function(b){return g.jc(b.X,function(R){return R.type=="LOUNGE_SCREEN"})},wN=function(b,R,h){h?V_("Sending: action="+R+", params="+g.z1(h)):V_("Sending: action="+R); b.Y.sendMessage(R,h)},HU3=function(b){L$(b); b.T6=g.QB(()=>{wN(b,"getNowPlaying")},2E4)},qqp=function(b){g.m8(b.C); b.C=g.QB(()=>{b.D(1)},864E5)},DTz=function(b,R){var h=null; if(R){const K=Bqx(b);K&&(h={clientName:K.clientName,deviceMake:K.brand,deviceModel:K.model,osVersion:K.osVersion})}g.kB("yt.mdx.remote.remoteClient_",h);R&&(rN(b),C$(b));h=b.Y.m6()&&isNaN(b.J);R==h?R&&(M7(b,1),wN(b,"getSubtitlesTrack")):R?(b.NJ()&&b.G.reset(),M7(b,1),wN(b,"getNowPlaying"),qqp(b)):b.D(1)},$qc=function(b,R){const h=R.params.videoId; delete R.params.videoId;h==b.G.videoId&&(g.RT(R.params)?b.G.trackData=null:b.G.trackData=R.params,b.publish("remotePlayerChange"))},bUc=function(b,R,h){const K=R.params.videoId||R.params.video_id,I=parseInt(R.params.currentIndex,10); b.G.listId=R.params.listId||b.G.listId;eN(b.G,K,I);b.publish("remoteQueueChange",h)},h7z=function(b,R){var h=parseInt(R.params.currentTime||R.params.current_time,10); kL(b.G,isNaN(h)?0:h);h=parseInt(R.params.state,10);h=isNaN(h)?-1:h;h==-1&&b.G.playerState==-1E3&&(h=-1E3);b.G.playerState=h;h=Number(R.params.loadedTime);b.G.loadedTime=isNaN(h)?0:h;b.G.Fr(Number(R.params.duration));h=b.G;var K=Number(R.params.liveIngestionTime);h.G=K;h.V=isNaN(K)?!1:!0;h=b.G;K=Number(R.params.seekableStartTime);R=Number(R.params.seekableEndTime);h.Y=isNaN(K)?0:K;h.D=isNaN(R)?0:R;b.G.playerState==1?HU3(b):L$(b);b.publish("remotePlayerChange")},R7c=function(b,R){R.params=R.params|| {}; bUc(b,R,"NOW_PLAYING_MAY_CHANGE");h7z(b,R);b.publish("autoplayDismissed")},K2c=function(b,R){if(b.G.playerState!=-1E3){var h=1085; switch(parseInt(R.params.adState,10)){case 1:h=1081;break;case 2:h=1084;break;case 0:h=1083}b.G.playerState=h;R=parseInt(R.params.currentTime,10);kL(b.G,isNaN(R)?0:R);b.publish("remotePlayerChange")}},svz=function(b,R){const h=R.params.muted=="true"; b.G.volume=parseInt(R.params.volume,10);b.G.muted=h;b.publish("remotePlayerChange")},IGt=function(b,R){b.K=R.params.videoId; b.publish("nowAutoplaying",parseInt(R.params.timeout,10))},Nqn=function(b,R){b.K=R.params.videoId||null; b.publish("autoplayUpNext",b.K)},pjp=function(b,R){b.S=R.params.autoplayMode; b.publish("autoplayModeChange",b.S);b.S=="DISABLED"&&b.publish("autoplayDismissed")},lGt=function(b,R){const h=R.params.hasNext=="true"; b.G.hasPrevious=R.params.hasPrevious=="true";b.G.hasNext=h;b.publish("previousNextChange")},tyz=function(b,R){B3R(); if(!WB||!WB.get("yt-remote-disable-remote-module-for-dev")){R=g.x("MDX_CONFIG")||R;$3R();GB();Fm||(Fm=new ZJ(R?R.loungeApiHost:void 0),HfR()&&(Fm.G="/api/loungedev"));o3||(o3=g.YB("yt.mdx.remote.deferredProxies_")||[],g.kB("yt.mdx.remote.deferredProxies_",o3));dqr();var h=Dh();if(!h){const I=new sS(Fm,R?R.disableAutomaticScreenCache||!1:!1);g.kB("yt.mdx.remote.screenService_",I);h=Dh();var K={};R&&(K={appId:R.appId,disableDial:R.disableDial,theme:R.theme,loadCastApiSetupScript:R.loadCastApiSetupScript, disableCastApi:R.disableCastApi,enableDialLoungeToken:R.enableDialLoungeToken,enableCastLoungeToken:R.enableCastLoungeToken,forceMirroring:R.forceMirroring});g.kB("yt.mdx.remote.enableConnectWithInitialState_",R?R.enableConnectWithInitialState||!1:!1);cop(b,I,function(N){N?be()&&SN(be(),"YouTube TV"):I.subscribe("onlineScreenChange",function(){SQ("yt-remote-receiver-availability-change")})},K)}R&&!g.YB("yt.mdx.remote.initialized_")&&(g.kB("yt.mdx.remote.initialized_",!0),RW("Initializing: "+g.z1(R)), hI.push(g.Iq("yt-remote-cast2-api-ready",function(){SQ("yt-remote-api-ready")})),hI.push(g.Iq("yt-remote-cast2-availability-change",function(){SQ("yt-remote-receiver-availability-change")})),hI.push(g.Iq("yt-remote-cast2-receiver-selected",function(){Kb(null); SQ("yt-remote-auto-connect","cast-selector-receiver")})),hI.push(g.Iq("yt-remote-cast2-receiver-resumed",function(){SQ("yt-remote-receiver-resumed","cast-selector-receiver")})),hI.push(g.Iq("yt-remote-cast2-session-change",fGU)),hI.push(g.Iq("yt-remote-connection-change",function(I){I?SN(be(),"YouTube TV"):s_()||(SN(null,null),VGH())})),hI.push(g.Iq("yt-remote-cast2-session-failed",()=>{SQ("yt-remote-connection-failed")})),b=$e(),R.isAuto&&(b.id+="#dial"),K=R.capabilities||[],K.length>0&&(b.capabilities= K),b.name=R.device,b.app=R.app,(R=R.theme)&&(b.theme=R),RW(" -- with channel params: "+g.z1(b)),b?(g.Iz("yt-remote-session-app",b.app),g.Iz("yt-remote-session-name",b.name)):(g.pk("yt-remote-session-app"),g.pk("yt-remote-session-name")),g.kB("yt.mdx.remote.channelParams_",b),h.start(),be()||yY2())}},jvn=function(){var b=Dh().Ui.$_gos(); const R=IW();R&&No()&&(jQ(b,R)||b.push(R));return sZR(b)},pb=function(){let b=AYR(); !b&&Gy()&&X9c()&&(b={key:"cast-selector-receiver",name:X9c()});return b},AYR=function(){const b=jvn(); let R=IW();R||(R=s_());return g.jc(b,function(h){return R&&dQ(R,h.key)?!0:!1})},IW=function(){const b=be(); if(!b)return null;const R=Dh().Rw();return AZ(R,b)},fGU=function(b){RW("remote.onCastSessionChange_: "+fF(b)); if(b){var R=IW();if(R&&R.id==b.id){if(SN(R.id,"YouTube TV"),b.idType=="shortLived"&&(b=b.token))le&&(le.token=b),(R=No())&&R.VZ(b)}else R&&aW(),vf(b,1)}else No()&&aW()},aW=function(){gN()?zy().stopSession():Ad("stopSession called before API ready."); const b=No();b&&(b.disconnect(1),Bf(null))},Hf=function(){const b=No(); return!!b&&b.getProxyState()!=3},RW=function(b){Vl("remote",b)},Dh=function(){if(!qo){const b=g.YB("yt.mdx.remote.screenService_"); qo=b?new iUr(b):null}return qo},be=function(){return g.YB("yt.mdx.remote.currentScreenId_")},z7c=function(b){g.kB("yt.mdx.remote.currentScreenId_",b)},Uq3=function(){return g.YB("yt.mdx.remote.connectData_")},Kb=function(b){g.kB("yt.mdx.remote.connectData_",b)},No=function(){return g.YB("yt.mdx.remote.connection_")},Bf=function(b){const R=No(); Kb(null);b||z7c("");g.kB("yt.mdx.remote.connection_",b);o3&&(g.pr(o3,function(h){h(b)}),o3.length=0); R&&!b?SQ("yt-remote-connection-change",!1):!R&&b&&SQ("yt-remote-connection-change",!0)},s_=function(){const b=g.lQ(); if(!b)return null;var R=Dh();if(!R)return null;R=R.Rw();return AZ(R,b)},vf=function(b,R){be(); IW()&&IW();if(df)le=b;else{z7c(b.id);var h=g.YB("yt.mdx.remote.enableConnectWithInitialState_")||!1;b=new fb(b,h);b.connect(R,Uq3());b.subscribe("beforeDisconnect",function(K){SQ("yt-remote-before-disconnect",K)}); b.subscribe("beforeDispose",function(){No()&&(No(),Bf(null))}); b.subscribe("browserChannelAuthError",()=>{const K=IW();K&&K.idType=="shortLived"&&(gN()?zy().handleBrowserChannelAuthError():Ad("refreshLoungeToken called before API ready."))}); Bf(b)}},yY2=function(){const b=s_(); b?(RW("Resume connection to: "+fF(b)),vf(b,0)):(gQ(),VGH(),RW("Skipping connecting because no session screen found."))},dqr=function(){var b=$e(); if(g.RT(b)){b=Up();var R=g.NC("yt-remote-session-name")||"";const h=g.NC("yt-remote-session-app")||"";b={device:"REMOTE_CONTROL",id:b,name:R,app:h,mdxVersion:3};b.authuser=String(g.x("SESSION_INDEX","0"));(R=g.x("DELEGATED_SESSION_ID"))&&(b.pageId=String(R));g.kB("yt.mdx.remote.channelParams_",b)}},$e=function(){return g.YB("yt.mdx.remote.channelParams_")||{}},GD3=function(b,R){if(y6(b)){b.Cz.unsubscribe("remotePlayerChange",b.S,b); const h=Math.round(R.volume);R=!!R.muted;const K=xL(b.Cz);if(h!==K.volume||R!==K.muted)b.Cz.setVolume(h,R),b.C.start();b.Cz.subscribe("remotePlayerChange",b.S,b)}},y6=function(b){return xL(b.Cz).videoId===tI(b).videoId},jj=function(b,R){let h,K; var I=b.A.getPlaylist();I?.listId&&(h=I.index,K=I.listId.toString());I=tI(b);b.Cz.playVideo(I.videoId,R,h,K,I.playerParams,I.C,X6n(I));b.n0(new g.tk(1))},AI=function(b,R){if(y6(b)&&!b.J){let h=null; R&&(h={style:b.A.getSubtitlesUserSettings()},Object.assign(h,R));b.Cz.K(tI(b).videoId,h);b.V=xL(b.Cz).trackData}},gXc=function(b,R){if(R){const h=b.A.getOption("captions","tracklist",{Gn:1}); h&&h.length?(b.A.setOption("captions","track",R),b.J=!1):(b.A.loadModule("captions"),b.J=!0)}else b.A.setOption("captions","track",{})},W2t=function(b){b.FX(0); b.Y.stop();b.n0(new g.tk(64))},tI=function(b){return b.A.getVideoData({playerType:1})},Sqn=function(b){const R=b.player.L(); return!R.N("mdx_enable_privacy_disclosure_ui")||b.isLoggedIn()||b.fA||!b.Le?!1:g.lv(R)||g.BG(R)},nXn=function(b,R,h){b.p5=h; b.player.publish("presentingplayerstatechange",new g.n6(h,R))},ie=function(b,R,...h){b.loaded&&b.FQ.kH(R,...h)},z7=function(b){b.w0&&(b.player.removeEventListener("presentingplayerstatechange",b.w0),b.w0=null)},U_=function(b,R){if(R.key!==b.QD.key)if(R.key===b.uB.key)aW(); else if(Sqn(b)&&EXH(b),b.QD=R,!g.LW(b.player.L())){{const N=b.player.getPlaylistId();var h=b.player.getVideoData({playerType:1});const p=h.videoId;if(!N&&!p||(b.player.getAppState()===2||b.player.getAppState()===1)&&b.player.L().N("should_clear_video_data_on_player_cued_unstarted"))h=null;else{var K=b.player.getPlaylist();if(K){var I=[];for(let l=0;l{!b.fA&&R.Up(8)&&(b.player.pauseVideo(), z7(b))},b.player.addEventListener("presentingplayerstatechange",b.w0)); b.Le&&b.Le.zD();No()||(df=!0)}; g.Le.prototype.y5=g.hD(46,function(){this.app.Nz().y5()}); g.kR.prototype.y5=g.hD(45,function(){this.Qk=null}); g.Le.prototype.qh=g.hD(44,function(b){this.app.Nz().qh(b)}); g.kR.prototype.qh=g.hD(43,function(b){this.Qk=b}); g.VG.prototype.qg=g.hD(1,function(){return g.vv(this,3)}); g.Nx.prototype.qg=g.hD(0,function(){return g.vv(this,11)}); var YEz=class{constructor(){var b=g.o1();this.Y=b;g.qf(b,"/client_streamz/youtube/living_room/mdx/channel/opened",g.Eh("channel_type"))}G(b){g.fi(this.Y,"/client_streamz/youtube/living_room/mdx/channel/opened",b)}},eQz=class{constructor(){var b=g.o1();this.Y=b;g.qf(b,"/client_streamz/youtube/living_room/mdx/channel/closed",g.Eh("channel_type"))}G(b){g.fi(this.Y,"/client_streamz/youtube/living_room/mdx/channel/closed",b)}},QSR=class{constructor(){var b=g.o1();this.Y=b;g.qf(b,"/client_streamz/youtube/living_room/mdx/channel/message_received", g.Eh("channel_type"))}G(b){g.fi(this.Y,"/client_streamz/youtube/living_room/mdx/channel/message_received",b)}},OSt=class{constructor(){var b=g.o1();this.Y=b;g.qf(b,"/client_streamz/youtube/living_room/mdx/channel/success")}G(){g.fi(this.Y,"/client_streamz/youtube/living_room/mdx/channel/success")}},x5x=class{constructor(){var b=g.o1();this.Y=b;g.qf(b,"/client_streamz/youtube/living_room/mdx/channel/error",g.Eh("channel_type"),g.Eh("error_type"))}G(b,R){g.fi(this.Y,"/client_streamz/youtube/living_room/mdx/channel/error", b,R)}},m5z=class{constructor(){var b=g.o1();this.Y=b;g.qf(b,"/client_streamz/youtube/living_room/mdx/browser_channel/pending_maps")}G(){g.fi(this.Y,"/client_streamz/youtube/living_room/mdx/browser_channel/pending_maps")}},PVt=class{constructor(){var b=g.o1();this.Y=b;g.qf(b,"/client_streamz/youtube/living_room/mdx/browser_channel/undelivered_maps")}G(){g.fi(this.Y,"/client_streamz/youtube/living_room/mdx/browser_channel/undelivered_maps")}};g.W=vB.prototype; g.W.Rm=function(){BB(this);const b=[];for(let R=0;R2*this.size&&BB(this),!0):!1}; g.W.get=function(b,R){return a9(this.Y,b)?this.Y[b]:R}; g.W.set=function(b,R){a9(this.Y,b)||(this.size+=1,this.G.push(b),this.eG++);this.Y[b]=R}; g.W.forEach=function(b,R){const h=this.WM();for(let K=0;K=K.G.length)return g.e_;const N=K.G[R++];return g.Wk(b?N:K.Y[N])}; return I}; var Dlc={XC:"atp",frH:"ska",gZp:"que",OY:"mus",wYY:"sus",tG:"dsp",q9r:"seq",pV:"mic",MO:"dpa",LV:"mlm",I_:"dsdtr",Q2:"ntb",sT6:"vsp",NO:"scn",VYv:"rpe",nE:"dcn",GA:"dcp",NG:"pas",TA:"drq",MG:"opf",JG:"els",Fi:"isg",bR9:"svq",wO:"mvp",G1:"ads",nOO:"stcp",KeH:"sads",Y7:"dloc",hG:"dcw",T1:"asw",YD:"apw",Ix:"wrc",e4:"pcw",C1:"ipv",I4:"ndt",E6:"ctops",wF:"gsrm"},bfR={cO9:"u",oV:"cl",Pu:"k",NS:"i",W0:"cr",fV:"m",iV:"g",vc:"up"},cKn={Gu:"nowPlaying",vT:"onStateChange",SM:"adPlaying",u4:"onAdStateChange", YW:"nowPlayingShorts",gy:"onShortsStateChange"};HB.prototype.equals=function(b){return b?this.id==b.id:!1}; var zB="",WB=null,jZz=qVp("loadCastFramework")||qVp("loadCastApplicationFramework"),ifn=["pkedcjkdefgpdelpbcmbmeomcjbeemfm","enhhojjnijigcajfphajepfemndkmdlo"];g.Dx(kf,g.N3);g.W=kf.prototype;g.W.Hw=function(b){this.V=arguments;this.G=!1;this.i5?this.X=g.wK()+this.zk:this.i5=g.Nf(this.S,this.zk)}; g.W.stop=function(){this.i5&&(g.JD.clearTimeout(this.i5),this.i5=null);this.X=null;this.G=!1;this.V=[]}; g.W.pause=function(){++this.Y}; g.W.resume=function(){this.Y&&(--this.Y,!this.Y&&this.G&&(this.G=!1,this.J.apply(null,this.V)))}; g.W.X5=function(){this.stop();kf.d3.X5.call(this)}; g.W.au=function(){this.i5&&(g.JD.clearTimeout(this.i5),this.i5=null);this.X?(this.i5=g.Nf(this.S,this.X-g.wK()),this.X=null):this.Y?this.G=!0:(this.G=!1,this.J.apply(null,this.V))};var eQ=null;Yf.prototype.set=function(b){this.G=b}; Yf.prototype.reset=function(){this.set(g.wK())}; Yf.prototype.get=function(){return this.G};g.Dx(Ggn,U3r);var Ni=class{stringify(b){return g.JD.JSON.stringify(b,void 0)}parse(b){return g.JD.JSON.parse(b,void 0)}};g.Dx(Op,g.av);g.Dx(Qn,g.av);var glH=null;g.Dx(WRR,g.av);g.Dx(SV2,g.av);g.Dx(nl2,g.av);cB.prototype.debug=function(){}; cB.prototype.info=function(){}; cB.prototype.warning=function(){};var eNr={},rQ={};g.W=uB.prototype;g.W.setTimeout=function(b){this.xZ=b}; g.W.Zf=function(b){b=b.target;const R=this.NJ;R&&g.eS(b)==3?R.V():this.Rn(b)}; g.W.Rn=function(b){try{if(b==this.G)a:{const I=g.eS(this.G),N=this.G.Y,p=this.G.getStatus();if(!(I<3)&&(I!=3||this.G&&(this.Y.Y||g.x5(this.G)||g.mr(this.G)))){this.gp||I!=4||N==7||(N==8||p<=0?mE(3):mE(2));LF(this);var R=this.G.getStatus();this.fR=R;var h=YVU(this);if(this.J=R==200){if(this.CR&&!this.JX){b:{if(this.G){const l=g.Zg(this.G,"X-HTTP-Initial-Response");if(l&&!g.fj(l)){var K=l;break b}}K=null}if(b=K)this.JX=!0,sc(this,b);else{this.J=!1;this.S=3;PB(12);CF(this);MO(this);break a}}if(this.MJ){b= !0;let l;for(;!this.gp&&this.D0&&!this.RH&&(this.RH=!0,this.X.hp(this)):(CF(this),MO(this))}else sc(this,h);I==4&&CF(this);this.J&&!this.gp&&(I==4?x33(this.X,this):(this.J=!1,Vn(this)))}else g.Pd(this.G),R==400&&h.indexOf("Unknown SID")> 0?(this.S=3,PB(12)):(this.S=0,PB(13)),CF(this),MO(this)}}}catch(I){}finally{}}; g.W.cancel=function(){this.gp=!0;CF(this)}; g.W.Df=function(){this.G6=null;const b=Date.now();b-this.KR>=0?(this.vY!=2&&(mE(3),PB(17)),CF(this),this.S=2,MO(this)):QZH(this,this.KR-b)}; g.W.getLastError=function(){return this.S}; g.W.H8=function(){return this.G};var Tqp=class{constructor(b,R){this.G=b;this.map=R;this.context=null}};car.prototype.cancel=function(){this.X=$D(this);if(this.Y)this.Y.cancel(),this.Y=null;else if(this.G&&this.G.size!==0){for(const b of this.G.values())b.cancel();this.G.clear()}};g.W=MDz.prototype;g.W.tY=8;g.W.cI=1;g.W.connect=function(b,R,h,K){PB(0);this.Zl=b;this.gp=R||{};h&&K!==void 0&&(this.gp.OSID=h,this.gp.OAID=K);this.NJ=this.Sn;this.SY=m3t(this,null,this.Zl);Kv(this)}; g.W.disconnect=function(){rac(this);if(this.cI==3){var b=this.Zr++,R=this.SY.clone();g.$O(R,"SID",this.V);g.$O(R,"RID",b);g.$O(R,"TYPE","terminate");aO(this,R);b=new uB(this,this.V,b);b.vY=2;b.K=I9(R.clone());R=!1;if(g.JD.navigator&&g.JD.navigator.sendBeacon)try{R=g.JD.navigator.sendBeacon(b.K.toString(),"")}catch{}!R&&g.JD.Image&&((new Image).src=b.K,R=!0);R||(b.G=Ja3(b.X,null),b.G.send(b.K));b.nR=Date.now();Vn(b)}bSU(this)}; g.W.r4=function(){return this.cI==0}; g.W.getState=function(){return this.cI}; g.W.Qo=function(b){if(this.J)if(this.J=null,this.cI==1){if(!b){this.Zr=Math.floor(Math.random()*1E5);b=this.Zr++;const I=new uB(this,"",b);let N=this.U;this.CR&&(N?(N=g.$T(N),g.pj(N,this.CR)):N=this.CR);this.D!==null||this.KR||(I.SY=N,N=null);if(this.wp)a:{var R=0;for(var h=0;h4096){R=h;break a}if(R===4096||h===this.X.length-1){R=h+1;break a}}R= this.jn}else R=this.jn;R=FRg(this,I,R);h=this.SY.clone();g.$O(h,"RID",b);g.$O(h,"CVER",22);this.MJ&&g.$O(h,"X-HTTP-Session-Id",this.MJ);aO(this,h);N&&(this.KR?R="headers="+g.A1(g.vP(N))+"&"+R:this.D&&g.BP(h,this.D,N));hv(this.Y,I);this.K5&&g.$O(h,"TYPE","init");this.wp?(g.$O(h,"$req",R),g.$O(h,"SID","null"),I.CR=!0,Xs(I,h,null)):Xs(I,h,R);this.cI=2}}else this.cI==3&&(b?olt(this,b):this.X.length==0||uCU(this.Y)||olt(this))}; g.W.kc=function(){this.K=null;D32(this);if(this.FM&&!(this.xZ||this.G==null||this.EW<=0)){var b=4*this.EW;this.T6=ZK((0,g.Ms)(this.Mo,this),b)}}; g.W.Mo=function(){this.T6&&(this.T6=null,this.NJ=!1,this.xZ=!0,PB(10),o9(this),D32(this))}; g.W.hp=function(b){this.G==b&&this.FM&&!this.xZ&&(l7(this),this.xZ=!0,PB(11))}; g.W.ou=function(){this.G6!=null&&(this.G6=null,o9(this),DK(this),PB(19))}; g.W.lM=function(b){b?PB(2):PB(1)}; g.W.isActive=function(){return!!this.S&&this.S.isActive(this)}; g.W=hQR.prototype;g.W.Y3=function(){}; g.W.Gc=function(){}; g.W.nK=function(){}; g.W.Px=function(){}; g.W.isActive=function(){return!0}; g.W.q0=function(){};g.Dx(BT,g.TD);BT.prototype.open=function(){this.G.S=this.X;this.D&&(this.G.JX=!0);this.G.connect(this.J,this.Y||void 0)}; BT.prototype.close=function(){this.G.disconnect()}; BT.prototype.send=function(b){var R=this.G;if(typeof b==="string"){var h={};h.__data__=b;b=h}else this.S&&(h={},h.__data__=g.z1(b),b=h);R.X.push(new Tqp(R.gB++,b));R.cI==3&&Kv(R)}; BT.prototype.X5=function(){this.G.S=null;delete this.X;this.G.disconnect();delete this.G;BT.d3.X5.call(this)}; g.Dx(sSt,Op);g.Dx($5x,Qn);g.Dx(vT,hQR);vT.prototype.Y3=function(){this.G.dispatchEvent("m")}; vT.prototype.Gc=function(b){this.G.dispatchEvent(new sSt(b))}; vT.prototype.nK=function(b){this.G.dispatchEvent(new $5x(b))}; vT.prototype.Px=function(){this.G.dispatchEvent("n")}; BT.prototype.V=function(){return new HT(this,this.G)}; HT.prototype.Y=function(){return b7(this.G.Y)}; HT.prototype.X=function(){return RQc(this.G).map(b=>{var R=this.V;b=b.map;"__data__"in b?(b=b.__data__,R=R.S?Cl2(b):b):R=b;return R})}; HT.prototype.commit=function(b){this.G.fR=b};var dr=new g.TD,IQ2=class extends g.av{constructor(){super("statevent",dr)}};g.W=yl.prototype;g.W.td=null;g.W.zv=!1;g.W.Ju=null;g.W.lm=null;g.W.e8=null;g.W.wr=null;g.W.dU=null;g.W.LW=null;g.W.kh=null;g.W.IU=null;g.W.fW=0;g.W.FL=null;g.W.OH=null;g.W.Fz=null;g.W.m9=-1;g.W.rb=!0;g.W.E0=!1;g.W.VE=0;g.W.ev=null;var lQH={},Av={};g.W=yl.prototype;g.W.setTimeout=function(b){this.Y=b}; g.W.zB=function(b){b=b.target;const R=this.ev;R&&g.eS(b)==3?R.V():this.Tc(b)}; g.W.Tc=function(b){try{if(b==this.IU)a:{const R=g.eS(this.IU),h=this.IU.Y,K=this.IU.getStatus();if(g.qN&&!g.ZN("420+")){if(R<4)break a}else if(R<3||R==3&&!g.x5(this.IU))break a;this.E0||R!=4||h==7||(h==8||K<=0?this.G.OT(3):this.G.OT(2));Bpr(this);const I=this.IU.getStatus();this.m9=I;const N=g.x5(this.IU);if(this.zv=I==200){R==4&&z8(this);if(this.MJ){for(b=!0;!this.E0&&this.fW0?3:0,fv(),z8(this),i7(this)}}catch(R){}finally{}}; g.W.cancel=function(){this.E0=!0;z8(this)}; g.W.xS=function(){this.Ju=null;const b=Date.now();b-this.lm>=0?(this.wr!=2&&this.G.OT(3),z8(this),this.Fz=2,fv(),i7(this)):v33(this,this.lm-b)}; g.W.getLastError=function(){return this.Fz};g.W=fQH.prototype;g.W.Bb=null;g.W.s_=null;g.W.D$=!1;g.W.Fj=null;g.W.pU=null;g.W.kY=-1;g.W.Ws=null;g.W.hD=null;g.W.connect=function(b){this.Fj=b;b=G8(this.G,null,this.Fj);fv();Date.now();const R=this.G.U;R!=null?(this.Ws=R[0],(this.hD=R[1])?(this.pU=1,yKn(this)):(this.pU=2,WT(this))):(NO(b,"MODE","init"),this.s_=new yl(this),this.s_.td=this.Bb,tv(this.s_,b,!1,null,!0),this.pU=0)}; g.W.kF=function(b){if(b)this.pU=2,WT(this);else{fv();var R=this.G;R.D5=R.RQ.kY;e3(R,9)}b&&this.OT(2)}; g.W.Sl=function(b){return this.G.Sl(b)}; g.W.abort=function(){this.s_&&(this.s_.cancel(),this.s_=null);this.kY=-1}; g.W.r4=function(){return!1}; g.W.IW=function(b,R){this.kY=b.m9;if(this.pU==0)if(R){try{var h=this.Y.parse(R)}catch(K){b=this.G;b.D5=this.kY;e3(b,2);return}this.Ws=h[0];this.hD=h[1]}else b=this.G,b.D5=this.kY,e3(b,2);else this.pU==2&&(this.D$?(fv(),Date.now()):R=="11111"?(fv(),this.D$=!0,Date.now(),this.kY=200,this.s_.cancel(),fv(),gr(this.G,this,!0)):(fv(),Date.now(),this.D$=!1))}; g.W.AN=function(){this.kY=this.s_.m9;if(this.s_.zv)this.pU==0?this.hD?(this.pU=1,yKn(this)):(this.pU=2,WT(this)):this.pU==2&&(this.D$?(fv(),gr(this.G,this,!0)):(fv(),gr(this.G,this,!1)));else{this.pU==0?fv():this.pU==2&&fv();var b=this.G;this.s_.getLastError();b.D5=this.kY;e3(b,2)}}; g.W.LG=function(){return this.G.LG()}; g.W.isActive=function(){return this.G.isActive()}; g.W.OT=function(b){this.G.OT(b)};g.W=S3.prototype;g.W.cM=null;g.W.wU=null;g.W.tE=null;g.W.iP=null;g.W.NR=null;g.W.UH=null;g.W.Xm=null;g.W.JN=null;g.W.O0=0;g.W.cw=0;g.W.bR=null;g.W.bN=null;g.W.Qg=null;g.W.P2=null;g.W.RQ=null;g.W.po=null;g.W.HQ=-1;g.W.MD=-1;g.W.D5=-1;g.W.rM=0;g.W.NH=0;g.W.Q9=8;var JY3={OK:0,Fev:2,Jx:4,Tu:5,pHp:6,STOP:7,Ru:8,g5:9,yR:10,u1:11,Xg:12};g.Dx(jSp,g.av);g.Dx(AKx,g.av);g.W=S3.prototype; g.W.connect=function(b,R,h,K,I){fv();this.NR=R;this.wU=h||{};K&&I!==void 0&&(this.wU.OSID=K,this.wU.OAID=I);this.K?(qi((0,g.Ms)(this.Ag,this,b),100),iS3(this)):this.Ag(b)}; g.W.disconnect=function(){zQU(this);if(this.G==3){var b=this.O0++;const R=this.UH.clone();g.$O(R,"SID",this.V);g.$O(R,"RID",b);g.$O(R,"TYPE","terminate");kD(this,R);b=new yl(this,this.V,b);b.wr=2;b.dU=I9(R.clone());(new Image).src=b.dU.toString();b.e8=Date.now();j3(b)}E3r(this)}; g.W.Ag=function(b){this.RQ=new fQH(this);this.RQ.Bb=this.cM;this.RQ.Y=this.S;this.RQ.connect(b)}; g.W.r4=function(){return this.G==0}; g.W.getState=function(){return this.G}; g.W.u2=function(b){this.bN=null;g3c(this,b)}; g.W.h4=function(){this.Qg=null;this.iP=new yl(this,this.V,"rpc",this.D);this.iP.td=this.cM;this.iP.VE=0;var b=this.Xm.clone();g.$O(b,"RID","rpc");g.$O(b,"SID",this.V);g.$O(b,"CI",this.po?"0":"1");g.$O(b,"AID",this.HQ);kD(this,b);g.$O(b,"TYPE","xmlhttp");tv(this.iP,b,!0,this.JN,!1)}; g.W.IW=function(b,R){if(this.G!=0&&(this.iP==b||this.tE==b))if(this.D5=b.m9,this.tE==b&&this.G==3)if(this.Q9>7){try{var h=this.S.parse(R)}catch(K){h=null}if(Array.isArray(h)&&h.length==3)if(b=h,b[0]==0)a:{if(!this.Qg){if(this.iP)if(this.iP.e8+3E30)){if(K=R==1)this.tE||this.bN||this.G==1||this.rM>=2?K=!1:(this.bN=qi((0,g.Ms)(this.u2,this,b),SEt(this,this.rM)),this.rM++, K=!0);K=!(K||R==2&&YD(this))}if(K)switch(h){case 1:e3(this,5);break;case 4:e3(this,10);break;case 3:e3(this,6);break;case 7:e3(this,12);break;default:e3(this,2)}}}; g.W.pF=function(b){if(!g.iR(arguments,this.G))throw Error("Unexpected channel state: "+this.G);}; g.W.VF=function(b){b?fv():(fv(),n3z(this,8))}; g.W.Sl=function(b){if(b)throw Error("Can't create secondary domain capable XhrIo object.");b=new g.ni;b.D=!1;return b}; g.W.isActive=function(){return!!this.bR&&this.bR.isActive(this)}; g.W.OT=function(b){const R=dr;R.dispatchEvent(new AKx(R,b))}; g.W.LG=function(){return!1}; new Ggn;g.W=Tp3.prototype;g.W.l2=function(){}; g.W.Vo=function(){}; g.W.SF=function(){}; g.W.vx=function(){}; g.W.Hb=function(){}; g.W.Bx=function(){return{}}; g.W.isActive=function(){return!0};g.W=JKz.prototype;g.W.enqueue=function(b){this.Y.push(b)}; g.W.isEmpty=function(){return this.G.length===0&&this.Y.length===0}; g.W.clear=function(){this.G=[];this.Y=[]}; g.W.contains=function(b){return g.iR(this.G,b)||g.iR(this.Y,b)}; g.W.remove=function(b){{var R=this.G;const h=Array.prototype.lastIndexOf.call(R,b,R.length-1);h>=0?(g.Ut(R,h),R=!0):R=!1}return R||g.G3(this.Y,b)}; g.W.Rm=function(){const b=[];for(var R=this.G.length-1;R>=0;--R)b.push(this.G[R]);R=this.Y.length;for(let h=0;h"",this.vY=()=>g.Xp({}))}; g.W.HY=function(){return this.U}; g.W.connect=async function(b,R,h){try{this.K&&await this.S}finally{if(this.U||this.G&&this.G.getState()==2&&!this.X)return;this.MJ="";this.X||this.Y.stop();this.C=b||null;this.G6=R||0;const K=this.JX+"/test",I=this.JX+"/bind";b=new S3(h?h.firstTestResults:null,h?h.secondTestResults:null,this.fR);const N=this.G;N&&(N.bR=null);b.bR=this;this.G=b;if(this.K)return this.S=mG(this).then(()=>ZS3(this,K,I,N,h)),this.S.then(()=>{this.S=g.Xp()}); ZS3(this,K,I,N,h)}}; g.W.disconnect=function(b){try{this.K&&(this.S.cancel(),this.S=g.Xp())}finally{this.T6=b||0,this.Y&&this.Y.stop(),xD(this),this.G&&(this.G.getState()==3&&g3c(this.G),this.G.disconnect()),this.T6=0}}; g.W.sendMessage=async function(b,R){try{this.K&&await this.S}finally{if(this.U)return;const h={_sc:b};R&&g.pj(h,R);if(this.Y.isActive()||(this.G?this.G.getState():0)==2)this.V.push(h);else if(this.m6())try{this.K&&!uac(this,b)&&await mG(this)}finally{this.m6()&&(uac(this,b),xD(this),T8(this.G,h))}}}; g.W.l2=function(){this.J&&this.Y&&this.Y.qg()>0&&(this.J.YiX(this.Y.qg(),this.X,!0),this.J.T4Z());this.J&&this.J.i06();this.X?(this.Y.stop(),g.$l(this.Y),this.Y=new Oc(this.ek,this),this.X=!1):this.Y.reset();this.C=null;this.G6=0;if(this.V.length)if(this.K)Xyc(this);else{var b=this.V;this.V=[];var R=b.length;for(let h=0;hJY3[h]===b); this.Zr.G("BROWSER_CHANNEL",R??"UNKNOWN")}; g.W.Hb=function(b,R){if(!this.Y.isActive())this.publish("handlerClosed");else if(R){const h=R.length;for(let K=0;K{this.onError(K)}); this.handler.subscribe("handlerMessage",this.onMessage,this);this.Y=R}connect(b,R,h){this.handler.connect(b,R,h)}disconnect(b){this.handler.disconnect(b)}c9(){this.handler.c9()}getDeviceId(){return this.handler.getDeviceId()}Jy(){return this.handler.Jy()}m6(){return this.handler.m6()}G(){this.dispatchEvent("channelOpened");var b=this.handler,R=this.Y;g.Iz("yt-remote-session-browser-channel",{firstTestResults:[""],secondTestResults:!b.G.po,sessionId:b.G.V,arrayId:b.G.HQ});g.Iz("yt-remote-session-screen-id", R);b=iB();R=Up();g.iR(b,R)||b.push(R);N3n(b);GB()}onClosed(){this.dispatchEvent("channelClosed")}onMessage(b){this.dispatchEvent(new kDg(b))}onError(b){this.dispatchEvent(new Yqz(b?1:0))}sendMessage(b,R){this.handler.sendMessage(b,R)}VZ(b){this.handler.VZ(b)}dispose(){this.handler.dispose()}};var rKx=class{constructor(b,R,h=()=>""){new K7g; var K=new g.kd;this.pathPrefix=b;this.G=R;this.nR=h;this.S=K;this.K=null;this.U=this.D=0;this.channel=null;this.J=0;this.X=new Oc(()=>{this.X.isActive();this.channel?.V().Y()===0&&this.connect(this.K,this.D)}); this.V={};this.Y={};this.G6=!1;this.logger=null;this.C=[];this.g4=void 0;this.SY=new YEz;this.T6=new eQz;this.gp=new QSR;this.MJ=new x5x}connect(b={},R=0){this.J!==2&&(this.X.stop(),this.K=b,this.D=R,u7(this),(b=g.x("ID_TOKEN"))?this.V["x-youtube-identity-token"]=b:delete this.V["x-youtube-identity-token"],this.G&&(this.Y.device=this.G.device,this.Y.name=this.G.name,this.Y.app=this.G.app,this.Y.id=this.G.id,this.G.jT&&(this.Y.mdxVersion=`${this.G.jT}`),this.G.theme&&(this.Y.theme=this.G.theme),this.G.capabilities&& (this.Y.capabilities=this.G.capabilities),this.G.Vv&&(this.Y.cst=this.G.Vv),this.G.authuser&&(this.Y.authuser=this.G.authuser),this.G.pageId&&(this.Y.pageId=this.G.pageId)),this.D!==0?this.Y.ui=`${this.D}`:delete this.Y.ui,Object.assign(this.Y,this.K),this.channel=new BT(this.pathPrefix,{fk:"gsessionid",LS:this.V,wZ:this.Y}),this.channel.open(),this.J=2,CVp(this))}disconnect(b=0){this.U=b;this.X.stop();u7(this);this.channel&&(this.U!==0?this.Y.ui=`${this.U}`:delete this.Y.ui,this.channel.close()); this.U=0}Jy(){return this.X.isActive()?this.X.Az-Date.now():NaN}c9(){var b=this.X;g.Rf(b.G);b.start()}sendMessage(b,R){this.channel&&(u7(this),this.channel.send({_sc:b,...R}))}VZ(b){b||this.X.stop();b?this.V["X-YouTube-LoungeId-Token"]=b:delete this.V["X-YouTube-LoungeId-Token"]}getDeviceId(){return this.G?this.G.id:""}publish(b,...R){return this.S.publish(b,...R)}subscribe(b,R,h){return this.S.subscribe(b,R,h)}unsubscribe(b,R,h){return this.S.unsubscribe(b,R,h)}pN(b){return this.S.pN(b)}dispose(){this.G6|| (this.G6=!0,g.$l(this.S),this.disconnect(),g.$l(this.X),this.nR=()=>"")}HY(){return this.G6}};var Mdz=class extends g.TD{constructor(b){super();this.G=b();this.G.subscribe("webChannelOpened",this.Y,this);this.G.subscribe("webChannelClosed",this.onClosed,this);this.G.subscribe("webChannelError",this.onError,this);this.G.subscribe("webChannelMessage",this.onMessage,this)}connect(b,R){this.G.connect(b,R)}disconnect(b){this.G.disconnect(b)}c9(){this.G.c9()}getDeviceId(){return this.G.getDeviceId()}Jy(){return this.G.Jy()}m6(){return this.G.J===3}Y(){this.dispatchEvent("channelOpened")}onClosed(){this.dispatchEvent("channelClosed")}onMessage(b){this.dispatchEvent(new kDg(b))}onError(){this.dispatchEvent(new Yqz(this.G.g4=== 401?1:0))}sendMessage(b,R){this.G.sendMessage(b,R)}VZ(b){this.G.VZ(b)}dispose(){this.G.dispose()}};var KtR=Date.now(),X0=null,rr=Array(50),Mi=-1,Lv=!1;g.Dx(wr,g.NU);wr.prototype.Rw=function(){return this.screens}; wr.prototype.contains=function(b){return!!jQ(this.screens,b)}; wr.prototype.get=function(b){return b?AZ(this.screens,b):null}; wr.prototype.info=function(b){Vl(this.J,b)};var OUH=class extends g.NU{constructor(b,R,h,K,I){super();this.V=b;this.C=R;this.K=h;this.G6=K;this.U=I;this.Y=0;this.G=null;this.i5=NaN}start(){!this.G&&isNaN(this.i5)&&this.X()}stop(){this.G&&(this.G.abort(),this.G=null);isNaN(this.i5)||(g.m8(this.i5),this.i5=NaN)}X5(){this.stop();super.X5()}X(){this.i5=NaN;this.G=g.LD(cT(this.V,"/pairing/get_screen"),{method:"POST",postParams:{pairing_code:this.C},timeout:5E3,onSuccess:(0,g.Ms)(this.J,this),onError:(0,g.Ms)(this.S,this),onTimeout:(0,g.Ms)(this.D, this)})}J(b,R){this.G=null;b=R.screen||{};b.dialId=this.K;b.name=this.G6;R=-1;this.U&&b.shortLivedLoungeToken&&b.shortLivedLoungeToken.value&&b.shortLivedLoungeToken.refreshIntervalMs&&(b.screenIdType="shortLived",b.loungeToken=b.shortLivedLoungeToken.value,R=b.shortLivedLoungeToken.refreshIntervalMs);this.publish("pairingComplete",new qO(b),R)}S(b){this.G=null;b.status&&b.status==404?this.Y>=e73.length?this.publish("pairingFailed",Error("DIAL polling timed out")):(b=e73[this.Y],this.i5=g.QB((0,g.Ms)(this.X, this),b),this.Y++):this.publish("pairingFailed",Error("Server error "+b.status))}D(){this.G=null;this.publish("pairingFailed",Error("Server not responding"))}},e73=[2E3,2E3,1E3,1E3,1E3,2E3,2E3,5E3,5E3,1E4];g.Dx(oO,wr);g.W=oO.prototype;g.W.start=function(){F0(this)&&this.publish("screenChange");!g.NC("yt-remote-lounge-token-expiration")&&Na3(this);g.m8(this.G);this.G=g.QB((0,g.Ms)(this.start,this),1E4)}; g.W.add=function(b,R){F0(this);sUU(this,b);DJ(this,!1);this.publish("screenChange");R(b);b.token||Na3(this)}; g.W.remove=function(b,R){let h=F0(this);IMz(this,b)&&(DJ(this,!1),h=!0);R(b);h&&this.publish("screenChange")}; g.W.xn=function(b,R,h,K){let I=F0(this);const N=this.get(b.id);N?(N.name!=R&&(N.name=R,DJ(this,!1),I=!0),h(b)):K(Error("no such local screen."));I&&this.publish("screenChange")}; g.W.X5=function(){g.m8(this.G);oO.d3.X5.call(this)}; g.W.iU=function(b){F0(this);let R=this.screens.length;b=b&&b.screens||[];const h=b.length;for(let K=0;K{g.$l(p);I($L(this,l),a)}); p.subscribe("pairingFailed",l=>{g.$l(p);N(l)}); p.start();return(0,g.Ms)(p.stop,p)}; g.W.sx=function(b,R,h,K){g.LD(cT(this.V,"/pairing/get_screen"),{method:"POST",postParams:{pairing_code:b},timeout:5E3,onSuccess:(0,g.Ms)(function(I,N){I=new qO(N.screen||{});if(!I.name||H2x(this,I.name)){a:{N=I.name;let p=2,l=R(N,p);for(;H2x(this,l);){p++;if(p>20)break a;l=R(N,p)}N=l}I.name=N}h($L(this,I))},this), onError:(0,g.Ms)(function(I){K(Error("pairing request failed: "+I.status))},this), onTimeout:(0,g.Ms)(function(){K(Error("pairing request timed out."))},this)})}; g.W.X5=function(){g.$l(this.Y);g.$l(this.G);sS.d3.X5.call(this)}; g.W.Ev=function(){dTR(this);this.publish("screenChange");this.G.update()}; sS.prototype.dispose=sS.prototype.dispose;g.Dx(N7,g.NU);g.W=N7.prototype;g.W.N8=function(b){this.HY()||(b&&(lc(this,""+b),this.publish("sessionFailed")),this.G=null,this.publish("sessionScreen",null))}; g.W.info=function(b){Vl(this.MJ,b)}; g.W.J4=function(){return null}; g.W.E4=function(b){const R=this.Y;b?(R.displayStatus=new chrome.cast.ReceiverDisplayStatus(b,[]),R.displayStatus.showStop=!0):R.displayStatus=null;chrome.cast.setReceiverDisplayStatus(R,(0,g.Ms)(function(){this.info("Updated receiver status for "+R.friendlyName+": "+b)},this),(0,g.Ms)(function(){lc(this,"Failed to update receiver status for: "+R.friendlyName)},this))}; g.W.X5=function(){this.E4("");N7.d3.X5.call(this)};var G7=class extends N7{constructor(b,R,h){super(b,R,"CastSession");this.config_=h;this.X=null;this.C=(0,g.Ms)(this.SY,this);this.nR=(0,g.Ms)(this.vY,this);this.G6=g.QB(()=>{Aor(this,null)},12E4); this.K=this.S=this.D=this.U=0}T6(b){if(this.X){if(this.X==b)return;lc(this,"Overriding cast session with new session object");i2H(this);this.X.removeUpdateListener(this.C);this.X.removeMessageListener("urn:x-cast:com.google.youtube.mdx",this.nR)}this.X=b;this.X.addUpdateListener(this.C);this.X.addMessageListener("urn:x-cast:com.google.youtube.mdx",this.nR);zf3(this,"getMdxSessionStatus")}J(b){this.info("launchWithParams no-op for Cast: "+g.z1(b))}stop(){this.X?this.X.stop((0,g.Ms)(function(){this.N8()}, this),(0,g.Ms)(function(){this.N8(Error("Failed to stop receiver app."))},this)):this.N8(Error("Stopping cast device without session."))}E4(){}X5(){this.info("disposeInternal"); i2H(this);this.X&&(this.X.removeUpdateListener(this.C),this.X.removeMessageListener("urn:x-cast:com.google.youtube.mdx",this.nR));this.X=null;super.X5()}vY(b,R){if(!this.HY())if(R)if(R=lB(R),g.uT(R))switch(b=""+R.type,R=R.data||{},this.info("onYoutubeMessage_: "+b+" "+g.z1(R)),b){case "mdxSessionStatus":Aor(this,R);break;case "loungeToken":UTt(this,R);break;default:lc(this,"Unknown youtube message: "+b)}else lc(this,"Unable to parse message.");else lc(this,"No data in message.")}gp(b,R,h,K){g.m8(this.U); this.U=0;Bag(this.V,this.Y.label,b,this.Y.friendlyName,(0,g.Ms)(function(I){I?R(I):K>=0?(lc(this,"Screen "+b+" appears to be offline. "+K+" retries left."),this.U=g.QB((0,g.Ms)(this.gp,this,b,R,h,K-1),300)):h(Error("Unable to fetch screen."))},this),h)}J4(){return this.X}SY(b){this.HY()||b||(lc(this,"Cast session died."),this.N8())}};var Qv3=class extends N7{constructor(b,R,h,K){super(b,R,"DialSession");this.config_=K;this.X=this.U=null;this.nR="";this.vY=h;this.SY=null;this.C=()=>{}; this.G6=NaN;this.gp=(0,g.Ms)(this.JX,this);this.S=()=>{}; this.K=this.D=0}T6(b){this.X=b;this.X.addUpdateListener(this.gp)}J(b){this.SY=b;this.C()}stop(){nWz(this);this.X?this.X.stop((0,g.Ms)(this.N8,this,null),(0,g.Ms)(this.N8,this,"Failed to stop DIAL device.")):this.N8()}X5(){nWz(this);this.X&&this.X.removeUpdateListener(this.gp);this.X=null;super.X5()}JX(b){this.HY()||b||(lc(this,"DIAL session died."),this.S(),this.S=()=>{},this.N8())}};var xq3=class extends N7{constructor(b,R){super(b,R,"ManualSession");this.X=g.QB((0,g.Ms)(this.J,this,null),150)}stop(){this.N8()}T6(){}J(){g.m8(this.X);this.X=NaN;const b=AZ(this.V.Rw(),this.Y.label);b?p$(this,b):this.N8(Error("No such screen"))}X5(){g.m8(this.X);this.X=NaN;super.X5()}};var n$=class extends g.NU{constructor(b,R){super();this.config_=R;this.Y=b;this.T6=R.appId||"233637DE";this.V=R.theme||"cl";this.MJ=R.disableCastApi||!1;this.D=R.forceMirroring||!1;this.G=null;this.K=!1;this.X=[];this.J=(0,g.Ms)(this.SY,this)}init(b,R){chrome.cast.timeout.requestSession=3E4;var h=new chrome.cast.SessionRequest(this.T6,[chrome.cast.Capability.AUDIO_OUT]);g.cg("desktop_enable_cast_connect")&&(h.androidReceiverCompatible=!0);this.MJ||(h.dialRequest=new chrome.cast.DialRequest("YouTube")); const K=chrome.cast.AutoJoinPolicy.TAB_AND_ORIGIN_SCOPED;b=b||this.D?chrome.cast.DefaultActionPolicy.CAST_THIS_TAB:chrome.cast.DefaultActionPolicy.CREATE_SESSION;const I=(0,g.Ms)(this.vY,this);h=new chrome.cast.ApiConfig(h,(0,g.Ms)(this.U,this),I,K,b);h.customDialLaunchCallback=(0,g.Ms)(this.gp,this);chrome.cast.initialize(h,(0,g.Ms)(function(){this.HY()||(chrome.cast.addReceiverActionListener(this.J),b23(),this.Y.subscribe("onlineScreenChange",(0,g.Ms)(this.S,this)),this.X=ef3(this),chrome.cast.setCustomReceivers(this.X, ()=>{},(0,g.Ms)(function(N){this.t9("Failed to set initial custom receivers: "+g.z1(N))},this)),this.publish("yt-remote-cast2-availability-change",dN(this)),R(!0))},this),(0,g.Ms)(function(N){this.t9("Failed to initialize API: "+g.z1(N)); R(!1)},this))}NJ(b,R){f$("Setting connected screen ID: "+b+" -> "+R); if(this.G){var h=this.G.G;if(!b||h&&h.id!=b)f$("Unsetting old screen status: "+this.G.Y.friendlyName),y_(this,null)}if(b&&R){if(!this.G){b=AZ(this.Y.Rw(),b);if(!b){f$("setConnectedScreenStatus: Unknown screen.");return}if(b.idType=="shortLived"){f$("setConnectedScreenStatus: Screen with id type to be short lived.");return}h=Yhg(this,b);h||(f$("setConnectedScreenStatus: Connected receiver not custom..."),h=new chrome.cast.Receiver(b.uuid?b.uuid:b.id,b.name),h.receiverType=chrome.cast.ReceiverType.CUSTOM, this.X.push(h),chrome.cast.setCustomReceivers(this.X,()=>{},(0,g.Ms)(function(K){this.t9("Failed to set initial custom receivers: "+g.z1(K))},this))); f$("setConnectedScreenStatus: new active receiver: "+h.friendlyName);y_(this,new xq3(this.Y,h),!0)}this.G.E4(R)}else f$("setConnectedScreenStatus: no screen.")}Zr(b){this.HY()?this.t9("Setting connection data on disposed cast v2"):this.G?this.G.J(b):this.t9("Setting connection data without a session")}nR(){this.HY()?this.t9("Stopping session on disposed cast v2"):this.G?(this.G.stop(),y_(this,null)):f$("Stopping non-existing session")}requestSession(){chrome.cast.requestSession((0,g.Ms)(this.U,this), (0,g.Ms)(this.JX,this))}X5(){this.Y.unsubscribe("onlineScreenChange",(0,g.Ms)(this.S,this));window.chrome&&chrome.cast&&chrome.cast.removeReceiverActionListener(this.J);var b=F7g;const R=g.YB("yt.mdx.remote.debug.handlers_");g.G3(R||[],b);g.$l(this.G);super.X5()}t9(b){Vl("Controller",b)}G6(b,R){this.G==b&&(R||y_(this,null),this.publish("yt-remote-cast2-session-change",R))}SY(b,R){if(!this.HY())if(b)switch(b.friendlyName=chrome.cast.unescape(b.friendlyName),f$("onReceiverAction_ "+b.label+" / "+b.friendlyName+ "-- "+R),R){case chrome.cast.ReceiverAction.CAST:if(this.G)if(this.G.Y.label!=b.label)f$("onReceiverAction_: Stopping active receiver: "+this.G.Y.friendlyName),this.G.stop();else{f$("onReceiverAction_: Casting to active receiver.");this.G.G&&this.publish("yt-remote-cast2-session-change",this.G.G);break}switch(b.receiverType){case chrome.cast.ReceiverType.CUSTOM:y_(this,new xq3(this.Y,b));break;case chrome.cast.ReceiverType.DIAL:y_(this,new Qv3(this.Y,b,this.V,this.config_));break;case chrome.cast.ReceiverType.CAST:y_(this, new G7(this.Y,b,this.config_));break;default:this.t9("Unknown receiver type: "+b.receiverType)}break;case chrome.cast.ReceiverAction.STOP:this.G&&this.G.Y.label==b.label?this.G.stop():this.t9("Stopping receiver w/o session: "+b.friendlyName)}else this.t9("onReceiverAction_ called without receiver.")}gp(b){if(this.HY())return Promise.reject(Error("disposed"));var R=b.receiver;R.receiverType!=chrome.cast.ReceiverType.DIAL&&(this.t9("Not DIAL receiver: "+R.friendlyName),R.receiverType=chrome.cast.ReceiverType.DIAL); var h=this.G?this.G.Y:null;if(!h||h.label!=R.label)return this.t9("Receiving DIAL launch request for non-clicked DIAL receiver: "+R.friendlyName),Promise.reject(Error("illegal DIAL launch"));if(h&&h.label==R.label&&h.receiverType!=chrome.cast.ReceiverType.DIAL){if(this.G.G)return f$("Reselecting dial screen."),this.publish("yt-remote-cast2-session-change",this.G.G),Promise.resolve(new chrome.cast.DialLaunchResponse(!1));this.t9('Changing CAST intent from "'+h.receiverType+'" to "dial" for '+R.friendlyName); y_(this,new Qv3(this.Y,R,this.V,this.config_))}R=this.G;R.U=b;R.U.appState==chrome.cast.DialAppState.RUNNING?(b=R.U.extraData||{},h=b.screenId||null,Hh(R)&&b.loungeToken?b.loungeTokenRefreshIntervalMs?b=kkt(R,{name:R.Y.friendlyName,screenId:b.screenId,loungeToken:b.loungeToken,dialId:R.U.receiver.label,screenIdType:"shortLived"},b.loungeTokenRefreshIntervalMs):(g.qc(Error(`No loungeTokenRefreshIntervalMs presents in additionalData: ${JSON.stringify(b)}.`)),b=TaR(R,h)):b=TaR(R,h)):b=Bh(R);return b}U(b){if(!this.HY()&& !this.D){f$("New cast session ID: "+b.sessionId);var R=b.receiver;if(R.receiverType!=chrome.cast.ReceiverType.CUSTOM){if(!this.G)if(R.receiverType==chrome.cast.ReceiverType.CAST)f$("Got resumed cast session before resumed mdx connection."),R.friendlyName=chrome.cast.unescape(R.friendlyName),y_(this,new G7(this.Y,R,this.config_),!0);else{this.t9("Got non-cast session without previous mdx receiver event, or mdx resume.");return}var h=this.G.Y,K=AZ(this.Y.Rw(),h.label);K&&dQ(K,R.label)&&h.receiverType!= chrome.cast.ReceiverType.CAST&&R.receiverType==chrome.cast.ReceiverType.CAST&&(f$("onSessionEstablished_: manual to cast session change "+R.friendlyName),g.$l(this.G),this.G=new G7(this.Y,R,this.config_),this.G.subscribe("sessionScreen",(0,g.Ms)(this.G6,this,this.G)),this.G.subscribe("sessionFailed",()=>O2r(this,this.G)),this.G.J(null)); this.G.T6(b)}}}C(){return this.G?this.G.J4():null}JX(b){this.HY()||(this.t9("Failed to estabilish a session: "+g.z1(b)),b.code!=chrome.cast.ErrorCode.CANCEL&&y_(this,null),this.publish("yt-remote-cast2-session-failed"))}vY(b){f$("Receiver availability updated: "+b);if(!this.HY()){var R=dN(this);this.K=b==chrome.cast.ReceiverAvailability.AVAILABLE;dN(this)!=R&&this.publish("yt-remote-cast2-availability-change",dN(this))}}S(){this.HY()||(this.X=ef3(this),f$("Updating custom receivers: "+g.z1(this.X)), chrome.cast.setCustomReceivers(this.X,()=>{},(0,g.Ms)(function(){this.t9("Failed to set custom receivers.")},this)),this.publish("yt-remote-cast2-availability-change",dN(this)))}}; n$.prototype.setLaunchParams=n$.prototype.Zr;n$.prototype.setConnectedScreenStatus=n$.prototype.NJ;n$.prototype.stopSession=n$.prototype.nR;n$.prototype.getCastSession=n$.prototype.C;n$.prototype.requestSession=n$.prototype.requestSession;n$.prototype.init=n$.prototype.init;n$.prototype.dispose=n$.prototype.dispose;var US=[],Z2t=(0,g.DN)`https://www.gstatic.com/cv/js/sender/v1/cast_sender.js`;g.W=ES.prototype; g.W.reset=function(b){this.listId="";this.index=-1;this.videoId="";Ty(this);this.volume=-1;this.muted=!1;b&&(this.index=b.index,this.listId=b.listId,this.videoId=b.videoId,this.playerState=b.playerState,this.volume=b.volume,this.muted=b.muted,this.audioTrackId=b.audioTrackId,this.trackData=b.trackData,this.hasPrevious=b.hasPrevious,this.hasNext=b.hasNext,this.J=b.playerTime,this.S=b.playerTimeAt,this.Y=b.seekableStart,this.D=b.seekableEnd,this.X=b.duration,this.loadedTime=b.loadedTime,this.G=b.liveIngestionTime, this.V=!isNaN(this.G))}; g.W.isPlaying=function(){return this.playerState==1}; g.W.isBuffering=function(){return this.playerState==3}; g.W.Fr=function(b){this.X=isNaN(b)?0:b}; g.W.getDuration=function(){return this.V?this.X+Jd(this):this.X}; g.W.clone=function(){return new ES(OS(this))};var mqz=class extends g.NU{constructor(){var b=No();super();this.X=0;this.V=b;this.D=[];this.S=new JKz;this.Y=this.G=null;this.C=(0,g.Ms)(this.SY,this);this.U=(0,g.Ms)(this.J,this);this.G6=(0,g.Ms)(this.gp,this);this.MJ=(0,g.Ms)(this.vY,this);let R=0;b?(R=b.getProxyState(),R!=3&&(b.subscribe("proxyStateChange",this.T6,this),Ltt(this))):R=3;R!=0&&g.QB(()=>{this.T6(R)},0); (b=CXH())&&Q_(this,b);this.subscribe("yt-remote-cast2-session-change",this.MJ)}getState(){return this.X}Jy(){return this.V.getReconnectTimeout()}c9(){this.V.reconnect()}play(){mm(this)?(this.G?this.G.play(null,g.OU,Zh(this,"play")):Ph(this,"play"),uc(this,1,YL(xL(this))),this.publish("remotePlayerChange")):Xm(this,this.play)}pause(){mm(this)?(this.G?this.G.pause(null,g.OU,Zh(this,"pause")):Ph(this,"pause"),uc(this,2,YL(xL(this))),this.publish("remotePlayerChange")):Xm(this,this.pause)}seekTo(b){if(mm(this)){if(this.G){const R= xL(this),h=new chrome.cast.media.SeekRequest;h.currentTime=b;R.isPlaying()||R.isBuffering()?h.resumeState=chrome.cast.media.ResumeState.PLAYBACK_START:h.resumeState=chrome.cast.media.ResumeState.PLAYBACK_PAUSE;this.G.seek(h,g.OU,Zh(this,"seekTo",{newTime:b}))}else Ph(this,"seekTo",{newTime:b});uc(this,3,b);this.publish("remotePlayerChange")}else Xm(this,g.Lw(this.seekTo,b))}stop(){if(mm(this)){this.G?this.G.stop(null,g.OU,Zh(this,"stopVideo")):Ph(this,"stopVideo");var b=xL(this);b.index=-1;b.videoId= "";Ty(b);ch(this,b);this.publish("remotePlayerChange")}else Xm(this,this.stop)}setVolume(b,R){if(mm(this)){var h=xL(this);if(this.Y){if(h.volume!=b){const K=Math.round(b)/100;this.Y.setReceiverVolumeLevel(K,(0,g.Ms)(function(){Cv("set receiver volume: "+K)},this),(0,g.Ms)(function(){this.t9("failed to set receiver volume.")},this))}h.muted!=R&&this.Y.setReceiverMuted(R,(0,g.Ms)(function(){Cv("set receiver muted: "+R)},this),(0,g.Ms)(function(){this.t9("failed to set receiver muted.")},this))}else{const K= {volume:b, muted:R};h.volume!=-1&&(K.delta=b-h.volume);Ph(this,"setVolume",K)}h.muted=R;h.volume=b;ch(this,h)}else Xm(this,g.Lw(this.setVolume,b,R))}K(b,R){if(mm(this)){var h=xL(this);b={videoId:b};R&&(h.trackData={trackName:R.name,languageCode:R.languageCode,sourceLanguageCode:R.translationLanguage?R.translationLanguage.languageCode:"",languageName:R.languageName,kind:R.kind},b.style=g.z1(R.style),g.pj(b,h.trackData));Ph(this,"setSubtitlesTrack",b);ch(this,h)}else Xm(this,g.Lw(this.K,b,R))}setAudioTrack(b, R){mm(this)?(R=R.getLanguageInfo().getId(),Ph(this,"setAudioTrack",{videoId:b,audioTrackId:R}),b=xL(this),b.audioTrackId=R,ch(this,b)):Xm(this,g.Lw(this.setAudioTrack,b,R))}playVideo(b,R,h,K=null,I=null,N=null,p=null){const l=xL(this),a={videoId:b};h!==void 0&&(a.currentIndex=h);eN(l,b,h||0);R!==void 0&&(kL(l,R),a.currentTime=R);K&&(a.listId=K);I&&(a.playerParams=I);N&&(a.clickTrackingParams=N);p&&(a.locationInfo=g.z1(p));Ph(this,"setPlaylist",a);K||ch(this,l)}vF(b,R){if(mm(this)){if(b&&R){const h= xL(this);eN(h,b,R);ch(this,h)}Ph(this,"previous")}else Xm(this,g.Lw(this.vF,b,R))}nextVideo(b,R){if(mm(this)){if(b&&R){const h=xL(this);eN(h,b,R);ch(this,h)}Ph(this,"next")}else Xm(this,g.Lw(this.nextVideo,b,R))}uL(){if(mm(this)){Ph(this,"clearPlaylist");var b=xL(this);b.reset();ch(this,b);this.publish("remotePlayerChange")}else Xm(this,this.uL)}nR(){mm(this)?Ph(this,"dismissAutoplay"):Xm(this,this.nR)}dispose(){if(this.X!=3){const b=this.X;this.X=3;this.publish("proxyStateChange",b,this.X)}super.dispose()}X5(){w9z(this); this.V=null;this.S.clear();Q_(this,null);super.X5()}T6(b){if((b!=this.X||b==2)&&this.X!=3&&b!=0){var R=this.X;this.X=b;this.publish("proxyStateChange",R,b);if(b==1)for(;!this.S.isEmpty();)R=b=this.S,R.G.length===0&&(R.G=R.Y,R.G.reverse(),R.Y=[]),b.G.pop().apply(this);else b==3&&this.dispose()}}JX(b,R){this.publish(b,R)}SY(b){if(!b)this.J(null),Q_(this,null);else if(this.Y.receiver.volume){b=this.Y.receiver.volume;const R=xL(this),h=Math.round(100*b.level||0);if(R.volume!=h||R.muted!=b.muted)Cv("Cast volume update: "+ b.level+(b.muted?" muted":"")),R.volume=h,R.muted=!!b.muted,ch(this,R)}}J(b){Cv("Cast media: "+!!b);this.G&&this.G.removeUpdateListener(this.G6);if(this.G=b)this.G.addUpdateListener(this.G6),FtH(this),this.publish("remotePlayerChange")}gp(b){b?(FtH(this),this.publish("remotePlayerChange")):this.J(null)}AY(){Ph(this,"sendDebugCommand",{debugCommand:"stats4nerds "})}vY(){const b=CXH();b&&Q_(this,b)}t9(b){Vl("CP",b)}};var fb=class extends g.NU{constructor(b,R=!1){var h=Fm,K=$e();super();this.J=NaN;this.gp=!1;this.C=this.G6=this.T6=this.MJ=NaN;this.nR=[];this.S=this.K=this.V=this.G=this.Y=null;this.pR=h;this.JX=R;this.nR.push(g.D5(window,"beforeunload",()=>{this.D(2)})); this.X=[];this.G=new ES;this.KR=b.id;this.vY=b.idType;this.Y=wyH(this.pR,K,this.SY,this.vY=="shortLived",this.KR);this.Y.listen("channelOpened",()=>{oWz(this)}); this.Y.listen("channelClosed",()=>{V_("Channel closed");isNaN(this.J)?gQ(!0):gQ();this.dispose()}); this.Y.listen("channelError",I=>{gQ();isNaN(this.U())?(I==1&&this.vY=="shortLived"&&this.publish("browserChannelAuthError",I),V_(`Channel error: ${I} without reconnection`),this.dispose()):(this.gp=!0,V_("Channel error: "+I+" with reconnection in "+this.U()+" ms"),M7(this,2))}); this.Y.listen("channelMessage",I=>{aG2(this,I)}); this.Y.VZ(b.token);this.subscribe("remoteQueueChange",()=>{var I=this.G.videoId;g.lQ()&&g.Iz("yt-remote-session-video-id",I)})}connect(b,R){if(R){var h=R.listId; const K=R.videoId,I=R.videoIds,N=R.playerParams,p=R.clickTrackingParams,l=R.index,a={videoId:K},v=R.currentTime,B=R.locationInfo;R=R.loopMode;v!==void 0&&(a.currentTime=v<=5?0:v);N&&(a.playerParams=N);B&&(a.locationInfo=B);p&&(a.clickTrackingParams=p);h&&(a.listId=h);I&&I.length>0&&(a.videoIds=I.join(","));l!==void 0&&(a.currentIndex=l);this.JX&&(a.loopMode=R||"LOOP_MODE_OFF");h&&(this.G.listId=h);this.G.videoId=K;this.G.index=l||0;this.G.state=3;kL(this.G,v);this.S="UNSUPPORTED";h=this.JX?"setInitialState": "setPlaylist";V_(`Connecting with ${h} and params: ${g.z1(a)}`);this.Y.connect({method:h,params:g.z1(a)},b,pkH())}else V_("Connecting without params"),this.Y.connect({},b,pkH());vXz(this)}VZ(b){this.Y.VZ(b)}dispose(){this.HY()||(g.kB("yt.mdx.remote.remoteClient_",null),this.publish("beforeDispose"),M7(this,3));super.dispose()}X5(){rN(this);L$(this);C$(this);g.m8(this.G6);this.G6=NaN;g.m8(this.C);this.C=NaN;this.V=null;g.bQ(this.nR);this.nR.length=0;this.Y.dispose();super.X5();this.S=this.K=this.X= this.G=this.Y=null}Zr(b){if(!this.X||this.X.length===0)return!1;for(const R of this.X)if(!R.capabilities.has(b))return!1;return!0}RH(){let b=3;this.HY()||(b=0,isNaN(this.U())?this.Y.m6()&&isNaN(this.J)&&(b=1):b=2);return b}D(b){V_("Disconnecting with "+b);g.kB("yt.mdx.remote.remoteClient_",null);rN(this);this.publish("beforeDisconnect",b);b==1&&gQ();this.Y.disconnect(b);this.dispose()}CR(){let b=this.G;this.V&&(b=this.G.clone(),eN(b,this.V,b.index));return OS(b)}Ty(b){const R=new ES(b);R.videoId&& R.videoId!=this.G.videoId&&(this.V=R.videoId,g.m8(this.G6),this.G6=g.QB(()=>{if(this.V){const K=this.V;this.V=null;this.G.videoId!=K&&wN(this,"getNowPlaying")}},5E3)); const h=[];this.G.listId==R.listId&&this.G.videoId==R.videoId&&this.G.index==R.index||h.push("remoteQueueChange");this.G.playerState==R.playerState&&this.G.volume==R.volume&&this.G.muted==R.muted&&YL(this.G)==YL(R)&&g.z1(this.G.trackData)==g.z1(R.trackData)||h.push("remotePlayerChange");this.G.reset(b);g.pr(h,function(K){this.publish(K)},this)}NJ(){const b=this.Y.getDeviceId(),R=g.jc(this.X,function(h){return h.type=="REMOTE_CONTROL"&&h.id!=b}); return R?R.id:""}U(){return this.Y.Jy()}wp(){return this.S||"UNSUPPORTED"}fR(){return this.K||""}xZ(){!isNaN(this.U())&&this.Y.c9()}PH(b,R){wN(this,b,R);qqp(this)}SY(){var b=g.pX("SAPISID","")||g.pX("__Secure-1PAPISID")||"",R=g.pX("__Secure-3PAPISID","")||"";if(!b&&!R)return"";b=g.Zc(g.xg(b),2);R=g.Zc(g.xg(R),2);return g.Zc(g.xg(`,${b},${R}`),2)}};fb.prototype.subscribe=fb.prototype.subscribe;fb.prototype.unsubscribeByKey=fb.prototype.pN;fb.prototype.getProxyState=fb.prototype.RH; fb.prototype.disconnect=fb.prototype.D;fb.prototype.getPlayerContextData=fb.prototype.CR;fb.prototype.setPlayerContextData=fb.prototype.Ty;fb.prototype.getOtherConnectedRemoteId=fb.prototype.NJ;fb.prototype.getReconnectTimeout=fb.prototype.U;fb.prototype.getAutoplayMode=fb.prototype.wp;fb.prototype.getAutoplayVideoId=fb.prototype.fR;fb.prototype.reconnect=fb.prototype.xZ;fb.prototype.sendMessage=fb.prototype.PH;fb.prototype.getXsrfToken=fb.prototype.SY; fb.prototype.isCapabilitySupportedOnConnectedDevices=fb.prototype.Zr;var iUr=class extends wr{constructor(b){super("ScreenServiceProxy");this.Ui=b;this.G=[];this.G.push(this.Ui.$_s("screenChange",(0,g.Ms)(this.Y,this)));this.G.push(this.Ui.$_s("onlineScreenChange",(0,g.Ms)(this.X,this)))}Rw(b){return this.Ui.$_gs(b)}contains(b){return!!this.Ui.$_c(b)}get(b){return this.Ui.$_g(b)}start(){this.Ui.$_st()}add(b,R,h){this.Ui.$_a(b,R,h)}remove(b,R,h){this.Ui.$_r(b,R,h)}xn(b,R,h,K){this.Ui.$_un(b,R,h,K)}X5(){const b=this.G.length;for(let R=0;R{GD3(this,K)}); g.n(this,this.events);this.events.j(R,"onCaptionsTrackListChanged",this.xZ);this.events.j(R,"captionschanged",this.pR);this.events.j(R,"captionssettingschanged",this.JX);this.events.j(R,"videoplayerreset",this.D);this.events.j(R,"mdxautoplaycancel",()=>{this.Cz.nR()}); R.N("enable_mdx_video_play_directly")&&this.events.j(R,"videodatachange",()=>{Sqn(this.G)||y6(this)||jj(this,0)}); b=this.Cz;b.HY();b.subscribe("proxyStateChange",this.gp,this);b.subscribe("remotePlayerChange",this.S,this);b.subscribe("remoteQueueChange",this.D,this);b.subscribe("previousNextChange",this.MJ,this);b.subscribe("nowAutoplaying",this.T6,this);b.subscribe("autoplayDismissed",this.nR,this);g.n(this,this.Y);g.n(this,this.X);g.n(this,this.G6);g.n(this,this.C);g.n(this,this.U);this.JX();this.D();this.S()}X5(){super.X5();this.Y.stop();this.X.stop();this.G6.stop();const b=this.Cz;b.unsubscribe("proxyStateChange", this.gp,this);b.unsubscribe("remotePlayerChange",this.S,this);b.unsubscribe("remoteQueueChange",this.D,this);b.unsubscribe("previousNextChange",this.MJ,this);b.unsubscribe("nowAutoplaying",this.T6,this);b.unsubscribe("autoplayDismissed",this.nR,this);this.Cz=this.G=null}kH(b,...R){if(this.Cz.X!=2)if(y6(this)){if(xL(this.Cz).playerState!=1081||b!=="control_seek")switch(b){case "control_toggle_play_pause":xL(this.Cz).isPlaying()?this.Cz.pause():this.Cz.play();break;case "control_play":this.Cz.play(); break;case "control_pause":this.Cz.pause();break;case "control_seek":this.U.V(R[0],R[1]);break;case "control_subtitles_set_track":AI(this,R[0]);break;case "control_set_audio_track":this.setAudioTrack(R[0])}}else switch(b){case "control_toggle_play_pause":case "control_play":case "control_pause":b=this.A.getCurrentTime();jj(this,b===0?void 0:b);break;case "control_seek":jj(this,R[0]);break;case "control_subtitles_set_track":AI(this,R[0]);break;case "control_set_audio_track":this.setAudioTrack(R[0])}}pR(b){this.G6.Hw(b)}KR(b){this.kH("control_subtitles_set_track", g.RT(b)?null:b)}JX(){const b=this.A.getOption("captions","track");g.RT(b)||AI(this,b)}FX(b){this.G.FX(b,this.A.getVideoData().lengthSeconds)}xZ(){g.RT(this.V)||gXc(this,this.V);this.J=!1}gp(b,R){this.X.stop();R===2&&this.vY()}S(){if(y6(this)){this.Y.stop();var b=xL(this.Cz);switch(b.playerState){case 1080:case 1081:case 1084:case 1085:this.G.eS=1;break;case 1082:case 1083:this.G.eS=0;break;default:this.G.eS=-1}switch(b.playerState){case 1081:case 1:this.n0(new g.tk(8));this.SY();break;case 1085:case 3:this.n0(new g.tk(9)); break;case 1083:case 0:this.n0(new g.tk(2));this.U.stop();this.FX(this.A.getVideoData().lengthSeconds);break;case 1084:this.n0(new g.tk(4));break;case 2:this.n0(new g.tk(4));this.FX(YL(b));break;case -1:this.n0(new g.tk(64));break;case -1E3:this.n0(new g.tk(128,{errorCode:"mdx.remoteerror",errorMessage:"Este v\u00eddeo no se puede reproducir de forma remota.",Zc:2}))}const h=xL(this.Cz).trackData;b=h;var R=this.V;(b||R?b&&R&&b.trackName==R.trackName&&b.languageCode==R.languageCode&&b.languageName== R.languageName&&b.kind==R.kind:1)||(this.V=h,gXc(this,h));b=xL(this.Cz);b.volume===-1||Math.round(this.A.getVolume())===b.volume&&this.A.isMuted()===b.muted||this.C.isActive()||this.NJ()}else W2t(this)}MJ(){this.A.publish("mdxpreviousnextchange")}D(){y6(this)||W2t(this)}T6(b){isNaN(b)||this.A.publish("mdxnowautoplaying",b)}nR(){this.A.publish("mdxautoplaycanceled")}setAudioTrack(b){y6(this)&&this.Cz.setAudioTrack(tI(this).videoId,b)}seekTo(b,R){xL(this.Cz).playerState===-1?jj(this,b):R&&this.Cz.seekTo(b)}NJ(){if(y6(this)){var b= xL(this.Cz);this.events.Ac(this.Zr);b.muted?this.A.mute():this.A.unMute();this.A.setVolume(b.volume);this.Zr=this.events.j(this.A,"onVolumeChange",R=>{GD3(this,R)})}}SY(){this.Y.stop(); if(!this.Cz.HY()){var b=xL(this.Cz);b.isPlaying()&&this.n0(new g.tk(8));this.FX(YL(b));this.Y.start()}}vY(){this.X.stop();this.Y.stop();const b=this.Cz.Jy();this.Cz.X==2&&!isNaN(b)&&this.X.start()}n0(b){this.X.stop();const R=this.K;if(!g.Gh(R,b)){const h=b.G(2);h!==this.K.G(2)&&this.A.IL(h);this.K=b;nXn(this.G,R,b)}}};var ZUx=class extends g.Tv{constructor(b,R){super(b);this.G=R}getCurrentTime(){return this.G.getCurrentTime()}getDuration(){return this.G.getDuration()}hh(){return this.G.hh()}U_(){return this.G.U_()}QK(){return this.G.QK()}SU(){return this.G.SU()}getPlayerState(){return this.G.p5}isAtLiveHead(){return this.G.isAtLiveHead()}pauseVideo(){ie(this.G,"control_pause")}async playVideo(){ie(this.G,"control_play")}seekTo(b,R){ie(this.G,"control_seek",b,!R?.Il)}Xz(b){ie(this.G,"control_set_audio_track",b); return!0}};var cYg=class extends g.w{constructor(){super({B:"div",Z:"ytp-mdx-popup-dialog",O:{role:"dialog"},W:[{B:"div",Z:"ytp-mdx-popup-dialog-inner-content",W:[{B:"div",Z:"ytp-mdx-popup-title",IH:"No has iniciado sesi\u00f3n"},{B:"div",Z:"ytp-mdx-popup-description",IH:"Los v\u00eddeos que veas podr\u00edan aparecer en el historial de reproducciones de la TV e influir en las recomendaciones. Puedes evitarlo si cancelas e inicias sesi\u00f3n en YouTube desde tu ordenador."},{B:"div",Z:"ytp-mdx-privacy-popup-buttons", W:[{B:"button",F5:["ytp-button","ytp-mdx-privacy-popup-cancel"],IH:"Cancelar"},{B:"button",F5:["ytp-button","ytp-mdx-privacy-popup-confirm"],IH:"Confirmar"}]}]}]});this.fade=new g.Sg(this,250);this.cancelButton=this.yX("ytp-mdx-privacy-popup-cancel");this.confirmButton=this.yX("ytp-mdx-privacy-popup-confirm");g.n(this,this.fade);this.j(this.cancelButton,"click",this.G);this.j(this.confirmButton,"click",this.Y)}zD(){this.fade.show()}aT(){this.fade.hide()}G(){SQ("mdx-privacy-popup-cancel");this.aT()}Y(){SQ("mdx-privacy-popup-confirm"); this.aT()}};var upz=class extends g.w{constructor(b){super({B:"div",Z:"ytp-remote",W:[{B:"div",Z:"ytp-remote-display-status",W:[{B:"div",Z:"ytp-remote-display-status-icon",W:[g.Zf3()]},{B:"div",Z:"ytp-remote-display-status-text",IH:"{{statustext}}"}]}]});this.api=b;this.fade=new g.Sg(this,250);g.n(this,this.fade);this.j(b,"presentingplayerstatechange",this.onStateChange);this.Na(b.getPlayerStateObject())}onStateChange(b){this.Na(b.state)}Na(b){if(this.api.getPresentingPlayerType()===3){const R={RECEIVER_NAME:this.api.getOption("remote", "currentReceiver").name};b=b.G(128)?g.zc("No se ha podido reproducir el v\u00eddeo en $RECEIVER_NAME",R):b.isPlaying()||b.isPaused()?g.zc("El v\u00eddeo se est\u00e1 reproduciendo en $RECEIVER_NAME",R):g.zc("Conectado/a a $RECEIVER_NAME",R);this.updateValue("statustext",b);this.fade.show()}else this.fade.hide()}};var XjR=class extends g.y9{constructor(b,R){super("Reproducir en",1,b,R);this.A=b;this.yb={};this.j(b,"onMdxReceiversChange",this.J);this.j(b,"presentingplayerstatechange",this.J);this.J()}J(){var b=this.A.getOption("remote","receivers");b&&b.length>1&&!this.A.getOption("remote","quickCast")?(this.yb=g.Pp(b,this.S,this),this.V(g.an(b,this.S)),b=this.A.getOption("remote","currentReceiver"),b=this.S(b),this.options[b]&&this.Y(b),this.enable(!0)):this.enable(!1)}S(b){return b.key}X(b){return b==="cast-selector-receiver"? "Enviar...":this.yb[b].name}G(b){super.G(b);this.A.setOption("remote","currentReceiver",this.yb[b]);this.Gy.aT()}};g.jR("remote",class extends g.AW{constructor(b){super(b);this.uB={key:tZ(),name:"Este ordenador"};this.FQ=null;this.subscriptions=[];this.UR=this.Cz=null;this.yb=[this.uB];this.QD=this.uB;this.p5=new g.tk(64);this.JR=0;this.eS=-1;this.fA=!1;this.Qk=this.w0=this.Le=null;if(!g.Mz(this.player.L())&&!g.LW(this.player.L())){b=this.player;var R=g.hT(b);R&&(R=R.yA())&&(R=new XjR(b,R),g.n(this,R));R=new upz(b);g.n(this,R);g.dL(b,R.element,4);this.Le=new cYg;g.n(this,this.Le);g.dL(b,this.Le.element,4);this.fA= !!s_()}}create(){var b=this.player.L();const R=g.LB(b);b={device:"Desktop",app:"youtube-desktop",loadCastApiSetupScript:b.N("mdx_load_cast_api_bootstrap_script"),enableDialLoungeToken:b.N("enable_dial_short_lived_lounge_token"),enableCastLoungeToken:b.N("enable_cast_short_lived_lounge_token")};tyz(R,b);this.subscriptions.push(g.Iq("yt-remote-before-disconnect",this.XD,this));this.subscriptions.push(g.Iq("yt-remote-connection-change",this.ub,this));this.subscriptions.push(g.Iq("yt-remote-receiver-availability-change", this.aO,this));this.subscriptions.push(g.Iq("yt-remote-auto-connect",this.hV,this));this.subscriptions.push(g.Iq("yt-remote-receiver-resumed",this.M$,this));this.subscriptions.push(g.Iq("mdx-privacy-popup-confirm",this.T$,this));this.subscriptions.push(g.Iq("mdx-privacy-popup-cancel",this.Y1,this));this.aO()}load(){this.player.cancelPlayback();super.load();this.Qk=new ZUx(this.player.L(),this);this.player.qh(this.Qk);this.FQ=new P5R(this,this.player,this.Cz);var b=(b=Uq3())?b.currentTime:0;const R= Hf()?new mqz:null;b==0&&R&&(b=YL(xL(R)));b!==0&&this.FX(b);nXn(this,this.p5,this.p5);this.player.xY(6)}unload(){this.player.publish("mdxautoplaycanceled");this.player.y5();this.QD=this.uB;g.IZ(this.FQ,this.Cz);this.Cz=this.Qk=this.FQ=null;super.unload();this.player.xY(5);z7(this)}X5(){g.Nt(this.subscriptions);super.X5()}getAdState(){return this.eS}hasPrevious(){return this.Cz?xL(this.Cz).hasPrevious:!1}hasNext(){return this.Cz?xL(this.Cz).hasNext:!1}FX(b,R){this.JR=b||0;this.player.publish("progresssync", b,R);g.oj(this.player,"onVideoProgress",b||0)}getCurrentTime(){return this.JR}getDuration(){return xL(this.Cz).getDuration()||0}hh(){var b=xL(this.Cz);return b.V?b.G+Jd(b):b.G}U_(){return xL(this.Cz).loadedTime}QK(){return rox(xL(this.Cz))}SU(){var b=xL(this.Cz);return b.Y>0?b.Y+Jd(b):b.Y}getProgressState(){const b=xL(this.Cz),R=this.player.getVideoData();return{airingStart:0,airingEnd:0,allowSeeking:b.playerState!=1081&&this.player.Hr(),clipEnd:R.clipEnd,clipStart:R.clipStart,current:this.getCurrentTime(), displayedStart:-1,duration:this.getDuration(),ingestionTime:this.hh(),isAtLiveHead:this.isAtLiveHead(),loaded:this.U_(),seekableEnd:this.QK(),seekableStart:this.SU(),offset:0,viewerLivestreamJoinMediaTime:0}}isAtLiveHead(){return rox(xL(this.Cz))-this.getCurrentTime()<=1}nextVideo(){this.Cz&&this.Cz.nextVideo()}vF(){this.Cz&&this.Cz.vF()}XD(b){b===1&&(this.UR=this.Cz?xL(this.Cz):null)}ub(){var b=Hf()?new mqz:null;if(b){const R=this.QD;this.loaded&&this.unload();this.Cz=b;this.UR=null;R.key!==this.uB.key&& (this.QD=R,this.load())}else g.$l(this.Cz),this.Cz=null,this.loaded&&(this.unload(),(b=this.UR)&&b.videoId===this.player.getVideoData().videoId&&this.player.cueVideoById(b.videoId,YL(b)));this.player.publish("videodatachange","newdata",this.player.getVideoData(),3)}aO(){var b=[this.uB],R=b.concat;const h=jvn();Gy()&&g.NC("yt-remote-cast-available")&&h.push({key:"cast-selector-receiver",name:"Cast..."});this.yb=R.call(b,h);b=pb()||this.uB;U_(this,b);g.oj(this.player,"onMdxReceiversChange")}hV(){const b= pb();U_(this,b)}M$(){this.QD=pb()}T$(){this.fA=!0;z7(this);df=!1;le&&vf(le,1);le=null}Y1(){this.fA=!1;z7(this);U_(this,this.uB);this.QD=this.uB;df=!1;le=null;this.player.playVideo()}iR(b,R){switch(b){case "casting":return this.loaded;case "receivers":return this.yb;case "currentReceiver":return R&&(R.key==="cast-selector-receiver"?Wh():U_(this,R)),this.loaded?this.QD:this.uB;case "quickCast":return this.yb.length===2&&this.yb[1].key==="cast-selector-receiver"?(R&&Wh(),!0):!1}}AY(){this.Cz.AY()}Bd(){return!1}getOptions(){return["casting", "receivers","currentReceiver","quickCast"]}isLoggedIn(){return g.x("PLAYER_CONFIG")?.args?.authuser!==void 0?!0:!(!g.x("SESSION_INDEX")&&!g.x("LOGGED_IN"))}});})(_yt_player);