(function(g){var window=this;'use strict';var T9=function(f){f.publish("autonavvisibility")},F3L=function(f,e){g.yW(f,"onAutonavCoundownStarted",e)},Dz=function(f){return f.isBackground()&&f.Qi()},maB=function(f,e){e=e.getWatchNextResponse()?.playerOverlays?.playerOverlayRenderer?.autoplay?.playerOverlayAutoplayRenderer?.nextButton?.buttonRenderer; f.A=e?.navigationEndpoint;e=e?.trackingParams;f.playButton&&e&&f.Z.setTrackingParams(f.playButton.element,e)},G9=function(f){const e=JP(f); var B=Math,n=B.min;var r=f.X?Date.now()-f.X:0;B=n.call(B,r,e);MF(f,Math.ceil((e-B)/1E3));e-B<=500&&f.C()?f.select(!0):f.C()&&f.N.start()},xN=function(f){var e=f.Z.jh(!0,f.Z.isFullscreen()); g.h(f.container.element,"ytp-autonav-endscreen-small-mode",f.B0(e));g.h(f.container.element,"ytp-autonav-endscreen-is-premium",!!f.suggestion&&!!f.suggestion.qO);g.h(f.Z.getRootNode(),"ytp-autonav-endscreen-cancelled-state",!f.Z.Ws());g.h(f.Z.getRootNode(),"countdown-running",f.C());g.h(f.container.element,"ytp-player-content",f.Z.Ws());g.uc(f.overlay.element,{width:`${e.width}px`});if(!f.C()){f.Z.Ws()?MF(f,Math.round(JP(f)/1E3)):MF(f);e=!!f.suggestion&&!!f.suggestion.tv;const B=f.Z.Ws()||!e;g.h(f.container.element, "ytp-autonav-endscreen-upnext-alternative-header-only",!B&&e);g.h(f.container.element,"ytp-autonav-endscreen-upnext-no-alternative-header",B&&!e);f.U.FG(f.Z.Ws());g.h(f.element,"ytp-enable-w2w-color-transitions",!!f.Z.getVideoData()?.watchToWatchTransitionRenderer)}},MF=function(f,e=-1){f=f.V.JL("ytp-autonav-endscreen-upnext-header"); g.LC(f);if(e>=0){e=String(e);const B="Pr\u00f3ximo v\u00eddeo em $SECONDS".match(RegExp("\\$SECONDS","gi"))[0],n="Pr\u00f3ximo v\u00eddeo em $SECONDS".indexOf(B);if(n>=0){f.appendChild(g.nC("Pr\u00f3ximo v\u00eddeo em $SECONDS".slice(0,n)));const r=g.BN("span");g.X3(r,"ytp-autonav-endscreen-upnext-header-countdown-number");g.kC(r,e);f.appendChild(r);f.appendChild(g.nC("Pr\u00f3ximo v\u00eddeo em $SECONDS".slice(n+B.length)));return}}g.kC(f,"Pr\u00f3ximo")},JP=function(f){return f.Z.isFullscreen()? (f=f.Z.getVideoData()?.DO,f===-1||f===void 0?8E3:f):f.Z.LL()>=0?f.Z.LL():g.tS(f.Z.S().experiments,"autoplay_time")||1E4},Wa=function(f,e){e=UaG(f,e); var B=Math,n=B.min;var r=(0,g.T)()-f.X;B=n.call(B,r,e);e=e===0?1:Math.min(B/e,1);f.WS.setAttribute("stroke-dashoffset",`${-211*(e+1)}`);e>=1&&f.C()&&f.api.getPresentingPlayerType()!==3?f.select(!0):f.C()&&f.V.start()},UaG=function(f,e){return e?e:f.api.isFullscreen()?(f=f.api.getVideoData()?.DO,f===-1||f===void 0?8E3:f):f.api.LL()>=0?f.api.LL():g.tS(f.api.S().experiments,"autoplay_time")||1E4},s6=function(f){const e=f.Ws(); e!==f.X&&(f.X=e,T9(f.player),f.X?(f.G!==f.C&&f.G.hide(),f.table.hide()):(f.G!==f.C&&f.G.show(),f.table.show()))},X2=function(f){return g.zJ(f.player)&&f.V()&&!f.W},yn=function(f){const e=f.Ws(); e!==f.N&&(f.N=e,T9(f.player))},Pa=function(f){return g.zJ(f.player)&&f.V()&&!f.U},IX=function(f){const e=f.Ws(); e!==f.Cq&&(f.Cq=e,T9(f.player))},NPe=function(f){f=f.S(); return f.Mk&&!f.y8&&!f.disableOrganicUi},hVx=function(f){const e=f.player.getVideoData(); if(!e||f.C===e.zt&&f.G===e.IA)return!1;f.C=e.zt;f.G=e.IA;return!0},g_G=function(f){f.player.sK("endscreen"); var e=f.player.getVideoData();e=new g.VD(Math.max((e.lengthSeconds-10)*1E3,0),0x8000000000000,{id:"preload",namespace:"endscreen"});const B=new g.VD(0x8000000000000,0x8000000000000,{id:"load",priority:8,namespace:"endscreen"});f.player.AI([e,B])}; g.sL.prototype.LL=g.B5(9,function(){return this.app.LL()}); g.S6.prototype.LL=g.B5(8,function(){return this.getVideoData().T4}); g.Wq.prototype.VY=g.B5(7,function(f){this.LG().VY(f)}); g.wX.prototype.VY=g.B5(6,function(f){this.lc!==f&&(this.lc=f,this.Om())}); var SNH=class extends g.y{constructor(f){const e=f.S(),B=e.V;super({L:"a",B:"ytp-autonav-suggestion-card",O:{href:"{{url}}",target:B?e.N:"","aria-label":"{{aria_label}}","data-is-live":"{{is_live}}","data-is-list":"{{is_list}}","data-is-mix":"{{is_mix}}","data-is-upcoming":"{{is_upcoming}}"},j:[{L:"div",y9:["ytp-autonav-endscreen-upnext-thumbnail","ytp-autonav-thumbnail-small"],O:{style:"{{background}}"},j:[{L:"div",O:{"aria-label":"{{timestamp}}"},y9:["ytp-autonav-timestamp"],Ga:"{{duration}}"}, {L:"div",y9:["ytp-autonav-live-stamp"],Ga:"Ao vivo"},{L:"div",y9:["ytp-autonav-upcoming-stamp"],Ga:"Em breve"},{L:"div",B:"ytp-autonav-list-overlay",j:[{L:"div",B:"ytp-autonav-mix-text",Ga:"Mix"},{L:"div",B:"ytp-autonav-mix-icon"}]}]},{L:"div",y9:["ytp-autonav-endscreen-upnext-title","ytp-autonav-title-card"],Ga:"{{title}}"},{L:"div",y9:["ytp-autonav-endscreen-upnext-author","ytp-autonav-author-card"],Ga:"{{author}}"},{L:"div",y9:["ytp-autonav-endscreen-upnext-author","ytp-autonav-view-and-date-card"], Ga:"{{views_and_publish_time}}"}]});this.Z=f;this.suggestion=null;this.C=B;this.listen("click",this.onClick);this.listen("keypress",this.onKeyPress)}select(){this.Z.P6(this.suggestion.videoId,this.suggestion.sessionData,this.suggestion.playlistId,void 0,void 0,this.suggestion.RF||void 0)&&this.Z.logClick(this.element)}onClick(f){g.mv(f,this.Z,this.C,this.suggestion.sessionData||void 0)&&this.select()}onKeyPress(f){switch(f.keyCode){case 13:case 32:f.defaultPrevented||(this.select(),f.preventDefault())}}};var $N=class extends g.y{constructor(f,e=!1){super({L:"div",B:"ytp-autonav-endscreen-countdown-overlay"});this.Lq=e;this.cancelCommand=this.A=void 0;this.X=0;this.container=new g.y({L:"div",B:"ytp-autonav-endscreen-countdown-container"});g.A(this,this.container);this.container.di(this.element);e=f.S();const B=e.V;this.Z=f;this.suggestion=null;this.onVideoDataChange("newdata",this.Z.getVideoData());this.D(f,"videodatachange",this.onVideoDataChange);this.V=new g.y({L:"div",B:"ytp-autonav-endscreen-upnext-container", O:{"aria-label":"{{aria_label}}","data-is-live":"{{is_live}}","data-is-list":"{{is_list}}","data-is-mix":"{{is_mix}}","data-is-upcoming":"{{is_upcoming}}"},j:[{L:"div",B:"ytp-autonav-endscreen-upnext-header"},{L:"div",B:"ytp-autonav-endscreen-upnext-alternative-header",Ga:"{{autoplayAlternativeHeader}}"},{L:"a",B:"ytp-autonav-endscreen-link-container",O:{href:"{{url}}",target:B?e.N:""},j:[{L:"div",B:"ytp-autonav-endscreen-upnext-thumbnail",O:{style:"{{background}}"},j:[{L:"div",O:{"aria-label":"{{timestamp}}"}, y9:["ytp-autonav-timestamp"],Ga:"{{duration}}"},{L:"div",y9:["ytp-autonav-live-stamp"],Ga:"Ao vivo"},{L:"div",y9:["ytp-autonav-upcoming-stamp"],Ga:"Em breve"}]},{L:"div",B:"ytp-autonav-endscreen-video-info",j:[{L:"div",B:"ytp-autonav-endscreen-premium-badge"},{L:"div",B:"ytp-autonav-endscreen-upnext-title",Ga:"{{title}}"},{L:"div",B:"ytp-autonav-endscreen-upnext-author",Ga:"{{author}}"},{L:"div",B:"ytp-autonav-view-and-date",Ga:"{{views_and_publish_time}}"},{L:"div",B:"ytp-autonav-author-and-view", Ga:"{{author_and_views}}"}]}]}]});g.A(this,this.V);this.V.di(this.container.element);B||this.D(this.V.JL("ytp-autonav-endscreen-link-container"),"click",this.cS);this.Z.createClientVe(this.container.element,this,115127);this.Z.createClientVe(this.V.JL("ytp-autonav-endscreen-link-container"),this,115128);this.overlay=new g.y({L:"div",B:"ytp-autonav-overlay"});g.A(this,this.overlay);this.overlay.di(this.container.element);this.U=new g.y({L:"div",B:"ytp-autonav-endscreen-button-container"});g.A(this, this.U);this.U.di(this.container.element);this.cancelButton=new g.y({L:"button",y9:["ytp-autonav-endscreen-upnext-button","ytp-autonav-endscreen-upnext-cancel-button","ytp-autonav-endscreen-upnext-button-rounded"],O:{"aria-label":"Cancelar reprodu\u00e7\u00e3o autom\u00e1tica"},Ga:"Cancelar"});g.A(this,this.cancelButton);this.cancelButton.di(this.U.element);this.cancelButton.listen("click",this.WS,this);this.Z.createClientVe(this.cancelButton.element,this,115129);this.playButton=new g.y({L:"a",y9:["ytp-autonav-endscreen-upnext-button", "ytp-autonav-endscreen-upnext-play-button","ytp-autonav-endscreen-upnext-button-rounded"],O:{href:"{{url}}",role:"button","aria-label":"Reproduzir pr\u00f3ximo v\u00eddeo"},Ga:"Assista agora"});g.A(this,this.playButton);this.playButton.di(this.U.element);this.playButton.listen("click",this.cS,this);this.Z.createServerVe(this.playButton.element,this.playButton,!0);(e=this.Z.getVideoData())&&maB(this,e);this.N=new g.T6(()=>{G9(this)},500); g.A(this,this.N);this.Cq();this.D(f,"autonavvisibility",this.Cq);this.Z.Y("web_autonav_color_transition")&&(this.D(f,"autonavchange",this.eI),this.D(f,"onAutonavCoundownStarted",this.PS))}K(f){this.suggestion!==f&&(this.suggestion=f,g.HO(this.V,f),this.playButton.updateValue("url",this.suggestion.Q7()),xN(this))}C(){return this.X>0}W(){this.C()||(this.X=Date.now(),G9(this),F3L(this.Z,JP(this)),g.h(this.Z.getRootNode(),"countdown-running",this.C()))}J(){this.G();G9(this);const f=this.V.JL("ytp-autonav-endscreen-upnext-header"); f&&g.kC(f,"Pr\u00f3ximo")}G(){this.C()&&(this.N.stop(),this.X=0)}select(f=!1){this.Z.nextVideo(!1,f);this.G()}cS(f){g.mv(f,this.Z)&&(f.currentTarget===this.playButton.element?this.Z.logClick(this.playButton.element):f.currentTarget===this.V.JL("ytp-autonav-endscreen-link-container")&&(f=this.V.JL("ytp-autonav-endscreen-link-container"),this.Z.logVisibility(f,!0),this.Z.logClick(f)),this.A?(g.yW(this.Z,"innertubeCommand",this.A),this.G()):this.select())}WS(){this.Z.logClick(this.cancelButton.element); g.C_(this.Z,!0);this.cancelCommand&&g.yW(this.Z,"innertubeCommand",this.cancelCommand)}onVideoDataChange(f,e){maB(this,e);this.cancelCommand=e.getWatchNextResponse()?.playerOverlays?.playerOverlayRenderer?.autoplay?.playerOverlayAutoplayRenderer?.cancelButton?.buttonRenderer?.command}PS(f){if(this.Z.getVideoData()?.watchToWatchTransitionRenderer){var e=this.Z.getVideoData().watchToWatchTransitionRenderer;const B=e?.fromColorPaletteDark,n=e?.toColorPaletteDark;B&&n&&(e=this.element,e.style.setProperty("--w2w-start-background-color", g.Dk(B.surgeColor)),e.style.setProperty("--w2w-start-primary-text-color",g.Dk(B.primaryTitleColor)),e.style.setProperty("--w2w-start-secondary-text-color",g.Dk(B.secondaryTitleColor)),e.style.setProperty("--w2w-end-background-color",g.Dk(n.surgeColor)),e.style.setProperty("--w2w-end-primary-text-color",g.Dk(n.primaryTitleColor)),e.style.setProperty("--w2w-end-secondary-text-color",g.Dk(n.secondaryTitleColor)),e.style.setProperty("--w2w-animation-duration",`${f}ms`));g.h(this.element,"ytp-w2w-animate", !0)}}eI(f){this.Z.Y("web_autonav_color_transition")&&f!==2&&g.h(this.element,"ytp-w2w-animate",!1)}Cq(){const f=this.Z.Ws();this.Lq&&this.ef!==f&&this.FG(f);xN(this);this.Z.logVisibility(this.container.element,f);this.Z.logVisibility(this.cancelButton.element,f);this.Z.logVisibility(this.V.JL("ytp-autonav-endscreen-link-container"),f);this.Z.logVisibility(this.playButton.element,f)}B0(f){return f.width<400||f.height<459}};var ik=class extends g.y{constructor(f,e){super({L:"div",y9:["html5-endscreen","ytp-player-content",e||"base-endscreen"]});this.created=!1;this.player=f}create(){this.created=!0}destroy(){this.created=!1}V(){return!1}Ws(){return!1}A(){return!1}};var fo=class extends g.y{constructor(f){super({L:"div",y9:["ytp-upnext","ytp-player-content"],O:{"aria-label":"{{aria_label}}"},j:[{L:"div",B:"ytp-cued-thumbnail-overlay-image",O:{style:"{{background}}"}},{L:"span",B:"ytp-upnext-top",j:[{L:"span",B:"ytp-upnext-header",Ga:"Pr\u00f3ximo"},{L:"span",B:"ytp-upnext-title",Ga:"{{title}}"},{L:"span",B:"ytp-upnext-author",Ga:"{{author}}"}]},{L:"a",B:"ytp-upnext-autoplay-icon",O:{role:"button",href:"{{url}}","aria-label":"Reproduzir pr\u00f3ximo v\u00eddeo"}, j:[{L:"svg",O:{height:"100%",version:"1.1",viewBox:"0 0 72 72",width:"100%"},j:[{L:"circle",B:"ytp-svg-autoplay-circle",O:{cx:"36",cy:"36",fill:"#fff","fill-opacity":"0.3",r:"31.5"}},{L:"circle",B:"ytp-svg-autoplay-ring",O:{cx:"-36",cy:"36","fill-opacity":"0",r:"33.5",stroke:"#FFFFFF","stroke-dasharray":"211","stroke-dashoffset":"-211","stroke-width":"4",transform:"rotate(-90)"}},{L:"path",B:"ytp-svg-fill",O:{d:"M 24,48 41,36 24,24 V 48 z M 44,24 v 24 h 4 V 24 h -4 z"}}]}]},{L:"span",B:"ytp-upnext-bottom", j:[{L:"span",B:"ytp-upnext-cancel"},{L:"span",B:"ytp-upnext-paused",Ga:"Reprodu\u00e7\u00e3o autom\u00e1tica pausada"}]}]});this.api=f;this.cancelButton=null;this.WS=this.JL("ytp-svg-autoplay-ring");this.N=this.notification=this.V=this.suggestion=null;this.A=new g.T6(this.U,5E3,this);this.X=0;var e=this.JL("ytp-upnext-cancel");this.cancelButton=new g.y({L:"button",y9:["ytp-upnext-cancel-button","ytp-button"],O:{tabindex:"0","aria-label":"Cancelar reprodu\u00e7\u00e3o autom\u00e1tica"},Ga:"Cancelar"}); g.A(this,this.cancelButton);this.cancelButton.listen("click",this.cS,this);this.cancelButton.di(e);this.cancelButton&&this.api.createClientVe(this.cancelButton.element,this,115129);g.A(this,this.A);this.api.createClientVe(this.element,this,18788);e=this.JL("ytp-upnext-autoplay-icon");this.D(e,"click",this.eI);this.api.createClientVe(e,this,115130);this.Cq();this.D(f,"autonavvisibility",this.Cq);this.D(f,"mdxnowautoplaying",this.PS);this.D(f,"mdxautoplaycanceled",this.Lq);g.h(this.element,"ytp-upnext-mobile", this.api.S().G)}U(){this.notification&&(this.A.stop(),this.uh(this.N),this.N=null,this.notification.close(),this.notification=null)}K(f){this.suggestion=f;g.HO(this,f,"hqdefault.jpg")}Cq(){this.FG(this.api.Ws());this.api.logVisibility(this.element,this.api.Ws());this.api.logVisibility(this.JL("ytp-upnext-autoplay-icon"),this.api.Ws());this.cancelButton&&this.api.logVisibility(this.cancelButton.element,this.api.Ws())}uY(){window.focus();this.U()}W(f){this.C()||(g.iO("a11y-announce",`${"Pr\u00f3ximo"} ${this.suggestion.title}`), this.X=(0,g.T)(),this.V=new g.T6(()=>{Wa(this,f)},25),Wa(this,f),F3L(this.api,UaG(this,f))); g.$i(this.element,"ytp-upnext-autoplay-paused")}hide(){super.hide()}C(){return!!this.V}J(){this.G();this.X=(0,g.T)();Wa(this);g.PW(this.element,"ytp-upnext-autoplay-paused")}G(){this.C()&&(this.V.dispose(),this.V=null)}select(f=!1){if(this.api.S().Y("autonav_notifications")&&f&&window.Notification&&typeof document.hasFocus==="function"){const e=Notification.permission;e==="default"?Notification.requestPermission():e!=="granted"||document.hasFocus()||(this.U(),this.notification=new Notification("Pr\u00f3ximo", {body:this.suggestion.title,icon:this.suggestion.iR()}),this.N=this.D(this.notification,"click",this.uY),this.A.start())}this.G();this.api.nextVideo(!1,f)}eI(f){!g.HN(this.cancelButton.element,f.target)&&g.mv(f,this.api)&&(this.api.Ws()&&this.api.logClick(this.JL("ytp-upnext-autoplay-icon")),this.select())}cS(){this.api.Ws()&&this.cancelButton&&this.api.logClick(this.cancelButton.element);g.C_(this.api,!0)}PS(f){this.api.getPresentingPlayerType();this.show();this.W(f)}Lq(){this.api.getPresentingPlayerType(); this.G();this.hide()}bY(){this.G();this.U();super.bY()}};var QUB=class extends ik{constructor(f){super(f,"autonav-endscreen");this.overlay=this.videoData=null;this.table=new g.y({L:"div",B:"ytp-suggestion-panel",j:[{L:"div",y9:["ytp-autonav-endscreen-upnext-header","ytp-autonav-endscreen-more-videos"],Ga:"Mais v\u00eddeos"}]});this.N=new g.y({L:"div",B:"ytp-suggestions-container"});this.videos=[];this.J=null;this.X=this.K=!1;this.G=new $N(this.player);g.A(this,this.G);this.G.di(this.element);f.getVideoData().IA?this.C=this.G:(this.C=new fo(f),g.qX(this.player, this.C.element,4),g.A(this,this.C));this.overlay=new g.y({L:"div",B:"ytp-autonav-overlay-cancelled-state"});g.A(this,this.overlay);this.overlay.di(this.element);this.W=new g.ep(this);g.A(this,this.W);g.A(this,this.table);this.table.di(this.element);this.table.show();g.A(this,this.N);this.N.di(this.table.element);this.hide()}create(){super.create();this.W.D(this.player,"appresize",this.U);this.W.D(this.player,"onVideoAreaChange",this.U);this.W.D(this.player,"videodatachange",this.onVideoDataChange); this.W.D(this.player,"autonavchange",this.Cq);this.W.D(this.player,"onAutonavCancelled",this.cS);this.onVideoDataChange()}show(){super.show();(this.K||this.J&&this.J!==this.videoData.clientPlaybackNonce)&&g.C_(this.player,!1);g.zJ(this.player)&&this.V()&&!this.J?(s6(this),this.videoData.autonavState===2?this.player.getVisibilityState()===3||Dz(this.player.lE())&&this.player.Y("web_player_pip_logging_fix")?this.C.select(!0):this.C.W():this.videoData.autonavState===3&&this.C.J()):(g.C_(this.player, !0),s6(this));this.U()}hide(){super.hide();this.C.J();s6(this)}U(){var f=this.player.jh(!0,this.player.isFullscreen());s6(this);xN(this.G);g.h(this.element,"ytp-autonav-cancelled-small-mode",this.B0(f));g.h(this.element,"ytp-autonav-cancelled-tiny-mode",this.Og(f));g.h(this.element,"ytp-autonav-cancelled-mini-mode",f.width<=400||f.height<=360);this.overlay&&g.uc(this.overlay.element,{width:`${f.width}px`});if(!this.X)for(f=0;f{g.PW(this.element,"ytp-show-tiles")},0); g.A(this,this.X);this.table=new g.af({L:"div",B:"ytp-modern-endscreen-content"});g.A(this,this.table);this.table.di(this.element);f.getVideoData().IA?this.C=new $N(f,!0):this.C=new fo(f);g.A(this,this.C);g.qX(this.player,this.C.element,4);f.createClientVe(this.element,this,158789);this.hide()}create(){super.create();var f=this.player.getVideoData();f&&(this.videoData=f);this.J();this.G.D(this.player,"appresize",this.J);this.G.D(this.player,"onVideoAreaChange",this.J);this.G.D(this.player,"videodatachange", this.onVideoDataChange);this.G.D(this.player,"autonavchange",this.K);this.G.D(this.player,"onAutonavCancelled",this.cS);f=this.videoData.autonavState;f!==this.Cq&&this.K(f);this.G.D(this.element,"transitionend",this.eI)}destroy(){this.G.G();g.II(this.stills);this.stills=[];super.destroy();g.$i(this.element,"ytp-show-tiles");this.X.stop();this.Cq=this.videoData.autonavState}V(){return this.videoData.autonavState!==1}show(){const f=this.ef;super.show();g.$i(this.element,"ytp-show-tiles");this.player.S().G? g.G6(this.X):this.X.start();(this.U||this.W&&this.W!==this.videoData.clientPlaybackNonce)&&g.C_(this.player,!1);X2(this)?(yn(this),this.videoData.autonavState===2?this.player.getVisibilityState()===3||Dz(this.player.lE())&&this.player.Y("web_player_pip_logging_fix")?this.C.select(!0):this.C.W():this.videoData.autonavState===3&&this.C.J()):(g.C_(this.player,!0),yn(this));f!==this.ef&&this.player.logVisibility(this.element,!0)}hide(){const f=this.ef;super.hide();this.C.J();yn(this);f!==this.ef&&this.player.logVisibility(this.element, !1)}eI(f){f.target===this.element&&this.J()}J(){const f=this.videoData?.suggestions?.length?this.videoData?.suggestions:[this.videoData?.N()];if(f.length){var e=this.Z.jh(!0,this.Z.isFullscreen()),B=Math.floor((e.width-64+16)/(g.ch(e.width*.27,250,450)+16));e=Math.min(3,Math.floor((e.height-64)/((e.width-64-(B-1)*16)/B*.5625+70)));g.il(this.element,["ytp-modern-endscreen-limit-rows-1","ytp-modern-endscreen-limit-rows-2","ytp-modern-endscreen-limit-rows-3"]);g.PW(this.element,`ytp-modern-endscreen-limit-rows-${e}`); g.h(this.element,"ytp-modern-endscreen-single-item",B===1);g.h(this.element,"ytp-modern-endscreen-row-0",e===0);B=this.table.element;B.ariaLive="polite";this.C.K(this.videoData.N());this.C instanceof $N&&xN(this.C);g.h(this.element,"ytp-endscreen-takeover",X2(this));yn(this);e=0;B.ariaBusy="true";var n=f.length;for(let r=0;r{g.PW(this.element,"ytp-show-tiles")},0); g.A(this,this.K);var e=new g.y({L:"button",y9:["ytp-button","ytp-endscreen-previous"],O:{"aria-label":"Anterior"},j:[g.d_()]});g.A(this,e);e.di(this.element);e.listen("click",this.PS,this);this.table=new g.af({L:"div",B:"ytp-endscreen-content"});g.A(this,this.table);this.table.di(this.element);e=new g.y({L:"button",y9:["ytp-button","ytp-endscreen-next"],O:{"aria-label":"Pr\u00f3ximo"},j:[g.tX()]});g.A(this,e);e.di(this.element);e.listen("click",this.WS,this);f.getVideoData().IA?this.C=new $N(f,!0): this.C=new fo(f);g.A(this,this.C);g.qX(this.player,this.C.element,4);f.createClientVe(this.element,this,158789);this.hide()}create(){super.create();var f=this.player.getVideoData();f&&(this.videoData=f);this.G();this.J.D(this.player,"appresize",this.G);this.J.D(this.player,"onVideoAreaChange",this.G);this.J.D(this.player,"videodatachange",this.onVideoDataChange);this.J.D(this.player,"autonavchange",this.N);this.J.D(this.player,"onAutonavCancelled",this.eI);f=this.videoData.autonavState;f!==this.cS&& this.N(f);this.J.D(this.element,"transitionend",this.Lq)}destroy(){this.J.G();g.II(this.stills);this.stills=[];super.destroy();g.$i(this.element,"ytp-show-tiles");this.K.stop();this.cS=this.videoData.autonavState}V(){return this.videoData.autonavState!==1}show(){const f=this.ef;super.show();g.$i(this.element,"ytp-show-tiles");this.player.S().G?g.G6(this.K):this.K.start();(this.X||this.U&&this.U!==this.videoData.clientPlaybackNonce)&&g.C_(this.player,!1);Pa(this)?(IX(this),this.videoData.autonavState=== 2?this.player.getVisibilityState()===3||Dz(this.player.lE())&&this.player.Y("web_player_pip_logging_fix")?this.C.select(!0):this.C.W():this.videoData.autonavState===3&&this.C.J()):(g.C_(this.player,!0),IX(this));f!==this.ef&&this.player.logVisibility(this.element,!0)}hide(){const f=this.ef;super.hide();this.C.J();IX(this);f!==this.ef&&this.player.logVisibility(this.element,!1)}Lq(f){f.target===this.element&&this.G()}G(){var f=this.videoData?.suggestions?.length?this.videoData?.suggestions:[this.videoData?.N()]; if(f.length){g.PW(this.element,"ytp-endscreen-paginate");var e=this.Z.jh(!0,this.Z.isFullscreen()),B=g.n_(this.Z);B&&(B=B.E3()?48:32,e.width-=B*2);var n=e.width/e.height,r=96/54,L=B=2,d=Math.max(e.width/96,2),t=Math.max(e.height/54,2),H=f.length;var k=H*4;for(k-=4;k>0&&(B=w*4,b=L<=t-2&&k>=C*4;if((C+1)/w*r/n>n/(C/(w+1)*r)&&b)k-=C*4,L+=2;else if(v)k-=w*4,B+=2;else if(b)k-=C*4,L+=2;else break}r=!1;k>=12&&H*4-k<=6&&(L>=4||B>=4)&&(r=!0);k=B*96;d=L*54;n=k/d=B-2&&C>=L-2?b=1:C%2===0&&t%2===0&&(C<2&&t<2?C===0&&t===0&&(b=2):b=2),v=g.Aj(v+this.W,H), b!==0){w=this.stills[n];w||(w=new JGH(this.player),this.stills[n]=w,e.appendChild(w.element));var K=Math.floor(d*C/L);const Y=Math.floor(k*t/B),l=Math.floor(d*(C+b)/L)-K-4,m=Math.floor(k*(t+b)/B)-Y-4;g.Em(w.element,Y,K);g.xC(w.element,m,l);g.uc(w.element,"transitionDelay",(C+t)/20+"s");g.h(w.element,"ytp-videowall-still-mini",b===1);g.h(w.element,"ytp-videowall-still-large",b>2);b=Math.max(m,l);g.h(w.element,"ytp-videowall-still-round-large",b>=256);g.h(w.element,"ytp-videowall-still-round-medium", b>96&&b<256);g.h(w.element,"ytp-videowall-still-round-small",b<=96);v=f[v];w.suggestion!==v&&(w.suggestion=v,b=w.api.S(),K=g.yC(w.element,"ytp-videowall-still-large")?"hqdefault.jpg":"mqdefault.jpg",g.HO(w,v,K),g.XY(b)&&!w.api.Y("web_player_log_click_before_generating_ve_conversion_params")&&(b=v.Q7(),K={},g.$7(w.api,"addEmbedsConversionTrackingParams",[K]),b=g.vT(b,K),w.updateValue("url",b)),(v=(v=v.sessionData)&&v.itct)&&w.api.setTrackingParams(w.element,v));n++}e.ariaBusy="false";g.h(this.element, "ytp-endscreen-paginate",n=n;f--)B=this.stills[f],g.tb(B.element),g.PT(B);this.stills.length=n}}onVideoDataChange(){const f=this.player.getVideoData({playerType:1});this.videoData!==f&&(f?.N()?(this.W=0,this.videoData=f,this.G()):this.player.ri("missg",{vid:f?.videoId||"",cpn:f?.clientPlaybackNonce||""}))}WS(){this.W+=this.stills.length;this.G()}PS(){this.W-=this.stills.length;this.G()}A(){return this.C.C()}N(f){f===1?(this.X=!1,this.U=this.videoData.clientPlaybackNonce, this.C.G(),this.ef&&this.G()):(this.X=!0,this.ef&&Pa(this)&&(f===2?this.C.W():f===3&&this.C.J()))}eI(f){if(f){for(f=0;f{this.onCueRangeEnter(B)}); this.listeners.D(f,g.Ca("endscreen"),B=>{this.onCueRangeExit(B)})}sL(){var f=this.player.getVideoData(); const e=f.mutedAutoplay&&(f.limitedPlaybackDurationInSeconds>0||f.endSeconds>0||f.mutedAutoplayDurationMode!==2);if(this.player.isEmbedsShortsMode()&&!e)return!0;var B=!(!f?.N()&&!f?.suggestions?.length);B=!NPe(this.player)||B;f=f.Uj;const n=this.player.vC();return B&&!f&&!n&&!e}Ws(){return this.endScreen.Ws()}TW(){return this.Ws()?this.endScreen.A():!1}bY(){this.player.sK("endscreen");super.bY()}load(){{const B=this.player.getVideoData(),n=B.transitionEndpointAtEndOfStream;if(n&&n.videoId){var f= this.player.iC().L5.get("heartbeat");var e=B.N();!e||n.videoId!==e.videoId||B.E7?(this.player.P6(n.videoId,void 0,void 0,!0,!0,n),f&&f.oI("HEARTBEAT_ACTION_TRIGGER_AT_STREAM_END","HEARTBEAT_ACTION_TRANSITION_REASON_HAS_NEW_STREAM_TRANSITION_ENDPOINT"),f=!0):f=!1}else f=!1}f||(super.load(),this.endScreen.show())}unload(){super.unload();this.endScreen.hide();this.endScreen.destroy()}onCueRangeEnter(f){this.sL()&&(this.endScreen.created||this.endScreen.create(),f.getId()==="load"&&this.load())}onCueRangeExit(f){f.getId()=== "load"&&this.loaded&&this.unload()}onVideoDataChange(){g_G(this);this.J&&hVx(this)&&(this.endScreen&&(this.endScreen.hide(),this.endScreen.created&&this.endScreen.destroy(),this.endScreen.dispose()),this.C?this.endScreen=new QUB(this.player):this.endScreen=new MWM(this.player),g.A(this,this.endScreen),g.qX(this.player,this.endScreen.element,4))}});})(_yt_player);