1import{u as k,f as w,e as y,r as l,j as h,B as A,J as b}from"./MarketingSiteLoadingFallback-DF4Bevx8.js";import{a as _,t as s,a8 as S,Z as m,a9 as M,aa as x,ab as v,ac as T,ad as P,ae as C,af as B,p as d,ag as L}from"./renderJungleWebApp-Bj6DEPtG.js";import{w as R}from"./index-Dcp8arUn.js";import{c as j,L as O}from"./LoginPage-DgAm91OQ.js";import{C as W}from"./center-BP01O02C.js";import"./frontend-release-DHVEZwfg.js";import"./hub-CmyV34zS.js";import"./index-rQLcFmgX.js";import"./track-error-fzCnz4fY.js";import"./legacy-referrer-id-B23nat6c.js";import"./landingHandoffUploadClaim-ZWzmhSYt.js";import"./client-environment-BMTHOZAb.js";import"./main-CR0pPclt.js";import"./stripe-price-details-Q-KLtuJy.js";import"./document-upload-sentry-CwY_2GoS.js";import"./jungle_river-fkLKo0Re.js";import"./sentry-init-DYpmux4V.js";import"./DefaultLayoutWrapper-CcSXgP3F.js";import"./container-Cn3zB5hy.js";import"./firebase-authentication-errors-C9FLB0Wu.js";function te(){const{tokenSession:i}=k(),[u]=w(),p=u.get("redirect"),f=y(),r=_(t=>t.currentUser),c="jungleai";l.useEffect(()=>{if(i==="outlook"){g();return}const t=u.get("verify")==="1",e=i?i.length:0;s("Auth by token attempted",{is_partner_signin:t,has_token:!!i,token_length:e,legacy_event_name:"Auth by token"}),s("Auth by token",{}),S(m,i||"").then(()=>{s("Auth by token succeeded",{is_partner_signin:t})}).catch(o=>{const a=(o==null?void 0:o.code)!==void 0&&typeof o.code=="string"?o.code:null,n=(o==null?void 0:o.message)!==void 0&&typeof o.message=="string"?o.message:null;s("Auth by token failed",{is_partner_signin:t,error_code:a,error_message:n?n.slice(0,240):null}),console.error("[AuthByToken] signInWithCustomToken failed",a,n)})},[]),l.useEffect(()=>{if(r){if(i==="outlook"){(async()=>{try{const e=await L(),o=await fetch(`${b}/users/get_firebase_custom_token`,{method:"POST",body:JSON.stringify({user_id:r.id}),headers:{"Content-Type":"application/json",...e}});if(!o.ok)throw new Error(`Outlook custom-token exchange failed with status ${o.status}`);const a=await o.text();window.location.href=`${c}://login-with-outlook-success?token=${a}`}catch(e){console.error("[AuthByToken] Outlook custom-token exchange failed",e),s("Error: Outlook custom-token exchange failed",{errorMessage:e instanceof Error?e.message:String(e)}),window.location.href=`${c}://login-with-outlook-error`}})();return}u.get("verify")==="1"&&M(m.currentUser),p||(window.location.href="/"),p==="upgrade"?window.location.href="https://jungleai.com/upgrade":f(`/${p}`)}},[r==null?void 0:r.id]);const g=async()=>{s("Auth by outlook",{}),await x(m,v);const t=new T("microsoft.com");t.addScope("email"),t.addScope("profile"),t.setCustomParameters({prompt:"select_account"});try{await P(m,t,C).then(async e=>{var n;const o=e==null?void 0:e.user;await B(o==null?void 0:o.uid)&&s("Login Successful",{signInMethod:"Microsoft",name:(n=e==null?void 0:e._tokenResponse)==null?void 0:n.displayName,platform:d.getState().isRunningAsMobileApp?"Mobile App":"Web"})}).catch(async e=>{var a;if(await j((a=e==null?void 0:e.customData)==null?void 0:a.email,O.Microsoft)){window.location.href=`${c}://login-with-outlook-error`;return}s("Error: Failed to Sign In",{userAgent:navigator.userAgent,signInMethod:"Microsoft",platform:d.getState().isRunningAsMobileApp?"Mobile App":"Web",errorMessage:e}),window.location.href=`${c}://login-with-outlook-error`})}catch(e){console.error("Firebase Authentication Error: ",e)}};return h.jsx(A,{maxW:"md",alignContent:"center",alignItems:"center",margin:"0 auto",children:h.jsx(W,{mt:"25%",children:h.jsx(R,{color:"#15803D"})})})}export{te as default}; 2//# sourceMappingURL=AuthByToken-BPu-RzGl.js.map
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.