t dQ(D)}finally{var X=D.V;
D.V=[];var B=X;X=X.length;for(let C=0;C<X;++C)Na(D.L,B[C]);Gk(D);Gk(D)}},Gk=function(D){D.publish("handlerOpened");
D.D3.L("BROWSER_CHANNEL")},ei=function(D){if(D.L){const X=D.G2(),B=D.L.rY||{};
X?B["x-youtube-lounge-xsrf-token"]=X:delete B["x-youtube-lounge-xsrf-token"];D.L.rY=B}},dQ=function(D){if(!D.WZ)return K1U(D);
D.vZ===null&&(D.vZ=K1U(D));return D.vZ},K1U=function(D){return g.ZT(D.HZ().then(X=>{if(D.L){let B=D.L.rY||{};
X&&Object.keys(X).length>0?B={...B,...X}:delete B.Authorization;D.L.rY=B}}).JH(()=>{}),()=>{D.vZ=null})},Z7=function(D){this.scheme="https";
this.port=this.domain="";this.L="/api/lounge";this.Z=!0;D=D||document.location.href;const X=Number(g.td(D)[4]||null)||"";X&&(this.port=":"+X);this.domain=g.re(D)||"";D=g.il();D.search("MSIE")>=0&&(D=D.match(/MSIE ([\d.]+)/)[1],g.mk(D,"10.0")<0&&(this.Z=!1))},Ql=function(D,X){let B=D.L;
D.Z&&(B=D.scheme+"://"+D.domain+D.port+D.L);return g.lm(B+X,{})},om5=function(D){g.yx(D.channel,"m",()=>{D.S=3;
D.U.reset();D.K=null;D.Y=0;for(const X of D.J)D.channel&&D.channel.send(X);D.J=[];D.publish("webChannelOpened");D.G2.L("WEB_CHANNEL")});
g.yx(D.channel,"n",()=>{D.S=0;D.U.isActive()||D.publish("webChannelClosed");const X=D.channel?.V().U();X&&(D.J=[...X]);D.s7.L("WEB_CHANNEL")});
g.yx(D.channel,"p",X=>{const B=X.data;B[0]==="gracefulReconnect"?(D.U.start(),D.channel&&D.channel.close()):D.publish("webChannelMessage",new zZN(B[0],B[1]));D.gf=X.statusCode;D.vZ.L("WEB_CHANNEL")});
g.yx(D.channel,"o",()=>{D.gf===401||D.U.start();D.publish("webChannelError");D.U7.L("WEB_CHANNEL","")})},Lf=function(D){const X=D.pv();
X?D.V["x-youtube-lounge-xsrf-token"]=X:delete D.V["x-youtube-lounge-xsrf-token"]},Z1N=function(D,X,B=()=>"",C,V){const x=()=>new oP(Ql(D,"/bc"),X,!1,B,C);
return g.GF("enable_mdx_web_channel_desktop")?new eZ0(()=>new dEg(Ql(D,"/wc"),X,B)):new Geg(x,V)},Emh=function(){var D=QW5;
L18();gQ.push(D);gmg()},EE=function(D,X){L18();
const B=nmP(D,String(X));gQ.length==0?wI2(B):(gmg(),g.Lu(gQ,function(C){C(B)}))},nf=function(D){EE("CP",D)},L18=function(){gQ||(gQ=g.MX("yt.mdx.remote.debug.handlers_")||[],g.Jz("yt.mdx.remote.debug.handlers_",gQ))},wI2=function(D){const X=(wQ+1)%50;
wQ=X;Tk[X]=D;Si||(Si=X==49)},gmg=function(){var D=gQ;
if(Tk[0]){var X=Si?wQ:-1;do{X=(X+1)%50;const B=Tk[X];g.Lu(D,function(C){C(B)})}while(X!=wQ);
Tk=Array(50);wQ=-1;Si=!1}},nmP=function(D,X){let B=(Date.now()-T5N)/1E3;
B.toFixed&&(B=B.toFixed(3));const C=[];C.push("[",B+"s","] ");C.push("[","yt.mdx.remote","] ");C.push(D+": "+X,"\n");return C.join("")},Px=function(D){g.Bl.call(this);
this.S=D;this.screens=[]},SSP=function(D,X){const B=D.get(X.uuid)||D.get(X.id);
if(B)return D=B.name,B.id=X.id||B.id,B.name=X.name,B.token=X.token,B.uuid=X.uuid||B.uuid,B.name!=D;D.screens.push(X);return!0},PHN=function(D,X){let B=D.screens.length!=X.length;
D.screens=g.gu(D.screens,function(V){return!!M8(X,V)});
const C=X.length;for(let V=0;V<C;V++)B=SSP(D,X[V])||B;return B},tvK=function(D,X){const B=D.screens.length;
D.screens=g.gu(D.screens,function(C){return!(C||X?!C!=!X?0:C.id==X.id:1)});
return D.screens.length<B},OE=function(D){Px.call(this,"LocalScreenService");
this.Z=D;this.L=NaN;tf(this);this.info("Initializing with "+hp(this.screens))},O1K=function(D){if(D.screens.length){const X=g.E$(D.screens,function(C){return C.id}),B=Ql(D.Z,"/pairing/get_lounge_token_batch");
D.Z.sendRequest("POST",B,{screen_ids:X.join(",")},(0,g.U$)(D.nC,D),(0,g.U$)(D.Fx,D))}},tf=function(D){if(g.GF("deprecate_pair_servlet_enabled"))return PHN(D,[]);
var X=Tig(Dc2());X=g.gu(X,function(B){return!B.uuid});
return PHN(D,X)},rQ=function(D,X){BC2(g.E$(D.screens,nwW));
X&&Xdg()},Dj=function(D){EE("OnlineScreenService",D)},XF=function(D){isNaN(D.U)||g.oA(D.U);
D.U=g.IA((0,g.U$)(D.Y,D),D.V>0&&D.V<g.c1()?2E4:1E4)},Bv=function(D,X){a:if(mZ(X)!=mZ(D.L))var B=!1;
else{B=g.IX(X);var C=B.length;for(let V=0;V<C;++V)if(!D.L[B[V]]){B=!1;break a}B=!0}B||(Dj("Updated online screens: "+g.fj(D.L)),D.L=X,D.publish("screenChange"));rvP(D)},Cd=function(D,X,B){const C=Ql(D.G,"/pairing/get_screen_availability");
D.G.sendRequest("POST",C,{lounge_token:X.token},(0,g.U$)(function(V){V=V.screens||[];const x=V.length;for(let y=0;y<x;++y)if(V[y].loungeToken==X.token){B(V[y].status=="online");return}B(!1)},D),(0,g.U$)(function(){B(!1)},D))},rvP=function(D){D=g.IX(g.Ut(D.L,function(X){return X}));
g.HA(D);D.length?g.xk("yt-remote-online-screen-ids",D.join(","),60):g.mh("yt-remote-online-screen-ids")},DDA=function(D){const X={};
g.Lu(D.S(),function(B){B.token?X[B.token]=B.id:this.o3("Requesting availability of screen w/o lounge token.")});
return X},VX=function(D,X=!1){Px.call(this,"ScreenService");
this.V=D;this.Y=X;this.L=this.Z=null;this.U=[];this.G={};X$g(this)},C88=function(D,X,B,C,V,x){D.info("getAutomaticScreenByIds "+B+" / "+X);
B||(B=D.G[X]);const y=D.HO();let m=B?Ap(y,B):null;B&&(D.Y||m)||(m=Ap(y,X));if(m){m.uuid=X;const l=xV(D,m);Cd(D.L,l,function(W){V(W?l:null)})}else B?B_X(D,B,(0,g.U$)(function(l){const W=xV(this,new fP({name:C,
screenId:B,loungeToken:l,dialId:X||""}));Cd(this.L,W,function(v){V(v?W:null)})},D),x):V(null)},VL5=function(D,X){const B=D.screens.length;
for(let C=0;C<B;++C)if(D.screens[C].name==X)return D.screens[C];return null},xDA=function(D,X,B){Cd(D.L,X,B)},B_X=function(D,X,B,C){D.info("requestLoungeToken_ for "+X);
const V={postParams:{screen_ids:X},method:"POST",context:D,onSuccess:function(x,y){x=y&&y.screens||[];x[0]&&x[0].screenId==X?B(x[0].loungeToken):C(Error("Missing lounge token in token response"))},
onError:function(){C(Error("Request screen lounge token failed"))}};
g.ns(Ql(D.V,"/pairing/get_lounge_token_batch"),V)},yEg=function(D){D.screens=D.Z.HO();
var X=D.G;const B={};for(var C in X)B[X[C]]=C;X=D.screens.length;for(C=0;C<X;++C){const V=D.screens[C];V.uuid=B[V.id]||""}D.info("Updated manual screens: "+hp(D.screens))},X$g=function(D){yX(D);
D.Z=new OE(D.V);D.Z.subscribe("screenChange",(0,g.U$)(D.d2,D));yEg(D);D.Y||(D.U=Tig(g.ys("yt-remote-automatic-screen-cache")||[]));yX(D);D.info("Initializing automatic screens: "+hp(D.U));D.L=new mDP(D.V,(0,g.U$)(D.HO,D,!0));D.L.subscribe("screenChange",(0,g.U$)(function(){this.publish("onlineScreenChange")},D))},xV=function(D,X){var B=D.get(X.id);
B?(B.uuid=X.uuid,X=B):((B=Ap(D.U,X.uuid))?(B.id=X.id,B.token=X.token,X=B):D.U.push(X),D.Y||ijX(D));yX(D);D.G[X.uuid]=X.id;g.xk("yt-remote-device-id-map",D.G,31536E3);return X},ijX=function(D){D=g.gu(D.U,X=>X.idType!="shortLived");
g.xk("yt-remote-automatic-screen-cache",g.E$(D,nwW))},yX=function(D){D.G=g.ys("yt-remote-device-id-map")||{}},mj=function(D,X,B){g.Bl.call(this);
this.U7=B;this.V=D;this.Z=X;this.L=null},iX=function(D,X){D.L=X;
D.publish("sessionScreen",D.L)},liA=function(D,X){D.L&&(D.L.token=X,xV(D.V,D.L));
D.publish("sessionScreen",D.L)},lX=function(D,X){EE(D.U7,X)},WXP=function(D,X){g.oA(D.Z3);
D.Z3=0;X?D.config_.enableCastLoungeToken&&X.loungeToken?X.deviceId?D.L&&D.L.uuid==X.deviceId||(X.loungeTokenRefreshIntervalMs?$D2(D,{name:D.Z.friendlyName,screenId:X.screenId,loungeToken:X.loungeToken,dialId:X.deviceId,screenIdType:"shortLived"},X.loungeTokenRefreshIntervalMs):(g.WB(Error(`No loungeTokenRefreshIntervalMs presents in mdxSessionStatusData: ${JSON.stringify(X)}.`)),$V(D,X.screenId))):(g.WB(Error(`No device id presents in mdxSessionStatusData: ${JSON.stringify(X)}.`)),$V(D,X.screenId)):
$V(D,X.screenId):D.xa(Error("Waiting for session status timed out."))},v4h=function(D){g.oA(D.N);
D.N=0;g.oA(D.Y);D.Y=0;g.oA(D.Z3);D.Z3=0;g.oA(D.G);D.G=0;g.oA(D.K);D.K=0},fih=function(D,X){D.info("sendYoutubeMessage_: "+X+" "+g.fj());
const B={};B.type=X;D.U?D.U.sendMessage("urn:x-cast:com.google.youtube.mdx",B,()=>{},(0,g.U$)(function(){lX(this,"Failed to send message: "+X+".")},D)):lX(D,"Sending yt message without session: "+g.fj(B))},p$U=function(D){fih(D,"getLoungeToken");
g.oA(D.G);D.G=g.IA(()=>{upg(D,null)},3E4)},Wv=function(D,X){g.oA(D.K);
D.K=0;X==0?p$U(D):D.K=g.IA(()=>{p$U(D)},X)},upg=function(D,X){g.oA(D.G);
D.G=0;let B=null;X?X.loungeToken?D.L?.token==X.loungeToken&&(B="staleLoungeToken"):B="missingLoungeToken":B="noLoungeTokenResponse";B?(D.info("Did not receive a new lounge token in onLoungeToken_ with "+`data: ${JSON.stringify(X)}, error: ${B}`),Wv(D,3E4)):(liA(D,X.loungeToken),Wv(D,X.loungeTokenRefreshIntervalMs))},$V=function(D,X){X?(D.info("onConnectedScreenId_: Received screenId: "+X),D.L&&D.L.id==X||D.vZ(X,B=>{iX(D,B)},()=>D.xa(),5)):D.xa(Error("Waiting for session status timed out."))},hUC=
function(D,X,B,C){g.oA(D.Y);
D.Y=0;xDA(D.V,X,V=>{V||C<0?B(V):D.Y=g.IA(()=>{hUC(D,X,B,C-1)},300)})},$D2=function(D,X,B){D.info(`onConnectedScreenData_: Received screenData: ${JSON.stringify(X)}`);
const C=new fP(X);hUC(D,C,V=>{V?(xV(D.V,C),iX(D,C),Wv(D,B)):(g.WB(Error(`CastSession, RemoteScreen from screenData: ${JSON.stringify(X)} is not online.`)),D.xa())},5)},vv=function(D){return new Promise(X=>{D.pv=Jp();
if(D.G2){const B=new chrome.cast.DialLaunchResponse(!0,JE8(D));X(B);ML8(D)}else D.J=()=>{g.oA(D.Z3);D.J=()=>{};
D.Z3=NaN;const B=new chrome.cast.DialLaunchResponse(!0,JE8(D));X(B);ML8(D)},D.Z3=g.IA(()=>{D.J()},100)})},AEC=function(D){g.oA(D.Y);
D.Y=0;g.oA(D.K);D.K=0;D.G();D.G=()=>{};
g.oA(D.Z3)},fd=function(D){return!(!D.config_.enableDialLoungeToken||!D.U?.getDialAppInfo)},uX=function(D,X){D.info(`getDialAppInfoWithTimeout_ ${X}`);
fd(D)&&(g.oA(D.K),D.K=0,X==0?jUU(D):D.K=g.IA(()=>{jUU(D)},X))},ML8=function(D){D.G=D.V.DC(D.pv,D.Z.label,D.Z.friendlyName,fd(D),(X,B)=>{D.G=()=>{};
iX(D,X);X.idType=="shortLived"&&B>0&&uX(D,B)},X=>{D.G=()=>{};
D.xa(X)})},JE8=function(D){var X={};
X.pairingCode=D.pv;X.theme=D.HZ;VHh()&&(X.env_useStageMdx=1);return g.im(X)},HjK=function(D,X){const B=D.N.receiver.label,C=D.Z.friendlyName;
return(new Promise(V=>{C88(D.V,B,X,C,x=>{x&&x.token&&iX(D,x);V(x)},x=>{lX(D,"Failed to get DIAL screen: "+x);
V(null)})})).then(V=>V&&V.token?new chrome.cast.DialLaunchResponse(!1):vv(D))},zUP=function(D,X,B){D.info(`initOnConnectedScreenDataPromise_: Received screenData: ${JSON.stringify(X)}`);
const C=new fP(X);return(new Promise(V=>{FXg(D,C,x=>{x?(xV(D.V,C),iX(D,C),uX(D,B)):g.WB(Error(`DialSession, RemoteScreen from screenData: ${JSON.stringify(X)} is not online.`));V(x)},5)})).then(V=>V?new chrome.cast.DialLaunchResponse(!1):vv(D))},FXg=function(D,X,B,C){g.oA(D.Y);
D.Y=0;xDA(D.V,X,V=>{V||C<0?B(V):D.Y=g.IA(()=>{FXg(D,X,B,C-1)},300)})},jUU=function(D){fd(D)&&D.U.getDialAppInfo(X=>{D.info(`getDialAppInfo dialLaunchData: ${JSON.stringify(X)}`);
X=X.extraData||{};let B=null;X.loungeToken?D.L?.token==X.loungeToken&&(B="staleLoungeToken"):B="missingLoungeToken";B?uX(D,3E4):(liA(D,X.loungeToken),uX(D,X.loungeTokenRefreshIntervalMs))},X=>{D.info(`getDialAppInfo error: ${X}`);
uX(D,3E4)})},QW5=function(D){window.chrome&&chrome.cast&&chrome.cast.logMessage&&chrome.cast.logMessage(D)},kv5=function(D){const X=D.Z.gM();
let B=D.L&&D.L.Z;D=g.E$(X,function(C){B&&u9(C,B.label)&&(B=null);const V=C.uuid?C.uuid:C.id;let x=bjW(this,C);x?(x.label=V,x.friendlyName=C.name):(x=new chrome.cast.Receiver(V,C.name),x.receiverType=chrome.cast.ReceiverType.CUSTOM);return x},D);
B&&(B.receiverType!=chrome.cast.ReceiverType.CUSTOM&&(B=new chrome.cast.Receiver(B.label,B.friendlyName),B.receiverType=chrome.cast.ReceiverType.CUSTOM),D.push(B));return D},pd=function(D){return D.K||!!D.U.length||!!D.L},hG=function(D){EE("Controller",D)},JG=function(D,X,B){X!=D.L&&(g.wK(D.L),(D.L=X)?(B?D.publish("yt-remote-cast2-receiver-resumed",X.Z):D.publish("yt-remote-cast2-receiver-selected",X.Z),X.subscribe("sessionScreen",(0,g.U$)(D.Z3,D,X)),X.subscribe("sessionFailed",()=>sUJ(D,X)),X.L?
D.publish("yt-remote-cast2-session-change",X.L):B&&D.L.S(null)):D.publish("yt-remote-cast2-session-change",null))},bjW=function(D,X){return X?g.O$(D.U,function(B){return u9(X,B.label)},D):null},sUJ=function(D,X){D.L==X&&D.publish("yt-remote-cast2-session-failed")},ai5=function(D,X,B,C){C.disableCastApi?MQ("Cannot initialize because disabled by Mdx config."):UDg()?RUK(X,C)&&(AG(!0),window.chrome&&chrome.cast&&chrome.cast.isAvailable?cEW(D,B):(window.__onGCastApiAvailable=function(V,x){V?cEW(D,B):(jq("Failed to load cast API: "+
x),Hv(!1),AG(!1),g.mh("yt-remote-cast-available"),g.mh("yt-remote-cast-receiver"),N_P(),B(!1))},C.loadCastApiSetupScript?g.X6(qUh):window.navigator.userAgent.indexOf("Android")>=0&&window.navigator.userAgent.indexOf("Chrome/")>=0&&window.navigator.presentation?UZ()>=60&&WsJ():!window.chrome||!window.navigator.presentation||window.navigator.userAgent.indexOf("Edge")>=0?cE():UZ()>=89?fV5():(N8(),RB(vD2.map(i3A))))):MQ("Cannot initialize because not running Chrome")},N_P=function(){MQ("dispose");
const D=FF();D&&D.dispose();g.Jz("yt.mdx.remote.cloudview.instance_",null);YUN(!1);g.rG(zE);zE.length=0},bX=function(){return!!g.ys("yt-remote-cast-installed")},Ii8=function(){const D=g.ys("yt-remote-cast-receiver");
return D?D.friendlyName:null},KXA=function(){MQ("clearCurrentReceiver");
g.mh("yt-remote-cast-receiver")},o4J=function(){return bX()?FF()?FF().getCastSession():(jq("getCastSelector: Cast is not initialized."),null):(jq("getCastSelector: Cast API is not installed!"),null)},sn=function(){bX()?FF()?kV()?(MQ("Requesting cast selector."),FF().requestSession()):(MQ("Wait for cast API to be ready to request the session."),zE.push(g.Oy("yt-remote-cast2-api-ready",sn))):jq("requestCastSelector: Cast is not initialized."):jq("requestCastSelector: Cast API is not installed!")},Un=
function(D,X){kV()?FF().setConnectedScreenStatus(D,X):jq("setConnectedScreenStatus called before ready.")},UDg=function(){var D=g.il().search(/ (CrMo|Chrome|CriOS)\//)>=0;
return g.f6||D},eUU=function(D,X){FF().init(D,X)},RUK=function(D,X){let B=!1;
FF()||(D=new R2(D,X),D.subscribe("yt-remote-cast2-availability-change",function(C){g.xk("yt-remote-cast-available",C);sZ("yt-remote-cast2-availability-change",C)}),D.subscribe("yt-remote-cast2-receiver-selected",function(C){MQ("onReceiverSelected: "+C.friendlyName);
g.xk("yt-remote-cast-receiver",C);sZ("yt-remote-cast2-receiver-selected",C)}),D.subscribe("yt-remote-cast2-receiver-resumed",function(C){MQ("onReceiverResumed: "+C.friendlyName);
g.xk("yt-remote-cast-receiver",C);sZ("yt-remote-cast2-receiver-resumed",C)}),D.subscribe("yt-remote-cast2-session-change",function(C){MQ("onSessionChange: "+pP(C));
C||g.mh("yt-remote-cast-receiver");sZ("yt-remote-cast2-session-change",C)}),g.Jz("yt.mdx.remote.cloudview.instance_",D),B=!0);
MQ("cloudview.createSingleton_: "+B);return B},FF=function(){return g.MX("yt.mdx.remote.cloudview.instance_")},cEW=function(D,X){Hv(!0);
AG(!1);eUU(D,function(B){B?(YUN(!0),g.DH("yt-remote-cast2-api-ready")):(jq("Failed to initialize cast API."),Hv(!1),g.mh("yt-remote-cast-available"),g.mh("yt-remote-cast-receiver"),N_P());X(B)})},MQ=function(D){EE("cloudview",D)},jq=function(D){EE("cloudview",D)},Hv=function(D){MQ("setCastInstalled_ "+D);
g.xk("yt-remote-cast-installed",D)},kV=function(){return!!g.MX("yt.mdx.remote.cloudview.apiReady_")},YUN=function(D){MQ("setApiReady_ "+D);
g.Jz("yt.mdx.remote.cloudview.apiReady_",D)},AG=function(D){g.Jz("yt.mdx.remote.cloudview.initializing_",D)},cv=function(D){this.index=-1;
this.videoId=this.listId="";this.volume=this.playerState=-1;this.muted=!1;this.audioTrackId=null;this.G=this.S=0;this.trackData=null;this.hasNext=this.hasPrevious=!1;this.loadedTime=this.U=this.Y=this.Z=0;this.L=NaN;this.V=!1;this.reset(D)},NQ=function(D){D.audioTrackId=null;
D.trackData=null;D.playerState=-1;D.hasPrevious=!1;D.hasNext=!1;D.S=0;D.G=g.c1();D.Z=0;D.Y=0;D.U=0;D.loadedTime=0;D.L=NaN;D.V=!1},qQ=function(D){return D.isPlaying()?(g.c1()-D.G)/1E3:0},a2=function(D,X){D.S=X;
D.G=g.c1()},YV=function(D){switch(D.playerState){case 1:case 1081:return(g.c1()-D.G)/1E3+D.S;
case -1E3:return 0}return D.S},dD8=function(D){return D.V?D.Y+qQ(D):D.Y},I2=function(D,X,B){const C=D.videoId;
D.videoId=X;D.index=B;X!=C&&NQ(D)},Kd=function(D){const X={};
X.index=D.index;X.listId=D.listId;X.videoId=D.videoId;X.playerState=D.playerState;X.volume=D.volume;X.muted=D.muted;X.audioTrackId=D.audioTrackId;X.trackData=g.n0(D.trackData);X.hasPrevious=D.hasPrevious;X.hasNext=D.hasNext;X.playerTime=D.S;X.playerTimeAt=D.G;X.seekableStart=D.Z;X.seekableEnd=D.Y;X.duration=D.U;X.loadedTime=D.loadedTime;X.liveIngestionTime=D.L;return X},GvU=function(D){g.Lu("nowAutoplaying autoplayDismissed remotePlayerChange remoteQueueChange autoplayModeChange autoplayUpNext previousNextChange multiStateLoopEnabled loopModeChange".split(" "),
function(X){this.Y.push(this.V.subscribe(X,g.R$(this.b0,X),this))},D)},o2=function(D,X){D.Z&&(D.Z.removeUpdateListener(D.J),D.Z.removeMediaListener(D.N),D.S(null));
D.Z=X;D.Z&&(nf("Setting cast session: "+D.Z.sessionId),D.Z.addUpdateListener(D.J),D.Z.addMediaListener(D.N),D.Z.media.length&&D.S(D.Z.media[0]))},eq=function(D){return new cv(D.V.getPlayerContextData())},dp=function(D){return D.getState()==1},Zj=function(D,X,B){return(0,g.U$)(function(C){this.o3("Failed to "+X+" with cast v2 channel. Error code: "+C.code);
C.code!=chrome.cast.ErrorCode.TIMEOUT&&(this.o3("Retrying "+X+" using MDx browser channel."),GE(this,X,B))},D)},GE=function(D,X,B){D.V.sendMessage(X,B)},Ld=function(D,X,B){const C=eq(D);
a2(C,B);C.playerState!=-1E3&&(C.playerState=X);QX(D,C)},gp=function(D,X){var B=D.G;
B.L.length+B.Z.length<50&&D.G.enqueue(X)},QX=function(D,X){ZjP(D);
D.V.setPlayerContextData(Kd(X));GvU(D)},ZjP=function(D){g.Lu(D.Y,function(X){this.V.unsubscribeByKey(X)},D);
D.Y.length=0},QUA=function(D){const X=D.L.media,B=D.L.customData;
if(X&&B){var C=eq(D);X.contentId!=C.videoId&&nf("Cast changing video to: "+X.contentId);C.videoId=X.contentId;C.playerState=B.playerState;a2(C,D.L.getEstimatedTime());QX(D,C)}else nf("No cast media video. Ignoring state update.")},LXW=function(D){En("Channel opened");
D.vZ&&(D.vZ=!1,nd(D),D.U7=g.IA(()=>{En("Timing out waiting for a screen.");D.Y(1)},15E3))},XNK=function(D,X){X=X.message;
X.params?En("Received: action="+X.action+", params="+g.fj(X.params)):En("Received: action="+X.action+" {}");switch(X.action){case "loungeStatus":X=i9(X.params.devices);D.U=g.E$(X,function(C){return new vE(C)});
X=!!g.O$(D.U,function(C){return C.type=="LOUNGE_SCREEN"});
g4N(D,X);X=D.YU("mlm");D.publish("multiStateLoopEnabled",X);break;case "loungeScreenDisconnected":g.mJ(D.U,function(C){return C.type=="LOUNGE_SCREEN"});
g4N(D,!1);break;case "remoteConnected":let B=new vE(i9(X.params.device));g.O$(D.U,function(C){return C.equals(B)})||K6P(D.U,B);
break;case "remoteDisconnected":B=new vE(i9(X.params.device));g.mJ(D.U,function(C){return C.equals(B)});
break;case "gracefulDisconnect":break;case "playlistModified":E48(D,X,"QUEUE_MODIFIED");break;case "nowPlaying":n40(D,X);break;case "onStateChange":w$8(D,X);break;case "onAdStateChange":T_X(D,X);break;case "onVolumeChanged":SUX(D,X);break;case "onSubtitlesTrackChanged":P8t(D,X);break;case "nowAutoplaying":tLh(D,X);break;case "autoplayDismissed":D.publish("autoplayDismissed");break;case "autoplayUpNext":OjK(D,X);break;case "onAutoplayModeChanged":rEJ(D,X);break;case "onHasPreviousNextChanged":D0W(D,
X);break;case "requestAssistedSignIn":D.publish("assistedSignInRequested",X.params.authCode);break;case "onLoopModeChanged":D.publish("loopModeChange",X.params.loopMode);break;default:En("Unrecognized action: "+X.action)}},En=function(D){EE("conn",D)},Bo0=function(D){D.S=g.IA(()=>{En("Connecting timeout");
D.Y(1)},2E4)},wp=function(D,X){D.publish("proxyStateChange",X)},TE=function(D){g.oA(D.S);
D.S=NaN},Sq=function(D){g.oA(D.s7);
D.s7=NaN},nd=function(D){g.oA(D.U7);
D.U7=NaN},CLC=function(D){return g.O$(D.U,function(X){return X.type=="LOUNGE_SCREEN"})},Pv=function(D,X,B){B?En("Sending: action="+X+", params="+g.fj(B)):En("Sending: action="+X);
D.Z.sendMessage(X,B)},VTX=function(D){Sq(D);
D.s7=g.IA(()=>{Pv(D,"getNowPlaying")},2E4)},x0X=function(D){g.oA(D.J);
D.J=g.IA(()=>{D.Y(1)},864E5)},g4N=function(D,X){var B=null;
if(X){const C=CLC(D);C&&(B={clientName:C.clientName,deviceMake:C.brand,deviceModel:C.model,osVersion:C.osVersion})}g.Jz("yt.mdx.remote.remoteClient_",B);X&&(TE(D),nd(D));B=D.Z.l_()&&isNaN(D.S);X==B?X&&(wp(D,1),Pv(D,"getSubtitlesTrack")):X?(D.O7()&&D.L.reset(),wp(D,1),Pv(D,"getNowPlaying"),x0X(D)):D.Y(1)},P8t=function(D,X){const B=X.params.videoId;
delete X.params.videoId;B==D.L.videoId&&(g.Z2(X.params)?D.L.trackData=null:D.L.trackData=X.params,D.publish("remotePlayerChange"))},E48=function(D,X,B){const C=X.params.videoId||X.params.video_id,V=parseInt(X.params.currentIndex,10);
D.L.listId=X.params.listId||D.L.listId;I2(D.L,C,V);D.publish("remoteQueueChange",B)},w$8=function(D,X){var B=parseInt(X.params.currentTime||X.params.current_time,10);
a2(D.L,isNaN(B)?0:B);B=parseInt(X.params.state,10);B=isNaN(B)?-1:B;B==-1&&D.L.playerState==-1E3&&(B=-1E3);D.L.playerState=B;B=Number(X.params.loadedTime);D.L.loadedTime=isNaN(B)?0:B;D.L.fz(Number(X.params.duration));B=D.L;var C=Number(X.params.liveIngestionTime);B.L=C;B.V=isNaN(C)?!1:!0;B=D.L;C=Number(X.params.seekableStartTime);X=Number(X.params.seekableEndTime);B.Z=isNaN(C)?0:C;B.Y=isNaN(X)?0:X;D.L.playerState==1?VTX(D):Sq(D);D.publish("remotePlayerChange")},n40=function(D,X){X.params=X.params||
{};
E48(D,X,"NOW_PLAYING_MAY_CHANGE");w$8(D,X);D.publish("autoplayDismissed")},T_X=function(D,X){if(D.L.playerState!=-1E3){var B=1085;
switch(parseInt(X.params.adState,10)){case 1:B=1081;break;case 2:B=1084;break;case 0:B=1083}D.L.playerState=B;X=parseInt(X.params.currentTime,10);a2(D.L,isNaN(X)?0:X);D.publish("remotePlayerChange")}},SUX=function(D,X){const B=X.params.muted=="true";
D.L.volume=parseInt(X.params.volume,10);D.L.muted=B;D.publish("remotePlayerChange")},tLh=function(D,X){D.K=X.params.videoId;
D.publish("nowAutoplaying",parseInt(X.params.timeout,10))},OjK=function(D,X){D.K=X.params.videoId||null;
D.publish("autoplayUpNext",D.K)},rEJ=function(D,X){D.G=X.params.autoplayMode;
D.publish("autoplayModeChange",D.G);D.G=="DISABLED"&&D.publish("autoplayDismissed")},D0W=function(D,X){const B=X.params.hasNext=="true";
D.L.hasPrevious=X.params.hasPrevious=="true";D.L.hasNext=B;D.publish("previousNextChange")},l4N=function(D,X){CzA();
if(!k5||!k5.get("yt-remote-disable-remote-module-for-dev")){X=g.e("MDX_CONFIG")||X;PdA();zM();tG||(tG=new Z7(X?X.loungeApiHost:void 0),VHh()&&(tG.L="/api/loungedev"));On||(On=g.MX("yt.mdx.remote.deferredProxies_")||[],g.Jz("yt.mdx.remote.deferredProxies_",On));ygt();var B=rp();if(!B){const V=new VX(tG,X?X.disableAutomaticScreenCache||!1:!1);g.Jz("yt.mdx.remote.screenService_",V);B=rp();var C={};X&&(C={appId:X.appId,disableDial:X.disableDial,theme:X.theme,loadCastApiSetupScript:X.loadCastApiSetupScript,
disableCastApi:X.disableCastApi,enableDialLoungeToken:X.enableDialLoungeToken,enableCastLoungeToken:X.enableCastLoungeToken,forceMirroring:X.forceMirroring});g.Jz("yt.mdx.remote.enableConnectWithInitialState_",X?X.enableConnectWithInitialState||!1:!1);ai5(D,V,function(x){x?DF()&&Un(DF(),"YouTube TV"):V.subscribe("onlineScreenChange",function(){sZ("yt-remote-receiver-availability-change")})},C)}X&&!g.MX("yt.mdx.remote.initialized_")&&(g.Jz("yt.mdx.remote.initialized_",!0),XH("Initializing: "+g.fj(X)),
Bf.push(g.Oy("yt-remote-cast2-api-ready",function(){sZ("yt-remote-api-ready")})),Bf.push(g.Oy("yt-remote-cast2-availability-change",function(){sZ("yt-remote-receiver-availability-change")})),Bf.push(g.Oy("yt-remote-cast2-receiver-selected",function(){CI(null);
sZ("yt-remote-auto-connect","cast-selector-receiver")})),Bf.push(g.Oy("yt-remote-cast2-receiver-resumed",function(){sZ("yt-remote-receiver-resumed","cast-selector-receiver")})),Bf.push(g.Oy("yt-remote-cast2-session-change",m05)),Bf.push(g.Oy("yt-remote-connection-change",function(V){V?Un(DF(),"YouTube TV"):VB()||(Un(null,null),KXA())})),Bf.push(g.Oy("yt-remote-cast2-session-failed",()=>{sZ("yt-remote-connection-failed")})),D=xc(),X.isAuto&&(D.id+="#dial"),C=X.capabilities||[],C.length>0&&(D.capabilities=
C),D.name=X.device,D.app=X.app,(X=X.theme)&&(D.theme=X),XH(" -- with channel params: "+g.fj(D)),D?(g.xk("yt-remote-session-app",D.app),g.xk("yt-remote-session-name",D.name)):(g.mh("yt-remote-session-app"),g.mh("yt-remote-session-name")),g.Jz("yt.mdx.remote.channelParams_",D),B.start(),DF()||iQg())}},$08=function(){var D=rp().Vp.$_gos();
const X=yB();X&&mY()&&(M8(D,X)||D.push(X));return Se2(D)},ij=function(){let D=WMA();
!D&&bX()&&Ii8()&&(D={key:"cast-selector-receiver",name:Ii8()});return D},WMA=function(){const D=$08();
let X=yB();X||(X=VB());return g.O$(D,function(B){return X&&u9(X,B.key)?!0:!1})},yB=function(){const D=DF();
if(!D)return null;const X=rp().HO();return Ap(X,D)},m05=function(D){XH("remote.onCastSessionChange_: "+pP(D));
if(D){var X=yB();if(X&&X.id==D.id){if(Un(X.id,"YouTube TV"),D.idType=="shortLived"&&(D=D.token))lj&&(lj.token=D),(X=mY())&&X.jX(D)}else X&&$c(),Wf(D,1)}else mY()&&$c()},$c=function(){kV()?FF().stopSession():jq("stopSession called before API ready.");
const D=mY();D&&(D.disconnect(1),vf(null))},fI=function(){const D=mY();
return!!D&&D.getProxyState()!=3},XH=function(D){EE("remote",D)},rp=function(){if(!uj){const D=g.MX("yt.mdx.remote.screenService_");
uj=D?new vy5(D):null}return uj},DF=function(){return g.MX("yt.mdx.remote.currentScreenId_")},f4g=function(D){g.Jz("yt.mdx.remote.currentScreenId_",D)},uv5=function(){return g.MX("yt.mdx.remote.connectData_")},CI=function(D){g.Jz("yt.mdx.remote.connectData_",D)},mY=function(){return g.MX("yt.mdx.remote.connection_")},vf=function(D){const X=mY();
CI(null);D||f4g("");g.Jz("yt.mdx.remote.connection_",D);On&&(g.Lu(On,function(B){B(D)}),On.length=0);
X&&!D?sZ("yt-remote-connection-change",!1):!X&&D&&sZ("yt-remote-connection-change",!0)},VB=function(){const D=g.iV();
if(!D)return null;var X=rp();if(!X)return null;X=X.HO();return Ap(X,D)},Wf=function(D,X){DF();
yB()&&yB();if(pI)lj=D;else{f4g(D.id);var B=g.MX("yt.mdx.remote.enableConnectWithInitialState_")||!1;D=new h$(D,B);D.connect(X,uv5());D.subscribe("beforeDisconnect",function(C){sZ("yt-remote-before-disconnect",C)});
D.subscribe("beforeDispose",function(){mY()&&(mY(),vf(null))});
D.subscribe("browserChannelAuthError",()=>{const C=yB();C&&C.idType=="shortLived"&&(kV()?FF().handleBrowserChannelAuthError():jq("refreshLoungeToken called before API ready."))});
vf(D)}},iQg=function(){const D=VB();
D?(XH("Resume connection to: "+pP(D)),Wf(D,0)):(b9(),KXA(),XH("Skipping connecting because no session screen found."))},ygt=function(){var D=xc();
if(g.Z2(D)){D=Fg();var X=g.ys("yt-remote-session-name")||"";const B=g.ys("yt-remote-session-app")||"";D={device:"REMOTE_CONTROL",id:D,name:X,app:B,mdxVersion:3};D.authuser=String(g.e("SESSION_INDEX","0"));(X=g.e("DELEGATED_SESSION_ID"))&&(D.pageId=String(X));g.Jz("yt.mdx.remote.channelParams_",D)}},xc=function(){return g.MX("yt.mdx.remote.channelParams_")||{}},pN0=function(D,X){if(J$(D)){D.iY.unsubscribe("remotePlayerChange",D.G,D);
const B=Math.round(X.volume);X=!!X.muted;const C=eq(D.iY);if(B!==C.volume||X!==C.muted)D.iY.setVolume(B,X),D.J.start();D.iY.subscribe("remotePlayerChange",D.G,D)}},J$=function(D){return eq(D.iY).videoId===Mu(D).videoId},A$=function(D,X){let B,C;
var V=D.A.getPlaylist();V?.listId&&(B=V.index,C=V.listId.toString());V=Mu(D);D.iY.playVideo(V.videoId,X,B,C,V.playerParams,V.J,I1K(V));D.Va(new g.u0(1))},j9=function(D,X){if(J$(D)&&!D.S){let B=null;
X&&(B={style:D.A.getSubtitlesUserSettings()},Object.assign(B,X));D.iY.K(Mu(D).videoId,B);D.V=eq(D.iY).trackData}},h4N=function(D,X){if(X){const B=D.A.getOption("captions","tracklist",{s4:1});
B&&B.length?(D.A.setOption("captions","track",X),D.S=!1):(D.A.loadModule("captions"),D.S=!0)}else D.A.setOption("captions","track",{})},Jgt=function(D){D.Ki(0);
D.Z.stop();D.Va(new g.u0(64))},Mu=function(D){return D.A.getVideoData({playerType:1})},MTh=function(D){const X=D.player.j();
return!X.X("mdx_enable_privacy_disclosure_ui")||D.isLoggedIn()||D.DQ||!D.OP?!1:g.bE(X)||g.Ul(X)},AgX=function(D,X,B){D.rS=B;
D.player.publish("presentingplayerstatechange",new g.b0(B,X))},Hf=function(D,X,...B){D.loaded&&D.jd.V1(X,...B)},FH=function(D){D.YJ&&(D.player.removeEventListener("presentingplayerstatechange",D.YJ),D.YJ=null)},z2=function(D,X){if(X.key!==D.DY.key)if(X.key===D.zi.key)$c();
else if(MTh(D)&&jF5(D),D.DY=X,!g.n9(D.player.j())){{const x=D.player.getPlaylistId();var B=D.player.getVideoData({playerType:1});const y=B.videoId;if(!x&&!y||(D.player.getAppState()===2||D.player.getAppState()===1)&&D.player.j().X("should_clear_video_data_on_player_cued_unstarted"))B=null;else{var C=D.player.getPlaylist();if(C){var V=[];for(let m=0;m<C.length;m++)V[m]=g.e2(C,m).videoId}else V=[y];C=D.player.getCurrentTime(1);D={videoIds:V,listId:x,videoId:y,playerParams:B.playerParams,clickTrackingParams:B.J,
index:Math.max(D.player.getPlaylistIndex(),0),currentTime:C===0?void 0:C};(B=I1K(B))&&(D.locationInfo=B);B=D}}XH("Connecting to: "+g.fj(X));X.key=="cast-selector-receiver"?(CI(B||null),X=B||null,kV()?FF().setLaunchParams(X):jq("setLaunchParams called before ready.")):!B&&fI()&&DF()==X.key?sZ("yt-remote-connection-change",!0):($c(),CI(B||null),B=rp().HO(),(X=Ap(B,X.key))&&Wf(X,1))}},jF5=function(D){D.player.getPlayerStateObject().isPlaying()?D.player.pauseVideo():(D.YJ=X=>{!D.DQ&&X.uI(8)&&(D.player.pauseVideo(),
FH(D))},D.player.addEventListener("presentingplayerstatechange",D.YJ));
D.OP&&D.OP.xt();mY()||(pI=!0)};
g.ub.prototype.F1=g.B1(46,function(){this.app.jS().F1()});
g.tq.prototype.F1=g.B1(45,function(){this.Rp=null});
g.ub.prototype.VE=g.B1(44,function(D){this.app.jS().VE(D)});
g.tq.prototype.VE=g.B1(43,function(D){this.Rp=D});
g.i5.prototype.oF=g.B1(1,function(){return g.P0(this,3)});
g.Xi.prototype.oF=g.B1(0,function(){return g.P0(this,11)});
var b18=class{constructor(){var D=g.Sn();this.Z=D;g.Cj(D,"/client_streamz/youtube/living_room/mdx/channel/opened",g.J1("channel_type"))}L(D){g.x4(this.Z,"/client_streamz/youtube/living_room/mdx/channel/opened",D)}},keh=class{constructor(){var D=g.Sn();this.Z=D;g.Cj(D,"/client_streamz/youtube/living_room/mdx/channel/closed",g.J1("channel_type"))}L(D){g.x4(this.Z,"/client_streamz/youtube/living_room/mdx/channel/closed",D)}},UEt=class{constructor(){var D=g.Sn();this.Z=D;g.Cj(D,"/client_streamz/youtube/living_room/mdx/channel/message_received",
g.J1("channel_type"))}L(D){g.x4(this.Z,"/client_streamz/youtube/living_room/mdx/channel/message_received",D)}},sW8=class{constructor(){var D=g.Sn();this.Z=D;g.Cj(D,"/client_streamz/youtube/living_room/mdx/channel/success")}L(){g.x4(this.Z,"/client_streamz/youtube/living_room/mdx/channel/success")}},RZP=class{constructor(){var D=g.Sn();this.Z=D;g.Cj(D,"/client_streamz/youtube/living_room/mdx/channel/error",g.J1("channel_type"),g.J1("error_type"))}L(D,X){g.x4(this.Z,"/client_streamz/youtube/living_room/mdx/channel/error",
D,X)}},cvP=class{constructor(){var D=g.Sn();this.Z=D;g.Cj(D,"/client_streamz/youtube/living_room/mdx/browser_channel/pending_maps")}L(){g.x4(this.Z,"/client_streamz/youtube/living_room/mdx/browser_channel/pending_maps")}},N5X=class{constructor(){var D=g.Sn();this.Z=D;g.Cj(D,"/client_streamz/youtube/living_room/mdx/browser_channel/undelivered_maps")}L(){g.x4(this.Z,"/client_streamz/youtube/living_room/mdx/browser_channel/undelivered_maps")}};g.b=$5.prototype;
g.b.UJ=function(){WE(this);const D=[];for(let X=0;X<this.L.length;X++)D.push(this.Z[this.L[X]]);return D};
g.b.sJ=function(){WE(this);return this.L.concat()};
g.b.has=function(D){return l9(this.Z,D)};
g.b.equals=function(D,X){if(this===D)return!0;if(this.size!=D.size)return!1;X=X||Gp8;WE(this);let B;for(let C=0;B=this.L[C];C++)if(!X(this.get(B),D.get(B)))return!1;return!0};
g.b.isEmpty=function(){return this.size==0};
g.b.clear=function(){this.Z={};this.lJ=this.size=this.L.length=0};
g.b.remove=function(D){return this.delete(D)};
g.b.delete=function(D){return l9(this.Z,D)?(delete this.Z[D],--this.size,this.lJ++,this.L.length>2*this.size&&WE(this),!0):!1};
g.b.get=function(D,X){return l9(this.Z,D)?this.Z[D]:X};
g.b.set=function(D,X){l9(this.Z,D)||(this.size+=1,this.L.push(D),this.lJ++);this.Z[D]=X};
g.b.forEach=function(D,X){const B=this.sJ();for(let C=0;C<B.length;C++){const V=B[C],x=this.get(V);D.call(X,x,V,this)}};
g.b.clone=function(){return new $5(this)};
g.b.keys=function(){return g.Hs(this.nz(!0)).L()};
g.b.values=function(){return g.Hs(this.nz(!1)).L()};
g.b.entries=function(){const D=this;return dq0(this.keys(),function(X){return[X,D.get(X)]})};
g.b.nz=function(D){WE(this);let X=0;const B=this.lJ,C=this,V=new g.f5;V.next=function(){if(B!=C.lJ)throw Error("The map has changed since the iterator was created");if(X>=C.L.length)return g.Op;const x=C.L[X++];return g.uo(D?x:C.Z[x])};
return V};
var gwU={Gf:"atp",TnF:"ska",S7V:"que",Qt:"mus",pC2:"sus",ea:"dsp",M7v:"seq",WI:"mic",OG:"dpa",iH:"mlm",lf:"dsdtr",ey:"ntb",nxF:"vsp",Cy:"scn",XZ0:"rpe",Hd:"dcn",e4:"dcp",Cc:"pas",Iw:"drq",Oq:"opf",Rw:"els",Pd:"isg",rFv:"svq",TQ:"mvp",qm:"ads",vx0:"stcp",WGF:"sads",Gc:"dloc",S4:"dcw",v2:"asw",H2:"apw",eZ:"wrc",pZ7:"pcw",vI:"ipv",aK:"ndt",WR:"ctops",uV:"gsrm"},Ew8={rya:"u",j8:"cl",ll:"k",EE:"i",Tc:"cr",uH:"m",kG:"g",Az:"up"},aTg={cw:"nowPlaying",YW:"onStateChange",Xe:"adPlaying",Sy:"onAdStateChange",
IK:"nowPlayingShorts",XU:"onShortsStateChange"};vE.prototype.equals=function(D){return D?this.id==D.id:!1};
var HE="",k5=null,$ch=xc8("loadCastFramework")||xc8("loadCastApplicationFramework"),vD2=["pkedcjkdefgpdelpbcmbmeomcjbeemfm","enhhojjnijigcajfphajepfemndkmdlo"];g.a$(q8,g.Sf);g.b=q8.prototype;g.b.fM=function(D){this.V=arguments;this.L=!1;this.Fw?this.U=g.c1()+this.Lh:this.Fw=g.tv(this.G,this.Lh)};
g.b.stop=function(){this.Fw&&(g.hz.clearTimeout(this.Fw),this.Fw=null);this.U=null;this.L=!1;this.V=[]};
g.b.pause=function(){++this.Z};
g.b.resume=function(){this.Z&&(--this.Z,!this.Z&&this.L&&(this.L=!1,this.S.apply(null,this.V)))};
g.b.u0=function(){this.stop();q8.FJ.u0.call(this)};
g.b.RW=function(){this.Fw&&(g.hz.clearTimeout(this.Fw),this.Fw=null);this.U?(this.Fw=g.tv(this.G,this.U-g.c1()),this.U=null):this.Z?this.L=!0:(this.L=!1,this.S.apply(null,this.V))};var Y5=null;aB.prototype.set=function(D){this.L=D};
aB.prototype.reset=function(){this.set(g.c1())};
aB.prototype.get=function(){return this.L};g.a$(pdt,u$W);var yl=class{stringify(D){return g.hz.JSON.stringify(D,void 0)}parse(D){return g.hz.JSON.parse(D,void 0)}};g.a$(IB,g.t1);g.a$(KP,g.t1);var h6h=null;g.a$(J1A,g.t1);g.a$(MHA,g.t1);g.a$(A12,g.t1);ZP.prototype.debug=function(){};
ZP.prototype.info=function(){};
ZP.prototype.warning=function(){};var kHW={},wZ={};g.b=QH.prototype;g.b.setTimeout=function(D){this.D3=D};
g.b.jG=function(D){D=D.target;const X=this.O7;X&&g.k4(D)==3?X.V():this.Ut(D)};
g.b.Ut=function(D){try{if(D==this.L)a:{const V=g.k4(this.L),x=this.L.Z,y=this.L.getStatus();if(!(V<3)&&(V!=3||this.L&&(this.Z.Z||g.RU(this.L)||g.c$(this.L)))){this.vZ||V!=4||x==7||(x==8||y<=0?eW(3):eW(2));TM(this);var X=this.L.getStatus();this.xU=X;var B=b35(this);if(this.S=X==200){if(this.WZ&&!this.b0){b:{if(this.L){const m=g.qD(this.L,"X-HTTP-Initial-Response");if(m&&!g.CR(m)){var C=m;break b}}C=null}if(D=C)this.b0=!0,Cf(this,D);else{this.S=!1;this.G=3;dZ(12);EZ(this);nP(this);break a}}if(this.U7){D=
!0;let m;for(;!this.vZ&&this.Y<B.length;)if(m=sI5(this,B),m==wZ){V==4&&(this.G=4,dZ(14),D=!1);break}else if(m==kHW){this.G=4;dZ(15);D=!1;break}else Cf(this,m);z6t(this)&&this.Y!=0&&(this.Z.L=this.Z.L.slice(this.Y),this.Y=0);V!=4||B.length!=0||this.Z.Z||(this.G=1,dZ(16),D=!1);this.S=this.S&&D;D?B.length>0&&!this.mG&&(this.mG=!0,this.U.XR(this)):(EZ(this),nP(this))}else Cf(this,B);V==4&&EZ(this);this.S&&!this.vZ&&(V==4?R6h(this.U,this):(this.S=!1,gZ(this)))}else g.ND(this.L),X==400&&B.indexOf("Unknown SID")>
0?(this.G=3,dZ(12)):(this.G=0,dZ(13)),EZ(this),nP(this)}}}catch(V){}finally{}};
g.b.cancel=function(){this.vZ=!0;EZ(this)};
g.b.CM=function(){this.Z3=null;const D=Date.now();D-this.Cv>=0?(this.HZ!=2&&(eW(3),dZ(17)),EZ(this),this.G=2,nP(this)):UcK(this,this.Cv-D)};
g.b.getLastError=function(){return this.G};
g.b.Cd=function(){return this.L};var HQt=class{constructor(D,X){this.L=D;this.map=X;this.context=null}};aV5.prototype.cancel=function(){this.U=Vl(this);if(this.Z)this.Z.cancel(),this.Z=null;else if(this.L&&this.L.size!==0){for(const D of this.L.values())D.cancel();this.L.clear()}};g.b=e6C.prototype;g.b.oN=8;g.b.NL=1;g.b.connect=function(D,X,B,C){dZ(0);this.zW=D;this.vZ=X||{};B&&C!==void 0&&(this.vZ.OSID=B,this.vZ.OAID=C);this.O7=this.Io;this.G2=c1X(this,null,this.zW);Bx(this)};
g.b.disconnect=function(){dc0(this);if(this.NL==3){var D=this.YU++,X=this.G2.clone();g.Xa(X,"SID",this.V);g.Xa(X,"RID",D);g.Xa(X,"TYPE","terminate");$o(this,X);D=new QH(this,this.V,D);D.HZ=2;D.K=x5(X.clone());X=!1;if(g.hz.navigator&&g.hz.navigator.sendBeacon)try{X=g.hz.navigator.sendBeacon(D.K.toString(),"")}catch{}!X&&g.hz.Image&&((new Image).src=D.K,X=!0);X||(D.L=FsP(D.U,null),D.L.send(D.K));D.pv=Date.now();gZ(D)}EDN(this)};
g.b.Ew=function(){return this.NL==0};
g.b.getState=function(){return this.NL};
g.b.q0=function(D){if(this.S)if(this.S=null,this.NL==1){if(!D){this.YU=Math.floor(Math.random()*1E5);D=this.YU++;const V=new QH(this,"",D);let x=this.N;this.WZ&&(x?(x=g.Et(x),g.T8(x,this.WZ)):x=this.WZ);this.Y!==null||this.Cv||(V.G2=x,x=null);if(this.BZ)a:{var X=0;for(var B=0;B<this.U.length;B++){b:{var C=this.U[B];if("__data__"in C.map&&(C=C.map.__data__,typeof C==="string")){C=C.length;break b}C=void 0}if(C===void 0)break;X+=C;if(X>4096){X=B;break a}if(X===4096||B===this.U.length-1){X=B+1;break a}}X=
this.Cr}else X=this.Cr;X=QIJ(this,V,X);B=this.G2.clone();g.Xa(B,"RID",D);g.Xa(B,"CVER",22);this.U7&&g.Xa(B,"X-HTTP-Session-Id",this.U7);$o(this,B);x&&(this.Cv?X="headers="+g.xh(g.mF(x))+"&"+X:this.Y&&g.iB(B,this.Y,x));Xm(this.Z,V);this.Ni&&g.Xa(B,"TYPE","init");this.BZ?(g.Xa(B,"$req",X),g.Xa(B,"SID","null"),V.WZ=!0,LP(V,B,null)):LP(V,B,X);this.NL=2}}else this.NL==3&&(D?LsP(this,D):this.U.length==0||Y2J(this.Z)||LsP(this))};
g.b.Vc=function(){this.K=null;gDh(this);if(this.Ay&&!(this.D3||this.L==null||this.X2<=0)){var D=4*this.X2;this.s7=GM((0,g.U$)(this.IM,this),D)}};
g.b.IM=function(){this.s7&&(this.s7=null,this.O7=!1,this.D3=!0,dZ(10),tp(this),gDh(this))};
g.b.XR=function(D){this.L==D&&this.Ay&&!this.D3&&(lf(this),this.D3=!0,dZ(11))};
g.b.tL=function(){this.Z3!=null&&(this.Z3=null,tp(this),OZ(this),dZ(19))};
g.b.Xf=function(D){D?dZ(2):dZ(1)};
g.b.isActive=function(){return!!this.G&&this.G.isActive(this)};
g.b=wd2.prototype;g.b.GG=function(){};
g.b.ef=function(){};
g.b.vj=function(){};
g.b.Hj=function(){};
g.b.isActive=function(){return!0};
g.b.EF=function(){};g.a$(vx,g.Jv);vx.prototype.open=function(){this.L.G=this.U;this.Y&&(this.L.b0=!0);this.L.connect(this.S,this.Z||void 0)};
vx.prototype.close=function(){this.L.disconnect()};
vx.prototype.send=function(D){var X=this.L;if(typeof D==="string"){var B={};B.__data__=D;D=B}else this.G&&(B={},B.__data__=g.fj(D),D=B);X.U.push(new HQt(X.e1++,D));X.NL==3&&Bx(X)};
vx.prototype.u0=function(){this.L.G=null;delete this.U;this.L.disconnect();delete this.L;vx.FJ.u0.call(this)};
g.a$(S28,IB);g.a$(PzJ,KP);g.a$(Wx,wd2);Wx.prototype.GG=function(){this.L.dispatchEvent("m")};
Wx.prototype.ef=function(D){this.L.dispatchEvent(new S28(D))};
Wx.prototype.vj=function(D){this.L.dispatchEvent(new PzJ(D))};
Wx.prototype.Hj=function(){this.L.dispatchEvent("n")};
vx.prototype.V=function(){return new ff(this,this.L)};
