(window.__LOADABLE_LOADED_CHUNKS__=window.__LOADABLE_LOADED_CHUNKS__||[]).push([[610],{Lajh:function(e,t,i){i.r(t);var n=i("q1tI"),o=i("/MKj"),a=i("gxu6"),s=i("mp1x"),l=i("kmwA"),p=i("g6r8"),c=i("/8nX"),r=i("B/oJ"),g=i("6adH"),h=i("ANjH"),d=i("4NNh"),u=i("isp9"),_=i("TXO6"),b=i("Q5BC"),m=i("vKjI"),O=i("VL22"),j=i("AGnR"),w=i("28DW"),y=i("b7nI"),T=i("tCfZ"),f=i("yweb"),S=i("n6mq"),v=i("nKUr");function L(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const x="staticSignupLogin",C="staticSignupLoginWithTOS",k="mweb_google_one_tap.confirmation_dialog";class D extends n.Component{constructor(...e){super(...e),L(this,"handleCancelClick",e=>{Object(w.a)(`${k}.${e}.cancel.click`),Object(j.h)({element:73,view_parameter:3202,view_type:10}),this.props.handleCancelClick()}),L(this,"handleConfirmSignup",(e,t=!0)=>{Object(w.a)(`${k}.${e}.confirm.click`),Object(j.h)({element:31,view_parameter:3202,view_type:10}),this.props.handleConfirmSignup(t)}),L(this,"handleShowLogin",e=>{Object(w.a)(`${k}.${e}.login.click`),Object(j.h)({element:30,view_parameter:3202,view_type:10}),this.props.handleShowLogin()})}componentDidMount(){Object(w.a)(`${k}.${this.props.initialStep}.shown`)}componentWillUnmount(){this.enableBackgroundScrolling()}enableBackgroundScrolling(){document.body&&(document.body.style.overflow="")}render(){const{initialStep:e}=this.props;return Object(v.jsxs)(S.f,{children:[this.props.loading?Object(v.jsx)(y.a,{}):null,Object(v.jsxs)(S.f,{padding:3,children:[Object(v.jsx)(S.f,{display:"inlineBlock",position:"absolute",top:!0,right:!0,marginTop:2,marginEnd:2,children:Object(v.jsx)(S.x,{accessibilityLabel:this.props.i18n._("Cancel","Button to close the signup/login modal","Button to close the signup/login modal"),icon:"cancel",onClick:()=>this.handleCancelClick(e),size:"sm"})}),Object(v.jsx)(S.cb,{align:"start",weight:"bold",children:Object(v.jsx)("span",{className:"deprecatedTextSizeXL",children:this.props.i18n._("Continue to Pinterest","Title of a dialog telling enabling the user to continue with sign up or log in","Title of a dialog telling enabling the user to continue with sign up or log in")})}),Object(v.jsx)(S.f,{marginTop:2,children:Object(v.jsx)(S.cb,{align:"start",children:this.props.i18n._("Hmm, it looks like you don't have an account yet. Let's get started!","Description text of a dialog asking the user to sign up for a Pinterest account","Description text of a dialog asking the user to sign up for a Pinterest account")})}),Object(v.jsx)(S.f,{marginTop:5,children:Object(v.jsx)(S.g,{fullWidth:!0,color:"red",onClick:()=>this.handleConfirmSignup(e),text:this.props.i18n._("Sign up","Text on a button which will create an account when clicked","Text on a button which will create an account when clicked")})}),Object(v.jsx)(S.f,{marginTop:2,children:Object(v.jsx)(S.g,{fullWidth:!0,color:"gray",onClick:()=>this.handleShowLogin(e),text:this.props.i18n._("Log in using a different method","Text on a button which will take the user to login when clicked","Text on a button which will take the user to login when clicked")})}),this.props.initialStep===C?Object(v.jsx)(S.f,{marginTop:6,children:Object(v.jsx)(T.a,{})}):null]})]})}}var I=function(e){const t=Object(f.c)();return Object(v.jsx)(D,{...e,i18n:t})},A=i("ulr2"),G=i("h7e3"),U=i("QAzJ"),E=i("37no"),R=i("EC67");function B(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class z extends n.PureComponent{constructor(...e){super(...e),B(this,"state",{loading:!1,confirmationDialogStep:void 0,googleOpenId:"",showRegisterLoading:!1}),B(this,"oneTapLogging",{element:null,interval:null}),B(this,"annotateOneTapStopwatch",e=>{Object(G.b)("google_autologin",e)}),B(this,"abortOneTapStopwatch",e=>{Object(G.a)("google_autologin",e)}),B(this,"stopOneTapStopwatch",()=>{Object(G.d)("google_autologin")}),B(this,"onRetrieveCredentialsSuccess",e=>{const{initializationHandledExternally:t,history:i,isAuthenticated:n,isLimitedLoginUser:o,location:a,login:s}=this.props;this.showLoading(),Object(w.j)("mweb_google_one_tap.retrieve_credential.success");const l={google_open_id_token:e.idToken,autologin:"auto"===(e.selectBy||"")};if(l.autologin&&t)return;Object(j.e)({event_type:7534,view_type:10,view_parameter:3201,aux_data:{...n?{login_state:o?2:1}:{},signup_login_method:4}});const p=e.selectBy.includes("btn")?"gsi_btn":e.selectBy.includes("user")?"onetap_btn":"other";s(l,i,a.pathname,{isAutologin:l.autologin,trigger:p}).then(()=>{Object(j.e)({event_type:7536,view_type:10,view_parameter:3201,aux_data:{...n?{login_state:o?2:1}:{},signup_login_method:4}})},e=>{Object(j.e)({event_type:7535,view_type:10,view_parameter:3201,aux_data:{...n?{login_state:o?2:1}:{},signup_login_method:4}}),this.onLoginFailure(l,e)})}),B(this,"onRetrieveCredentialsFailure",(e,t)=>{const i=e&&e.type||"unknown";Object(w.j)(`mweb_google_one_tap.${t}.error.${i}`)}),B(this,"onLoginFailure",(e,t)=>{this.hideLoading();const i=t&&t.apiErrorCode||0;if(Object(w.j)("mweb_google_one_tap.hint.login.error."+i),30!==i||this.props.isTablet)this.props.showToast({text:t.message||this.props.i18n._("We couldn’t log you in with that account. Try the Google button!")}),this.props.handleLoginError();else{const t=this.determineConfirmationDialogStep();t===x||t===C?this.showConfirmationDialog(e,t):this.attemptSignup(e.google_open_id_token,!1)}}),B(this,"onSignupSuccess",(e,t)=>{const{isAuthenticated:i,isLimitedLoginUser:n}=this.props;this.setState({showRegisterLoading:!1}),Object(w.j)("mweb_google_one_tap.hint.signup.success"),Object(j.e)({event_type:7487,view_type:10,view_parameter:t?3202:3201,aux_data:{...i?{login_state:n?2:1}:{},signup_login_method:4}}),this.props.history.push("/")}),B(this,"onSignupFailure",(e,t)=>{const{isAuthenticated:i,isLimitedLoginUser:n}=this.props,o=e&&e.api_error_code||0;Object(w.j)("mweb_google_one_tap.hint.signup.error."+o),Object(j.e)({event_type:7488,view_type:10,view_parameter:t?3202:3201,aux_data:{...i?{login_state:n?2:1}:{},signup_login_method:4}}),this.hideLoading(),this.hideConfirmationDialog(),this.props.showToast({text:e.message||this.props.i18n._("We couldn’t sign you up with that account. Try the Google button!")}),this.props.handleSignupError()}),B(this,"determineConfirmationDialogStep",()=>{const{location:e}=this.props;return Object(u.y)(e)?x:""}),B(this,"handleCancelOneTap",()=>{this.hideConfirmationDialog()}),B(this,"navigateToLogin",()=>{this.handleCancelOneTap(),this.props.history.push({pathname:"/login/",state:{next:this.props.location.pathname}})}),B(this,"attemptSignup",(e,t)=>{const{country:i,isAuthenticated:n,isLimitedLoginUser:o}=this.props,a=this.decodeToken(e),s={google_open_id_token:e,first_name:a.given_name,last_name:a.family_name,image_url:a.picture};if(Object(O.d)(i))return this.hideLoading(),this.hideConfirmationDialog(),void this.props.history.push({pathname:"/signup/thirdpartyage/",state:{signupOptions:s,signupPlatform:"gtap"}});this.setState({showRegisterLoading:!0}),Object(j.e)({event_type:7537,view_type:10,view_parameter:t?3202:3201,aux_data:{...n?{login_state:o?2:1}:{},signup_login_method:4}}),this.props.register(s).then(e=>this.onSignupSuccess(e,t),e=>this.onSignupFailure(e,t))}),B(this,"handleConfirmOneTapSignup",e=>{e&&this.showLoading();const{googleOpenId:t}=this.state;this.attemptSignup(t,!0)})}componentDidMount(){const{initializationHandledExternally:e,googleOneTapDisabled:t,handleEmptyCredentials:i,mwebGoogleDisabled:n}=this.props;e||(a.a("fba")||n?(t(),this.abortOneTapStopwatch("disabled"),i&&i()):this.setupGoogleOneTap())}componentDidUpdate(e){const{externalGSIResponse:t}=this.props;t&&!e.externalGSIResponse&&this.handleOneTapResponse(t)}initializeGoogleOneTap(){const{activateDelayAutologinExp:e,activateiOSOneTapExp:t,googleOneTapInitialized:i,platform:n}=this.props;Object(w.j)("mweb_google_one_tap.sdk_exists"),this.oneTapLogging.interval=setInterval(()=>this.checkForOneTapUI(),100);const o=window.google.accounts.id;o.initialize({activity_listener:this.handleActivity.bind(this),auto_select:!0,callback:this.handleOneTapResponse.bind(this),cancel_on_tap_outside:!1,client_id:l.a.settings.GPLUS_CLIENT_ID,context:"use",itp_support:"ios"===n&&t().anyEnabled}),i(),Object(w.j)("mweb_google_one_tap.initialize");let a=0;const{group:s}=e();if(s.startsWith("enabled_google")||s.startsWith("enabled_both"))try{const e=s.split("_");a=parseInt(e[2],10)||0}catch(p){Object(w.j)("mweb_unauth_delay_autologin_error."+s)}a>0?setTimeout(()=>{o.prompt(this.handleMomentNotification.bind(this))},a):o.prompt(this.handleMomentNotification.bind(this))}getGoogleId(){if("undefined"==typeof window)return null;const e=window.google;return e&&e.accounts&&e.accounts.id}setupGoogleOneTap(){this.annotateOneTapStopwatch("beforeLoadOneTapScript"),Object(w.j)("mweb_unauth.gsi_script.start_dynamic_loading"),this.loadOneTapScript("https://accounts.google.com/gsi/client").then(()=>{this.annotateOneTapStopwatch("afterLoadOneTapScript");const e=window.google;e&&e.accounts&&e.accounts.id?this.initializeGoogleOneTap():this.abortOneTapStopwatch("noAccountFound")})}loadOneTapScript(e){return Object(w.j)("mweb_google_one_tap.load_script.attempt"),Object(E.c)(e,E.a.GSI).then(()=>{Object(w.j)("mweb_google_one_tap.load_script.success")}).catch(()=>{Object(w.j)("mweb_google_one_tap.load_script.fail")})}handleMomentNotification(e){const{location:t}=this.props,i=e.getMomentType();if("display"===i){this.annotateOneTapStopwatch("handleMomentDisplay");e.isDisplayed()?Object(w.j)("mweb_google_one_tap.display_moment.displayed"):Object(w.j)("mweb_google_one_tap.display_moment.not_displayed."+e.getNotDisplayedReason())}else"skipped"===i?(Object(w.j)("mweb_google_one_tap.skipped_moment."+e.getSkippedReason()),Object(u.y)(t)||this.props.hideGoogleOneTap()):"dismissed"===i&&(Object(u.y)(t)||this.props.hideGoogleOneTap(),Object(w.j)("mweb_google_one_tap.dismissed_moment."+e.getDismissedReason()))}handleOneTapResponse(e){e?(this.checkForOneTapUI(),this.stopOneTapStopwatch(),Object(w.j)("mweb_google_one_tap.select_by."+e.select_by),this.onRetrieveCredentialsSuccess({idToken:e.credential,selectBy:e.select_by})):this.abortOneTapStopwatch("noResponse")}handleActivity(e){if(e){if("error"===e.type)return Object(w.j)("mweb_google_one_tap.error."+e.errorType),void this.props.hideGoogleOneTap();const t="ui_change"===e.type?e.uiActivityType:e.userActivityType;Object(w.j)(`mweb_google_one_tap.activity.${e.type}.${null!=t?t:""}`),"prompt_displayed"===t?this.props.showGoogleOneTap():"close_prompt"===t&&this.props.hideGoogleOneTap()}}checkForOneTapUI(){const e=document.getElementById("credential_picker_iframe");e?"none"===e.style.display||this.oneTapLogging.element||(this.annotateOneTapStopwatch("oneTapUIAppears"),this.oneTapLogging.element=e):this.oneTapLogging.element&&(this.annotateOneTapStopwatch("oneTapUIDisappears"),this.oneTapLogging.element=null,this.oneTapLogging.interval&&clearInterval(this.oneTapLogging.interval))}componentWillUnmount(){Object(w.j)("mweb_google_one_tap.dismiss_iframe.attempt"),Object(d.c)(window.smartlock),this.oneTapLogging.interval&&clearInterval(this.oneTapLogging.interval)}base64urlUnescape(e){return e.replace(/\-/g,"+").replace(/_/g,"/")}decodeToken(e){return JSON.parse(decodeURIComponent(atob(this.base64urlUnescape(e.split(".")[1])).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")))}showConfirmationDialog(e,t){this.setState({googleOpenId:e.google_open_id_token,confirmationDialogStep:t})}hideConfirmationDialog(){this.setState({confirmationDialogStep:void 0})}showLoading(){this.setState({loading:!0})}hideLoading(){this.setState({loading:!1,showRegisterLoading:!1})}render(){const{confirmationDialogStep:e,showRegisterLoading:t}=this.state,{mwebGoogleDisabled:i}=this.props;return i?null:t?Object(v.jsx)(r.a,{platform:"gtap"}):e?Object(v.jsx)(c.a,{viewType:10,viewParameter:3202,children:Object(v.jsx)(s.a,{isOpen:!0,type:"google_one_tap",children:Object(v.jsx)(I,{handleCancelClick:this.handleCancelOneTap,handleConfirmSignup:this.handleConfirmOneTapSignup,handleShowLogin:this.navigateToLogin,initialStep:e,loading:this.state.loading})})}):null}}t.default=Object(h.compose)(R.l,g.a,Object(o.connect)(({session:e,users:t={}})=>({country:e.country,isTablet:e.isTablet,isAuthenticated:e.isAuthenticated,isLimitedLoginUser:Object(_.b)(t[e.userId]),platform:e.userAgentPlatform}),e=>({login:(t,i,n,o)=>e(Object(b.b)(t,i,n,o)),register:t=>e(Object(m.a)(t)),showGoogleOneTap:()=>e(Object(A.G)()),hideGoogleOneTap:()=>e(Object(A.f)()),googleOneTapDisabled:()=>e(Object(A.c)()),googleOneTapInitialized:()=>e(Object(A.d)())})))((function(e){const t=Object(f.c)(),i=Object(p.a)(),n=Object(U.a)("mweb_unauth_ios_one_tap"),{anyEnabled:o}=Object(U.b)("mweb_google_disabled"),a=Object(U.a)("desktop"===i?"web_unauth_delay_autologin":"mweb_unauth_delay_autologin");return Object(v.jsx)(z,{...e,i18n:t,activateDelayAutologinExp:a,activateiOSOneTapExp:n,mwebGoogleDisabled:o})}))},b7nI:function(e,t,i){var n=i("yweb"),o=i("n6mq"),a=i("nKUr");const s=()=>{const e=Object(n.c)();return Object(a.jsx)(o.U,{accessibilityLabel:e._("Loading","Label for loading spinner","Label for loading spinner"),show:!0})};t.a=()=>Object(a.jsxs)(o.f,{children:[Object(a.jsx)(o.f,{alignItems:"center",display:"flex",justifyContent:"center",position:"absolute",top:!0,left:!0,bottom:!0,right:!0,opacity:1,dangerouslySetInlineStyle:{__style:{zIndex:101}},children:Object(a.jsx)(s,{})}),Object(a.jsx)(o.f,{color:"white",position:"absolute",top:!0,left:!0,bottom:!0,right:!0,opacity:.7,dangerouslySetInlineStyle:{__style:{zIndex:100}}})]})}}]);
//# sourceMappingURL=https://sm.pinimg.com/webapp/610-19b47217f96c0671717b.mjs.map