(window.__LOADABLE_LOADED_CHUNKS__=window.__LOADABLE_LOADED_CHUNKS__||[]).push([[609],{"4aTO":function(e,t,o){o.r(t),o.d(t,"track",(function(){return y}));var a=o("q1tI"),n=o("/MKj"),i=o("gxu6"),s=o("9Hil"),c=o("mp1x"),l=o("g6r8"),r=o("6adH"),u=o("J8m7"),d=o("qpbZ"),b=o("3h4M"),g=o("AGnR"),m=o("ulr2"),p=o("yweb"),_=o("h7e3"),h=o("rvfI"),w=o("28DW"),j=o("QAzJ"),f=o("n6mq"),k=o("ANjH"),O=o("Q5BC"),A=o("nKUr");const y=(e,t,o)=>{Object(w.j)(`${o?o+".":""}mweb_autologin.${t}_${e}`),"attempt"===e&&Object(w.g)({action:"autologin",event:"attempt",type:t})};class v extends a.Component{constructor(...e){var t,o,a;super(...e),a={fbEmail:null,fbName:null,showFbAutoLoginModal:!1,facebookAutologinFailed:!1,googleAutologinFailed:!1,smartlockAutologinFailed:!1},(o="state")in(t=this)?Object.defineProperty(t,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[o]=a}componentDidUpdate(e,t){const{trackAutologinFailure:o}=this.props,{facebookAutologinFailed:a,googleAutologinFailed:n,smartlockAutologinFailed:i}=this.state,{facebookAutologinFailed:s,googleAutologinFailed:c,smartlockAutologinFailed:l}=t;s===a&&c===n&&l===i||a&&n&&i&&o()}componentDidMount(){const{activateDelayAutologinExp:e,isAuthenticated:t,crossDomain:o,fb:a,smartlock:n,mwebFacebookDisabled:s}=this.props;if(!t&&(i.a("fba")?Object(w.j)("mweb_previously_logged_out.true"):Object(w.j)("mweb_previously_logged_out.false"),o&&this.attemptCrossDomainAutologin(),n&&this.attemptSmartlockAutologin(),a&&!s)){const{group:t}=e();if(t.startsWith("enabled_facebook")||t.startsWith("enabled_both")){let e=0;try{const o=t.split("_");e=parseInt(o[2],10)||0}catch(c){Object(w.j)("mweb_unauth_delay_autologin_error."+t)}this.attemptFBAutologin(e)}else this.attemptFBAutologin(0)}}attemptCrossDomainAutologin(){if("undefined"!=typeof window&&window.PINTEREST_DISABLE_CCTLD_AUTO)return void Object(w.j)("dev.autologin_disabled.cctld");const{logPrefix:e}=this.props,t=()=>y("attempt","cctld",e),o=()=>y("success","cctld",e),a=()=>y("fail","cctld",e);try{Object(h.a)({onAttempt:t}).then(O.a).then(o).then(()=>{"undefined"!=typeof window&&window.location&&window.location.reload()}).catch(e=>{e&&a()})}catch(n){a()}}attemptSmartlockAutologin(){if("undefined"!=typeof window&&window.PINTEREST_DISABLE_SMARTLOCK_AUTO)return void Object(w.j)("dev.autologin_disabled.smartlock");const{smartLockUseAlternativeResourceCall:e,history:t,location:o,login:a,logPrefix:n}=this.props;Object(h.d)({onAttempt:()=>y("attempt","smartlock",n),onNoBrowserCredentials:()=>y("error_no_api","smartlock",n)}).then(i=>{i?(Object(g.e)({event_type:7534,view_type:10,view_parameter:3204,aux_data:{signup_login_method:5}}),a({username_or_email:i.id,password:i.password},t,o.pathname,{isAutologin:!0,useAlternativeResourceCall:e}).then(()=>{y("success","smartlock",n),Object(g.e)({event_type:7536,view_type:10,view_parameter:3204,aux_data:{signup_login_method:5}})}).catch(()=>{y("fail","smartlock",n),Object(g.e)({event_type:7535,view_type:10,view_parameter:3204,aux_data:{signup_login_method:5}}),this.setState({smartlockAutologinFailed:!0})})):(this.setState({smartlockAutologinFailed:!0}),y("error_no_creds","smartlock",n))}).catch(e=>{this.setState({smartlockAutologinFailed:!0}),y(e?e.status:"error_other","smartlock",n)})}handleFBAutologinResponse(e){const{logPrefix:t}=this.props;y(e,"facebook",t)}handleFBAutologinError(e){let t;e?e.status?t=e.status:e instanceof Error?(t="error_no_status",Object(b.b)({message:e.message||e.description,line:e.lineno||e.lineNumber||e.line,column:e.colno||e.columnNumber||e.column,stack:e.stack||e.stacktrace||e.error&&(e.error.stack||e.error.stacktrace),filename:e.fileName||e.sourceUrl,name:"unexpected mweb facebook autologin response error"})):"string"==typeof e?(t="error_string",Object(b.b)({message:e,name:"unexpected mweb facebook autologin response string"})):t="error_other":t="error_empty",this.handleFBAutologinResponse(t)}attemptFBAutologin(e){if("undefined"!=typeof window&&window.PINTEREST_DISABLE_FB_AUTO)return Object(w.j)("dev.autologin_disabled.facebook"),void Object(_.a)("facebook_autologin","autologin_disabled");const{history:t,locale:o,location:a,login:n,logPrefix:i,showToast:s}=this.props;y("attempt","facebook",i),Object(_.b)("facebook_autologin","autoLoginFacebookStart"),Object(h.b)(e,o,e=>Object(w.j)(e)).then(e=>{Object(_.b)("facebook_autologin","autoLoginFacebookEnd"),this.setState({showFbAutoLoginModal:!0,fbEmail:e.data&&e.data.email,fbName:e.data&&e.data.first_name}),Object(g.e)({event_type:7534,view_type:10,view_parameter:3205,aux_data:{signup_login_method:2}}),Object(_.d)("facebook_autologin"),n(e.creds,t,a.pathname,{isAutologin:!0}).then(()=>{this.setState({showFbAutoLoginModal:!1}),Object(g.e)({event_type:7536,view_type:10,view_parameter:3205,aux_data:{signup_login_method:2}}),s({text:e.data&&e.data.first_name?Object(d.b)(this.props.i18n._("Welcome back to Pinterest, {{ name }}!","welcoming user back to pinterest when autologin with first name","welcoming user back to pinterest when autologin with first name"),{name:e.data.first_name}).join(""):this.props.i18n._("Welcome back to Pinterest!","welcoming user back to pinterest when autologin","welcoming user back to pinterest when autologin"),duration:4e3}),this.handleFBAutologinResponse("success")}).catch(e=>{this.setState({showFbAutoLoginModal:!1,facebookAutologinFailed:!0}),Object(g.e)({event_type:7535,view_type:10,view_parameter:3205,aux_data:{signup_login_method:2}});let t="fail";e&&e.apiErrorCode===u.m&&(t="incomplete_signup"),this.handleFBAutologinResponse(t)})}).catch(e=>{Object(_.a)("facebook_autologin","autoLoginFacebookFailed"),this.handleFBAutologinError(e),this.setState({facebookAutologinFailed:!0})})}render(){const{i18n:e}=this.props,{fbEmail:t,fbName:o,showFbAutoLoginModal:a}=this.state;return Object(A.jsx)(c.a,{isOpen:a,type:"autologin",children:Object(A.jsxs)(f.f,{margin:-3,children:[Object(A.jsx)(s.a,{duration:1500,finalProgress:95}),Object(A.jsxs)(f.f,{alignItems:"center",direction:"column",display:"flex",paddingX:t?10:12,paddingY:6,children:[Object(A.jsx)(f.w,{icon:"pinterest",color:"red",accessibilityLabel:e._("Pinterest logo"),size:24}),Object(A.jsx)(f.f,{marginTop:1,paddingY:1,children:Object(A.jsx)(f.cb,{align:"center",children:Object(A.jsx)(f.v,{size:"md",children:o?Object(d.b)(this.props.i18n._("Welcome back, {{ name }}!","welcome back with first name","welcome back with first name"),{name:o}).join(""):this.props.i18n._("Welcome back!","Welcome back!","Welcome back!")})})}),Object(A.jsx)(f.cb,{align:"center",children:t?Object(d.b)(this.props.i18n._("We're logging you in with your Facebook account, {{ email }}","logging in user with facebook account and email associated","logging in user with facebook account and email associated"),{email:Object(A.jsx)(f.cb,{inline:!0,weight:"bold",children:t},"fbEmail")}):this.props.i18n._("We're logging you in with your Facebook account...","logging in user with Facebook account","logging in user with Facebook account")})]})]})})}}t.default=Object(k.compose)(r.a,Object(n.connect)((e,t)=>({isAuthenticated:e.session.isAuthenticated,locale:e.session.locale}),e=>({login:(t,o,a,n)=>e(Object(O.b)(t,o,a,n)),crossDomainAutoLogin:()=>e(Object(O.a)()),trackAutologinFailure:()=>e(Object(m.R)())})))((function(e){const t=Object(p.c)(),o=Object(l.a)(),{anyEnabled:a}=Object(j.b)("mweb_facebook_disabled"),n=Object(j.a)("desktop"===o?"web_unauth_delay_autologin":"mweb_unauth_delay_autologin");return Object(A.jsx)(v,{...e,activateDelayAutologinExp:n,smartLockUseAlternativeResourceCall:"desktop"===o,mwebFacebookDisabled:a,i18n:t})}))},rvfI:function(e,t,o){o.d(t,"d",(function(){return c})),o.d(t,"b",(function(){return l})),o.d(t,"c",(function(){return r})),o.d(t,"a",(function(){return u}));var a=o("bKKl"),n=o("2hay"),i=o("4NbJ"),s=o("A+Hl");const c=(e={},t)=>{const o=window.navigator.credentials,n={password:!0};return t&&(n.mediation=t),Object(a.a)()?Promise.reject({status:"autologin_disabled"}):new Promise((t,a)=>{o?(e&&e.onAttempt&&e.onAttempt(),o.get(n).then(t).catch(a)):e&&e.onNoBrowserCredentials&&e.onNoBrowserCredentials()})},l=(e,t,o)=>{if(Object(a.a)())return Promise.reject({status:"autologin_disabled"});o("unauth_mweb.facebook_connect.autologin.attempt");return Object(n.f)(t).then(n.d).then(t=>{return e>0?(a=e,new Promise(e=>setTimeout(e,a))).then(()=>Object(n.e)(t,{autologin:!0},e=>o("unauth_mweb.facebook_connect.autologin."+e))):Object(n.e)(t,{autologin:!0},e=>o("unauth_mweb.facebook_connect.autologin."+e));var a})},r=(e,t)=>{if(Object(a.a)())return Promise.reject({status:"autologin_disabled"});t("create_google_autologin_button.number_6");const o=document.createElement("div");return o&&o.style&&(o.style.left="-99999px",o.style.opacity="0",o.style.position="fixed",o.style.top="-999999px"),o.id="google-autologin-button",document.getElementsByTagName("body")[0].appendChild(o),Object(i.d)(o.id,e,t,!0)},u=(e={})=>Object(s.c)(window.location.origin)?Object(a.a)()?Promise.reject({status:"autologin_disabled"}):(e&&e.onAttempt&&e.onAttempt(),Object(s.d)()):Promise.reject({status:"non_valid_origin"})}}]);
//# sourceMappingURL=https://sm.pinimg.com/webapp/609-43f0ccc330c773b89e8a.mjs.map