1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._posthogChunkIds=e._posthogChunkIds||{},e._posthogChunkIds[n]="01a05ed0-f2fa-7370-a50a-b5125f2f12cc")}catch(e){}}();;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="ee779b45-105f-2cc8-68e5-9aab0f316da0")}catch(e){}}(); 2(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,304055,e=>{"use strict";var t=e.i(604362),r=e.i(127460);let n=(0,r.createContext)({variant:"control",setVariant:()=>{}});function i({variant:e,children:i}){let[o,a]=(0,r.useState)(e);(0,r.useEffect)(()=>{a(e)},[e]);let s=(0,r.useCallback)(e=>{a(t=>t===e?t:e)},[]),l=(0,r.useMemo)(()=>({variant:o,setVariant:s}),[o,s]);return(0,t.jsx)(n.Provider,{value:l,children:i})}function o(){return(0,r.useContext)(n).variant}function a({variant:e}){let{variant:t,setVariant:i}=(0,r.useContext)(n);return t!==e&&i(e),null}e.s(["UnifiedAuthExperimentProvider",()=>i,"UnifiedAuthExperimentSync",()=>a,"useUnifiedAuthExperimentVariant",()=>o])},928149,662280,e=>{"use strict";e.i(850381);var t=e.i(486118);function r(e){if("string"!=typeof e||!e.trim())return;let t=new Date(e);return Number.isNaN(t.getTime())?void 0:t}function n(e){let t=e.headers.get("retry-after")?.trim();if(!t)return;let r=Number(t);if(Number.isFinite(r)&&r>=0)return new Date(Date.now()+1e3*r);let n=new Date(t);return Number.isNaN(n.getTime())?void 0:n}var i=e.i(5154);async function o({email:e,continueUrl:o}){var a,s,l,c,u,d;let m,g=(0,i.resolveMagicLinkContinueUrlForApi)(o);try{m=await (0,t.setHeadersAndFetch)("https://web-api-cdn.ground.news/api/v7/auth/magic-link",{method:"POST",contentType:"application/json",body:JSON.stringify({email:e.trim(),continueUrl:g})})}catch{return{outcome:"unavailable"}}if(m.status>=500)return{outcome:"unavailable"};let f=await m.text(),h={},p=!1;try{h=JSON.parse(f),p=!0}catch{}return(a=m.status,s=h,429===a||s.error?.code==="RATE_LIMIT_EXCEEDED")?{outcome:"rate_limited",retryAfter:(l=m,c=h,function({detailsRetryAfter:e,headerRetryAfter:t,detailsRetryAfterS:r}){return e??t??r}({detailsRetryAfter:r(c.error?.details?.retryAfter),headerRetryAfter:n(l),detailsRetryAfterS:function(e,t=Date.now()){if("number"==typeof e&&Number.isFinite(e)&&!(e<0))return new Date(t+1e3*e)}(c.error?.details?.retryAfterS)})),message:h.error?.message?.trim()||"You've requested too many sign-in links. Please wait a moment before trying again."}:m.ok?{outcome:"success",retryAfter:(u=m,d=h,function(...e){let t=e.map(e=>e?.getTime()).filter(e=>void 0!==e);if(0!==t.length)return new Date(Math.max(...t))}(n(u),r(d.data?.retryAfter),r(d.retryAfter)))}:p?{outcome:"error",message:h.error?.message?.trim()||"Failed to send sign-in link. Please try again."}:403===m.status&&(0,i.isLocalMagicLinkContinueUrl)(g)?{outcome:"error",message:"Could not send magic link. Check NEXT_PUBLIC_MAGIC_LINK_CONTINUE_URL points to a public HTTPS URL."}:{outcome:"error",message:"Something went wrong. Please try again."}}class a extends Error{retryAfter;constructor(e,t){super(e),this.name="MagicLinkRateLimitError",this.retryAfter=t}}async function s(e){let t=await o(e);if("success"===t.outcome)return{retryAfter:t.retryAfter};if("rate_limited"===t.outcome)throw new a(t.message,t.retryAfter);if("unavailable"===t.outcome)throw Error("We're having trouble sending your sign-in link. Please try again in a moment.");throw Error(t.message)}e.s(["MagicLinkRateLimitError",()=>a,"sendPasswordlessMagicLink",()=>s],928149);var l=e.i(127460);function c(e){return e.trim().toLowerCase()}function u(){let[e,t]=(0,l.useState)(!1),[r,n]=(0,l.useState)(0),[i,o]=(0,l.useState)(null),[a,s]=(0,l.useState)(0);(0,l.useEffect)(()=>{if(!i)return;let e=i.nextSendAllowedAt,t=()=>Date.now()>=e?(o(null),!1):(s(e=>e+1),!0);t();let r=window.setInterval(()=>{t()||window.clearInterval(r)},1e3);return()=>window.clearInterval(r)},[i]);let u=r>=5,d=(0,l.useCallback)(()=>{t(!1),n(0),o(null)},[]),m=(0,l.useCallback)(()=>{t(!1),n(0)},[]),g=(0,l.useCallback)(e=>i&&e.trim()&&c(i.email)===c(e)?Math.max(0,Math.ceil((i.nextSendAllowedAt-Date.now())/1e3)):0,[i,a]),f=(0,l.useCallback)(t=>{let r=g(t);return r>0?`Please wait ${r}s before requesting another link.`:e&&u?"Too many sign-in emails sent. Use the back button to start over or try again later.":null},[g,e,u]),h=(0,l.useCallback)((e,t)=>{let r=c(e);if(!r)return;let n=t?.getTime(),i=Date.now()+3e4,a=n&&n>Date.now()?n:i;o(e=>e&&c(e.email)===r?{email:r,nextSendAllowedAt:Math.max(e.nextSendAllowedAt,a)}:{email:r,nextSendAllowedAt:a})},[]);return{magicLinkSentStepActive:e,magicLinkResendLimitReached:u,resetResendLimits:d,resetSendCount:m,getCooldownSecondsLeft:g,getResendBlockError:f,recordSuccessfulSend:(0,l.useCallback)((e,r)=>
2{n(e=>e+1),h(e,r),t(!0)},[h]),recordRateLimited:(0,l.useCallback)((e,r)=>{h(e,r),t(!0)},[h])}}e.s(["useMagicLinkResendLimits",()=>u],662280)},566603,474365,e=>{"use strict";var t=e.i(559501);function r(e){return String(e??"").toLowerCase().replace(/_/g,"")}function n(e){return"signin"===r(e.get("mode"))&&!!e.get("oobCode")?.trim()}function i(e){return null!==function(e){try{let t=new URL(e);if(n(t.searchParams))return t.searchParams;let r=t.searchParams.get("link");if(!r?.trim())return null;let i=new URL(decodeURIComponent(r.replace(/\+/g," ")));return n(i.searchParams)?i.searchParams:null}catch{return null}}(e)}let o=["link","mode","oobCode","continueUrl","apiKey"];function a(e){try{let t=new URL(e);for(let e of o)t.searchParams.delete(e);let r=t.searchParams.toString();return`${t.pathname}${r?`?${r}`:""}${t.hash}`}catch{return e}}e.s(["FIREBASE_MAGIC_LINK_SEARCH_KEYS",0,o,"isFirebaseSignInActionHref",()=>i,"normalizeFirebaseActionMode",()=>r,"stripFirebaseMagicLinkSearchFromHref",()=>a],474365);let s="gnd_pwls_email",l="emailForSignIn",c="gnd_pwls_pending",u=["emailIdentifier","utm_medium","variant","lang"];function d(e){try{return localStorage.getItem(e)?.trim()||void 0}catch{return}}function m(e,t){try{return localStorage.setItem(e,t),!0}catch{return!1}}function g(e){try{localStorage.removeItem(e)}catch{}}function f(){let e=d(c);if(!e)return[];try{let t=JSON.parse(e);if(!Array.isArray(t))return[];let r=Date.now()-864e5;return t.filter(e=>"string"==typeof e.email&&"string"==typeof e.landingPath&&"number"==typeof e.sentAt&&e.sentAt>=r)}catch{return[]}}function h(e){m(c,JSON.stringify(e.slice(0,5)))}function p(e){let t=function(e){try{let t=new URL(e),r=t.searchParams.get("continueUrl")?.trim();if(r)try{let e=new URL(decodeURIComponent(r));return`${e.pathname}${e.search}`}catch{}for(let e of o)t.searchParams.delete(e);for(let e of u)t.searchParams.delete(e);return`${t.pathname}${t.search}`}catch{return e}}(e),r=f().find(e=>e.landingPath===t);return r?.email.trim()||void 0}function k(){let e=(function(e){if("u"<typeof document)return;let t=`${e}=`;for(let e of document.cookie.split(";")){let r=e.trim();if(r.startsWith(t)){let e=r.slice(t.length);try{return decodeURIComponent(e)}catch{return e}}}})(t.PASSWORDLESS_EMAIL_LINK_COOKIE)?.trim();if(e)return e;let r=d(s);return r||d(l)}async function w(e,r){let n,i,o=e.trim(),a=m(s,o);m(l,o),r?.trim()&&(n=function(e){try{let t=new URL(e);return`${t.pathname}${t.search}`}catch{return e.trim()}}(r),h([{email:i=o.trim(),landingPath:n,sentAt:Date.now()},...f().filter(e=>e.email!==i||e.landingPath!==n)]));let c=await fetch("/api/set-cookie",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t.PASSWORDLESS_EMAIL_LINK_COOKIE,value:o,options:{path:"/",maxAge:3600,sameSite:"lax"}})});if(!c.ok&&(!a||k()!==o))throw Error((await c.json().catch(()=>({}))).error||"Failed to set passwordless email cookie")}async function y(){let e,r=k();g(s),g(l),r&&(e=r.trim().toLowerCase(),h(f().filter(t=>t.email.trim().toLowerCase()!==e))),await fetch("/api/set-cookie",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t.PASSWORDLESS_EMAIL_LINK_COOKIE,value:"",options:{path:"/",maxAge:0}})}).catch(()=>{})}e.s(["clearPasswordlessEmailLinkCookie",()=>y,"getPasswordlessEmailLinkFromCookie",()=>k,"readPendingMagicLinkEmailForHref",()=>p,"setPasswordlessEmailLinkCookie",()=>w],566603)},501297,e=>{"use strict";var t=e.i(604362),r=e.i(153845),n=e.i(127460),i=e.i(928149),o=e.i(662280),a=e.i(566603);let s=(0,n.createContext)(null);function l({children:e}
2){let l=(0,r.usePathname)(),[c,u]=(0,n.useState)(!1),[d,m]=(0,n.useState)(null),g=null!==d,[f,h]=(0,n.useState)(""),[p,k]=(0,n.useState)("idle"),[w,y]=(0,n.useState)(""),[v,A]=(0,n.useState)(!1),{magicLinkSentStepActive:L,magicLinkResendLimitReached:S,resetResendLimits:C,resetSendCount:P,getCooldownSecondsLeft:E,getResendBlockError:b,recordSuccessfulSend:T,recordRateLimited:I}=(0,o.useMagicLinkResendLimits)(),F=E(f),_="sent"===p||"busy"===p&&(L||v),R=(0,n.useCallback)(e=>{u(e)},[]),M=(0,n.useCallback)(e=>{h(e),y("")},[]),O=(0,n.useCallback)(async(e,t)=>{let r=("string"==typeof e?e:f).trim();if(!r){y("Enter an email address."),k("error");return}r!==f.trim()&&h(r);let n=b(r);if(n){y(n),k("error");return}t?.treatAsResendUi&&A(!0);let o=`${window.location.origin}${window.location.pathname}${window.location.search}`;k("busy"),y("");try{await (0,a.setPasswordlessEmailLinkCookie)(r,o);let{retryAfter:e}=await (0,i.sendPasswordlessMagicLink)({email:r,continueUrl:o});T(r,e),A(!1),k("sent")}catch(e){if(A(!1),e instanceof i.MagicLinkRateLimitError){I(r,e.retryAfter),y(e.message),k("sent");return}await (0,a.clearPasswordlessEmailLinkCookie)(),y(e instanceof Error?e.message:"Failed to send link."),k("error")}},[f,l,b,T,I]),x=(0,n.useCallback)(()=>{m(null),y(""),P()},[P]),N=(0,n.useCallback)(()=>{k("idle"),y(""),m(null),A(!1),P()},[P]),U=(0,n.useCallback)(()=>{k("idle"),y(""),A(!1),C()},[C]),D=(0,n.useMemo)(()=>({isVerifyingMagicLink:c,setVerifyingMagicLink:R,magicLinkOobFailure:d,setMagicLinkOobFailure:m,isMagicLinkExpired:g,email:f,setEmail:M,status:p,error:w,sendMagicLink:O,reset:N,prepareFreshMagicLink:x,clearMagicLinkSendGuards:U,magicLinkSentStepActive:L,isMagicLinkSentStep:_,magicLinkResendCooldownSecondsLeft:F,magicLinkResendLimitReached:S}),[c,R,d,g,f,M,p,w,O,N,x,U,L,_,F,S]);return(0,t.jsx)(s.Provider,{value:D,children:e})}function c(){let e=(0,n.useContext)(s);if(!e)throw Error("usePasswordlessMagicLink must be used within PasswordlessMagicLinkProvider");return e}e.s(["PasswordlessMagicLinkProvider",()=>l,"usePasswordlessMagicLink",()=>c])},539943,e=>{"use strict";var t=e.i(474365);let r=["magicLinkToken","signInToken"];function n(e){if((0,t.isFirebaseSignInActionHref)(e))return!0;try{let t=new URL(e);return r.some(e=>!!t.searchParams.get(e)?.trim())}catch{return!1}}e.s(["isMagicLinkReturnHref",()=>n])},960313,e=>{"use strict";let t="ground.pendingProviderLink";function r(e){try{sessionStorage.setItem(t,JSON.stringify(e))}catch{}}function n(){try{let e=sessionStorage.getItem(t);if(!e)return null;let r=JSON.parse(e);if("string"==typeof r.email&&"string"==typeof r.pendingLinkToken&&Array.isArray(r.existingMethods)&&r.pendingCredential&&"object"==typeof r.pendingCredential)return r;return null}catch{return null}}function i(){try{sessionStorage.removeItem(t)}catch{}}e.s(["clearPersistedProviderMismatch",()=>i,"getPersistedProviderMismatch",()=>n,"persistProviderMismatch",()=>r])},798349,477963,697347,882510,e=>{"use strict";e.s(["AWAITING_V7_NEEDS_LINK",0,"awaiting-v7-needs-link"],798349),e.i(850381);var t=e.i(486118),r=e.i(820237),n=e.i(322875);async function i({pendingLinkToken:e,pendingCredential:i,existingCredential:o,email:a,utmCodes:s,experimentData:l}){let c={...(0,r.buildV7AuthRequestBody)({utmCodes:s,experimentData:l}),pendingLinkToken:e,pendingCredential:i,existingCredential:o},u=await (0,t.setHeadersAndFetch)("https://web-api-cdn.ground.news/api/v7/auth/login-and-link",{method:"POST",contentType:"application/json",body:JSON.stringify(c)}),d={};try{let e=await u.json();d=(0,n.normalizeV7LoginEnvelope)(e)}catch{return{outcome:"error",message:"Something went wrong. Please try again."}}return(0,n.parseV7AuthLoginResponse)(d,u.status,{fallbackEmail:a,authFailedMessage:"Could not verify your existing sign-in method. Please try again."})}async function o({credential:e,email:i,utmCodes:o,experimentData:a}){let s={...(0,r.buildV7AuthRequestBody)({utmCodes:o,experimentData:a}),credential:e},l=await (0,t.setHeadersAndFetch)("https://web-api-cdn.ground.news/api/v7/auth/login",{method:"POST",contentType:"application/json",body:JSON.stringify(s)}),c={};try{let e=await l.json();c=(0,n.normalizeV7LoginEnvelope)(e)}catch{return{outcome:"error",message:"Something went wrong. Please try again."}}return(0,n.parseV7AuthLoginResponse)(c,l.status,{fallbackEmail:i,fallbackPendingCredential:e})}e.s(["postV7LoginAndLink",()=>i],477963),e.s(["postV7SocialLogin",()=>o],697347),e.i(2933);var a=e.i(951099);e.i(117469);var s=e.i(5154);function l(e,t){switch(e){case"google":return{method:"oauth",provider:"google.com",credential:{...t.idToken?{idToken:t.idToken}:{},...t.accessToken?{accessToken:t.accessToken}:{}}};case"facebook":{let e=t.accessToken?.trim();if(!e)throw Error("Facebook access token is required.");return{method:"oauth",provider:"facebook.com",credential:{accessToken:e}}}case"apple":{let e=t.idToken?.trim();if(!e)throw Error("Apple ID token is required.");return{method:"oauth",provider:"apple.com",credential:{idToken:e,...t.rawNonce?{rawNonce:t.rawNonce}:{}}}}}}function c(e){return l("google",{accessToken:e})}function u(e,t){return{method:"password",email:e.trim(),password:t}}function d(e,t){return{method:"email_link",email:e.trim(),emailLink:(0,s.resolveMagicLinkEmailLinkForApi)(t)}}function m(e,t){switch(e){case"google":{let e=a.GoogleAuthProvider.credentialFromResult(t);if(!e||!e.idToken&&!e.accessToken)return;return l("google",{accessToken:e.accessToken??void 0,idToken:e.idToken??void 0})}case"facebook":{let e=a.FacebookAuthProvider.credentialFromResult(t);if(!e?.accessToken)return;return l("facebook",{accessToken:e.accessToken})}case"apple":{let e=a.OAuthProvider.credentialFromResult(t);
2if(!e?.idToken)return;return l("apple",{idToken:e.idToken})}}}function g(e){return e.customData?.email?.trim()||void 0}function f(e,t){let r=function(e,t){try{switch(e){case"google":return a.GoogleAuthProvider.credentialFromError(t);case"facebook":return a.FacebookAuthProvider.credentialFromError(t);case"apple":return a.OAuthProvider.credentialFromError(t)}}catch{return null}}(e,t);if(r)return h(e,r)}function h(e,t){switch(e){case"google":if(!t.idToken&&!t.accessToken)return;return l("google",{accessToken:t.accessToken??void 0,idToken:t.idToken??void 0});case"facebook":if(!t.accessToken)return;return l("facebook",{accessToken:t.accessToken});case"apple":if(!t.idToken)return;return l("apple",{idToken:t.idToken})}}e.s(["emailFromFirebaseAuthError",()=>g,"v7CredentialFromAuthCredential",()=>h,"v7CredentialFromAuthError",()=>f,"v7CredentialFromEmailLink",()=>d,"v7CredentialFromGoogleAccessToken",()=>c,"v7CredentialFromPassword",()=>u,"v7CredentialFromUserCredential",()=>m],882510)},353570,e=>{"use strict";e.i(2933);var t=e.i(951099),r=e.i(798349),n=e.i(477963),i=e.i(697347),o=e.i(882510),a=e.i(546475),s=e.i(960313);function l(){return window.google?.accounts}async function c(e){let t=await fetch("https://www.googleapis.com/oauth2/v3/userinfo",{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error("Could not read your Google account email.");let r=await t.json(),n=r.email?.trim();if(!n)throw Error("Could not read your Google account email.");return n}async function u(e){await (l()?.oauth2?Promise.resolve():new Promise((e,t)=>{let r=document.querySelector('script[src="https://accounts.google.com/gsi/client"]');if(r){r.addEventListener("load",()=>e(),{once:!0}),r.addEventListener("error",()=>t(Error("Failed to load Google sign-in.")),{once:!0});return}let n=document.createElement("script");n.src="https://accounts.google.com/gsi/client",n.async=!0,n.onload=()=>e(),n.onerror=()=>t(Error("Failed to load Google sign-in.")),document.body.appendChild(n)}));let r="1076208031945-6bk2mvo7qbmhsihk6nos4bkhkscfqt9s.apps.googleusercontent.com".trim();if(!r)throw Error("Google sign-in is not configured.");let n=l()?.oauth2;if(!n)throw Error("Google sign-in is not available.");return new Promise((i,o)=>{let a=!1;n.initTokenClient({client_id:r,scope:"openid email profile",error_callback:e=>{a||(a=!0,o(Error(e?.message||`Google sign-in unavailable (${e?.type??"unknown"}).`)))},callback:e=>{if(a)return;if(a=!0,e.error)return"popup_closed_by_user"===e.error?void o(Object.assign(Error("popup closed"),{code:"auth/popup-closed-by-user"})):void o(Error(e.error_description||e.error));let r=e.access_token?.trim();r?c(r).then(e=>{i({email:e,credential:t.GoogleAuthProvider.credential(null,r)})}).catch(o):o(Error("Google sign-in did not return an access token."))}}).requestAccessToken({prompt:e?.prompt??""})})}async function d(e){try{let t=await u(e);return{outcome:"success",...t}}catch(e){if("auth/popup-closed-by-user"===e?.code)return{outcome:"cancelled"};return{outcome:"unavailable"}}}e.i(850381),e.i(18550);var m=e.i(117469),g=e.i(157964);async function f(){let e=await (0,a.getOrInitializeAuth)("ensureSignedOutForCredentialCollection");"function"==typeof e.authStateReady&&await e.authStateReady(),e.currentUser&&await (0,t.signOut)(e)}async function h(e){let r=await (0,a.getOrInitializeAuth)("fetchDisplayableSignInMethods");"function"==typeof r.authStateReady&&await r.authStateReady();let n=await (0,t.fetchSignInMethodsForEmail)(r,e.trim());return(0,m.filterDisplayableSignInMethods)(n)}function p(e,t){let r=(0,m.socialProviderToSignInMethod)(t),n=e.filter(e=>e!==r);return(0,m.sortSignInMethods)(n.length>0?n:e)}function k(e,r,n,i,o){let a={email:i.trim(),existingMethods:o.length>0?o:[t.ProviderId.PASSWORD,"emailLink"],attemptedProvider:e,pendingLinkToken:r,pendingCredential:n};return(0,s.persistProviderMismatch)(a),a}async function w(e,t,n){let i=e?.trim();if(!i)return null;try{let e=await h(i);if(0===e.length||e.includes((0,m.socialProviderToSignInMethod)(t))||(0,m.isPasswordOnlySignInAccount)(e))return null;return{outcome:"provider_mismatch",state:k(t,r.AWAITING_V7_NEEDS_LINK,n,i,p(e,t))}}catch(e){return(0,g.logToSentry)(e,"[unified-social-login] precheckProviderMismatch",500,"text/plain"),null}}async function y(e,t,r){if("success"===e.outcome)return(0,s.clearPersistedProviderMismatch)(),await (0,a.applyV7AuthSe
2ssion)(r,e.session,e.user),{outcome:"success",session:e.session,user:e.user,newlyRegistered:!0===e.newlyRegistered||!0===e.user.newlyRegistered};if("provider_mismatch"===e.outcome){let{mismatch:r}=e;return{outcome:"provider_mismatch",state:k(t,r.pendingLinkToken,r.pendingCredential,r.email,p(r.existingMethods,t))}}return e.outcome,{outcome:"error",error:Error(e.message)}}async function v(e,t,n,o,a){if(e!==r.AWAITING_V7_NEEDS_LINK)return{outcome:"resolved",pendingLinkToken:e,pendingCredential:t};let s=await (0,i.postV7SocialLogin)({credential:t,email:n.trim(),utmCodes:a.utmCodes,experimentData:a.experimentData});return"provider_mismatch"===s.outcome?{outcome:"resolved",pendingLinkToken:s.mismatch.pendingLinkToken,pendingCredential:t}:"success"===s.outcome?y(s,o,a.isAppRouter):((0,g.logToSentry)(Error(`resolvePendingLinkToken ${s.outcome}: ${s.message}`),`[unified-social-login] could not resolve pending link token (${t.method})`,500,"text/plain"),{outcome:"error",error:Error(s.message)})}async function A(e){await f();try{let r=await (0,a.getOrInitializeAuth)(`collectSocialCredential:${e}`),n=function(e){switch(e){case"google":return new t.GoogleAuthProvider;case"facebook":return new t.FacebookAuthProvider;case"apple":return new t.OAuthProvider("apple.com")}}(e),i=await (0,t.signInWithPopup)(r,n),s=(0,o.v7CredentialFromUserCredential)(e,i),l=i.user.email;if(await (0,t.signOut)(r),!s)return{outcome:"error",error:Error("Could not read provider credentials.")};return{outcome:"success",v7Credential:s,email:l}}catch(t){if("auth/popup-closed-by-user"===t.code||"auth/user-cancelled"===t.code)return{outcome:"cancelled"};if("auth/account-exists-with-different-credential"===t.code){let r=(0,o.v7CredentialFromAuthError)(e,t);if(r)return{outcome:"success",v7Credential:r,email:(0,o.emailFromFirebaseAuthError)(t)??null};(0,g.logToSentry)(t,`[unified-social-login] account-exists-with-different-credential missing pending credential ${e}`,500,"application/json")}return{outcome:"error",error:t}}}async function L(e,t,r,n){let{isAppRouter:o=!1,utmCodes:a,experimentData:s}=n,l=await w(r,e,t);return l||y(await (0,i.postV7SocialLogin)({credential:t,email:r??void 0,utmCodes:a,experimentData:s}),e,o)}async function S(e){let{isAppRouter:t=!1,utmCodes:r,experimentData:n}=e;await f();let i=await d();if("cancelled"===i.outcome)return{outcome:"cancelled"};if("success"===i.outcome){let{email:e,credential:a}=i,s=a.accessToken,l=s?(0,o.v7CredentialFromGoogleAccessToken)(s):(0,o.v7CredentialFromAuthCredential)("google",a);return l?L("google",l,e,{isAppRouter:t,utmCodes:r,experimentData:n}):{outcome:"error",error:Error("Could not read Google credentials.")}}return C("google",e)}async function C(e,t){let r=await A(e);return"cancelled"===r.outcome?{outcome:"cancelled"}:"error"===r.outcome?((0,g.logToSentry)(r.error,`[unified-social-login] collect credential ${e}`,500,"application/json"),r):L(e,r.v7Credential,r.email,t)}async function P(e,t={}){return"google"===e?S(t):C(e,t)}async function E(e,r,n){if(e===t.ProviderId.PASSWORD)return n?.trim()?{outcome:"success",existingCredential:(0,o.v7CredentialFromPassword)(r,n)}:{outcome:"error",error:Error("Password is required.")};if("emailLink"===e)return{outcome:"error",error:Error("Use the email link flow to continue.")};let i=e===t.ProviderId.GOOGLE?"google":e===t.ProviderId.FACEBOOK?"facebook":"apple",a=r.trim().toLowerCase();if("google"===i){let e=await d({prompt:"select_account"});if("cancelled"===e.outcome)return{outcome:"cancelled"};if("success"===e.outcome){let{credential:t,email:n}=e;if(n.trim().toLowerCase()!==a)return{outcome:"error",error:Error(`Please sign in with the Google account for ${r.trim()}.`)};let i=t.accessToken,s=i?(0,o.v7CredentialFromGoogleAccessToken)(i):(0,o.v7CredentialFromAuthCredential)("google",t);if(s)return{outcome:"success",existingCredential:s}}}let s=await A(i);return"success"===s.outcome?s.email&&s.email.trim().toLowerCase()!==a?{outcome:"error",error:Error(`Please sign in with the ${(0,m.getSocialAuthProviderDisplayName)(i)} account for ${r.trim()}.`)}:{outcome:"success",existingCredential:s.v7Credential}:s}async function b(e,t){let{email:r,password:i,pendingLinkToken:o,pendingCredential:a,isAppRouter:s=!1,utmCodes:l,experimentData:c}=t,u=await E(e,r,i);if("cancelled"===u.outcome)return{outcome:"cancelled"};if("error"===u.outcome)return u;
2let d=await v(o,a,r,t.attemptedProvider,{isAppRouter:s,utmCodes:l,experimentData:c});if("resolved"!==d.outcome)return d;let m=await (0,n.postV7LoginAndLink)({pendingLinkToken:d.pendingLinkToken,pendingCredential:d.pendingCredential,existingCredential:u.existingCredential,email:r.trim(),utmCodes:l,experimentData:c});return"success"!==m.outcome&&"provider_mismatch"!==m.outcome&&(0,g.logToSentry)(Error(`postV7LoginAndLink ${m.outcome}: ${m.message}`),`[unified-social-login] link failed for ${t.attemptedProvider} via ${e}`,500,"text/plain"),y(m,t.attemptedProvider,s)}async function T(e,t,r={}){let{isAppRouter:i=!1,utmCodes:a,experimentData:s}=r;try{let r=await v(e.pendingLinkToken,e.pendingCredential,e.email,e.attemptedProvider,{isAppRouter:i,utmCodes:a,experimentData:s});if("resolved"!==r.outcome)return r;let l=await (0,n.postV7LoginAndLink)({pendingLinkToken:r.pendingLinkToken,pendingCredential:r.pendingCredential,existingCredential:(0,o.v7CredentialFromEmailLink)(e.email,t),email:e.email,utmCodes:a,experimentData:s});return y(l,e.attemptedProvider,i)}catch(e){return(0,g.logToSentry)(e,"[unified-social-login] completePendingProviderLinkViaEmailLink",500,"application/json"),{outcome:"error",error:e}}}e.s(["attemptUnifiedSocialLogin",()=>P,"completePendingProviderLinkViaEmailLink",()=>T,"signInWithExistingMethodAndLink",()=>b],353570)}]); 3 4//# debugId=ee779b45-105f-2cc8-68e5-9aab0f316da0 5//# sourceMappingURL=ac16ba34f23373bc.js.map 6//# chunkId=01a05ed0-f2fa-7370-a50a-b5125f2f12cc
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.