(self.__LOADABLE_LOADED_CHUNKS__=self.__LOADABLE_LOADED_CHUNKS__||[]).push([[72706],{272706:(e,o,t)=>{t.r(o),t.d(o,{default:()=>S});var i=t(667294),n=t(231486),a=t(157796),s=t(121151),r=t(830269),c=t(499128),l=t(226198),d=t(349700),_=t(773285),u=t(780280),p=t(50286),h=t(898781),g=t(112690),m=t(69642),b=t(701563),w=t(807998),f=t(966113);const k=()=>!!n.U2(l.x3)||!!n.U2(l.e7);var v=t(867820),A=t(6637),y=t(467570);const P=()=>{return(e=`${f.cD}/v3/handshake/verify/`,o="GET",new Promise(((i,n)=>{const a=new XMLHttpRequest;a.withCredentials=!0,a.open(o,e),"POST"===o&&a.setRequestHeader("Content-type","application/x-www-form-urlencoded; charset=UTF-8"),a.onload=()=>{try{const e=JSON.parse(a.responseText);"success"===e.status?i(e):n({api_error_code:e.code,httpStatus:a.status,...e})}catch(e){n({httpStatus:a.status,message:e.message})}},a.onerror=()=>n(a.statusText),a.send(t)}))).then((e=>{if(e&&e.data)return o=e.data,A.Z.create("HandshakeSessionResource",{token:o,get_user:!0}).callCreate();throw new Error("No custom access token in cross domain verify response");var o})).catch((e=>{throw e}));var e,o,t};var x=t(275926),L=t(883119),E=t(276775),T=t(343341),C=t(785893);class F extends i.Component{constructor(...e){var o,t,i;super(...e),i={fbEmail:null,fbName:null,showFbAutoLoginModal:!1},(t="state")in(o=this)?Object.defineProperty(o,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):o[t]=i}componentDidMount(){const{isAuthenticated:e,facebookAutologinDisabled:o}=this.props;if(!e){if(n.U2(l.e7)?(0,v.My)("mweb_previously_logged_out.true"):(0,v.My)("mweb_previously_logged_out.false"),this.attemptCrossDomainAutologin(),this.attemptSmartlockAutologin(),o)return void(0,v.My)("mweb_fb_autologin_disabled_by_experiment");this.attemptFBAutologin()}}attemptCrossDomainAutologin(){if("undefined"!=typeof window&&window.PINTEREST_DISABLE_CCTLD_AUTO)return void(0,v.My)("dev.autologin_disabled.cctld");const{crossDomainAutoLogin:e}=this.props;if(!w.Z.includes(window.location.origin)||k())return;const o=e=>{const{logContextEvent:o,trackConversion:t}=this.props;o({event_type:{attempt:7534,success:7536,fail:7535}[e],view_type:10,view_parameter:63,aux_data:{signup_login_method:r.Z.EMAIL}}),t({action:"autologin",event:e,type:"cctld"})};o("attempt");try{P().then(e).then((()=>{o("success"),"undefined"!=typeof window&&window.location&&window.location.reload()})).catch((()=>{o("fail")}))}catch(t){o("fail")}}attemptSmartlockAutologin(){if("undefined"!=typeof window&&window.PINTEREST_DISABLE_SMARTLOCK_AUTO)return void(0,v.My)("dev.autologin_disabled.smartlock");const{smartLockUseAlternativeResourceCall:e,history:o,location:t,login:i}=this.props;(()=>{const e=window.navigator.credentials;return!e||k()?Promise.reject():e.get({password:!0})})().then((n=>{n&&i({username_or_email:n.id,password:n.password},o,t.pathname,{isAutologin:!0,useAlternativeResourceCall:e},{event_type:7534,view_type:10,view_parameter:3204,aux_data:{signup_login_method:r.Z.SMARTLOCK}}).catch((()=>{}))})).catch((()=>{}))}attemptFBAutologin(){if("undefined"!=typeof window&&window.PINTEREST_DISABLE_FB_AUTO)return(0,v.My)("dev.autologin_disabled.facebook"),void(0,b.RP)("facebook_autologin","autologin_disabled");const{history:e,locale:o,location:t,login:i,showToast:n}=this.props;(0,v.dy)({event:"start",provider:"facebook"}),(0,b.M3)("facebook_autologin","autoLoginFacebookStart"),(({locale:e})=>k()?Promise.reject({status:"autologin_disabled"}):(0,y.we)(e,!0).then(y.Jb).then((e=>{if("connected"!==e.status)throw(0,v.dy)({event:"receive_no_credential_response_from_provider",provider:"facebook"}),new Error("not connected to FB");return(0,v.dy)({event:"receive_credential_response_from_provider",provider:"facebook"}),(0,b.M3)("facebook_autologin","autoLoginFacebookInitEnd"),new Promise((e=>setTimeout(e,3e3))).then((()=>{const{userID:o,accessToken:t}=e.authResponse;return{creds:{facebook_id:o,facebook_token:t,facebook_autologin:!0}}}))})))({locale:o}).then((({creds:o,signupOptions:a})=>{(0,b.M3)("facebook_autologin","autoLoginFacebookEnd"),this.setState({showFbAutoLoginModal:!0,fbEmail:a&&a.email,fbName:a&&a.first_name}),(0,v.dy)({event:"show_ui",provider:"facebook"}),(0,b.PA)("facebook_autologin"),(0,v.dy)({event:"pinterest_login_start",provider:"facebook"}),i(o,e,t.pathname,{isAutologin:!0},{event_type:7534,view_type:10,view_parameter:3205,aux_data:{signup_login_method:r.Z.FACEBOOK}}).then((()=>{this.setState({showFbAutoLoginModal:!1}),(0,v.dy)({event:"hide_ui",provider:"facebook"}),(0,v.dy)({event:"pinterest_login_success",provider:"facebook"}),n((({hideToast:e})=>(0,C.jsx)(c.ZP,{text:a&&a.first_name?(0,d.nk)(this.props.i18n.bt("Welcome back to Pinterest, {{ name }}!", "Welcome back to Pinterest, {{ name }}!", "welcoming user back to pinterest when autologin with first name", undefined, true),{name:a.first_name}).join(""):this.props.i18n.bt("Welcome back to Pinterest!", "Welcome back to Pinterest!", "welcoming user back to pinterest when autologin", undefined, true),duration:4e3,onHide:e}))),(0,v.dy)({event:"end",provider:"facebook"})})).catch((()=>{this.setState({showFbAutoLoginModal:!1}),(0,v.dy)({event:"pinterest_login_failure",provider:"facebook"}),(0,v.dy)({event:"end",provider:"facebook"})}))})).catch((()=>{(0,b.RP)("facebook_autologin","autoLoginFacebookFailed")}))}render(){const{i18n:e}=this.props,{fbEmail:o,fbName:t,showFbAutoLoginModal:i}=this.state;return(0,C.jsxs)(s.ZP,{accessibilityModalLabel:"",isOpen:i,type:"autologin",closeOnOutsideClick:!1,onDismiss:()=>{},children:[(0,C.jsx)(a.Z,{duration:1500,finalProgress:95}),(0,C.jsxs)(L.xu,{alignItems:"center",direction:"column",display:"flex",paddingX:o?10:12,paddingY:6,children:[(0,C.jsx)(L.JO,{icon:"pinterest",color:"brandPrimary",accessibilityLabel:e.bt("Pinterest logo", "Pinterest logo", " - ", undefined, true),size:24}),(0,C.jsx)(L.xu,{marginTop:1,paddingY:1,children:(0,C.jsx)(L.xv,{align:"center",children:(0,C.jsx)(L.X6,{size:"500",children:t?(0,d.nk)(this.props.i18n.bt("Welcome back, {{ name }}!", "Welcome back, {{ name }}!", "welcome back with first name", undefined, true),{name:t}).join(""):this.props.i18n.bt("Welcome back!", "Welcome back!", "Welcome back!", undefined, true)})})}),(0,C.jsx)(L.xv,{align:"center",children:o?(0,d.nk)(this.props.i18n.bt("We're logging you in with your Facebook account, {{ email }}", "We're logging you in with your Facebook account, {{ email }}", "logging in user with facebook account and email associated", undefined, true),{email:(0,C.jsx)(L.xv,{inline:!0,weight:"bold",children:o},"fbEmail")}):this.props.i18n.bt("We're logging you in with your Facebook account...", "We're logging you in with your Facebook account...", "logging in user with Facebook account", undefined, true)})]})]})}}function S(){const e=(0,E.useHistory)(),o=(0,E.useLocation)(),t=(0,h.ZP)(),{checkExperiment:i}=(0,_.F)(),n=(0,g.Z)(),a=(0,p.ZP)(),s=(0,x.f0)(),r=(0,x.lq)(),c=(0,m.Z)(),{country:l,isAuthenticated:d,locale:b}=(0,u.B)(),{group:w}=i("desktop"===a?"web_facebook_disabled":"mweb_facebook_disabled"),{showToast:f}=(0,T.F9)();return(0,C.jsx)(F,{crossDomainAutoLogin:r,deviceType:a,history:e,i18n:t,isAuthenticated:d,locale:b,location:o,logContextEvent:n,login:s,facebookAutologinDisabled:"enabled"===w||"CH"===l,smartLockUseAlternativeResourceCall:"desktop"===a,showToast:f,trackConversion:c})}}}]);
//# sourceMappingURL=https://sm.pinimg.com/webapp/72706.en_AU-32334596092adeb4.mjs.map