1import{aQ as a,bI as e,bo as o,a$ as i,bT as n,bU as s,bK as t,d as r,r as l,e as d,b$ as c,s as u,l as p,b9 as g,dz as m,f as w,x as f,v as h,c3 as v,c4 as y,c5 as b,c9 as P,bZ as k,dG as S,dH as I,c6 as A,bm as T,br as x,b1 as U,bx as _,aV as E,aS as F,bn as C,bO as L,bp as V,by as B,a_ as q,dY as z,dZ as D,E as j,j as R,aR as G,u as N,aT as O,aU as M}from"./index-B0wWhsKS.js";import{g as Y}from"./signup-o6NcK4o6.js";import{P as K}from"./PInput-B4D7YZGq.js";import{A as X,u as Z}from"./AccountLinkingModal-DniMDJCD.js";import{_ as $}from"./logo-stacked-DMI_3xJo.js";import"./phone-BfEgewkX.js";const H=a({name:"SignInForm",components:{IonContent:i,IonButton:o,Icon:e,PInput:K,AccountLinkingModal:X},setup(){const a=n(),e=s(),o=t(),i=l({email:"",password:""}),T=l(!1),x=l(!1),U=l(!1),_=l(""),E=l(!1),{beginAccountLinking:F,cancelAccountLinking:C}=Z();r(C);const L=()=>{U.value=!0},V=d(()=>!!i.value.email&&!!i.value.password&&!_.value),B=async a=>{const e=await m.create({message:a,spinner:"circles"});return await e.present(),e},q=async a=>{const e=await w.create({header:"Error",message:a,buttons:["OK"]});await e.present()},z=async(a,e)=>{var i,n,s,t;const r=g.currentRoute.value.query.redirect;let l=r||"/home";if(!r)if(null==e?void 0:e.fosterProfile)u.set("fosterProfile",e.fosterProfile),l="pending"===(null==(i=e.fosterProfile)?void 0:i.status)&&(null==(n=e.fosterProfile)?void 0:n.onboarding_completed)?"/pending-application":"/foster/home";else if(f(null==e?void 0:e.role))l="/foster/home";else if(h(null==e?void 0:e.role)){const a=null==(s=null==e?void 0:e.staffProfile)?void 0:s.organization;l=a&&!a.verified?"/pending-verification":!o&&v(e)?y(e):!o&&b(e)?A:"/home"}else if((null==e?void 0:e.roles)&&Array.isArray(e.roles))if(e.roles.some(f))l="/foster/home";else if(e.roles.some(h)){const a=null==(t=null==e?void 0:e.staffProfile)?void 0:t.organization;l=a&&!a.verified?"/pending-verification":!o&&v(e)?y(e):!o&&b(e)?A:"/home"}try{await g.replace(l)}catch(d){p.error("â Navigation failed:",d),await g.push(l)}},D=async e=>{var i;const n=Boolean(e.intent||(null==(i=e.invites)?void 0:i.length));if(o&&!n)return await P(),void(await q(a?"No completed account was found. If signup was interrupted, finish account setup on the Pawsitive Foster website, then sign in here.":"No completed account was found for this sign-in."));await u.set("signupRecoveryState",e),await k(!1),await g.replace("/resume-signup")},j=async a=>{await u.set("firebaseUser",a);const e=await Y();if("complete"!==e.state||!e.user)return void(await D(e));const o=e.user;await u.set("currentUser",o),await z(a.uid,o)},R=async(a,e,o)=>{if(E.value)return;E.value=!0;const i=await B("Preparing ".concat(a," Sign In..."));try{await i.dismiss();const a=await o(),e=await B("Completing sign in...");try{await j(a)}finally{await e.dismiss()}}catch(n){if((a=>"auth/popup-closed-by-user"===(null==a?void 0:a.code)||"auth/cancelled-popup-request"===(null==a?void 0:a.code))(n))return;if("auth/account-exists-with-different-credential"===(null==n?void 0:n.code))try{if(await F(n,e))return}catch(s){p.error("Unable to start ".concat(a," account linking:"),s)}p.error("An error occurred during ".concat(a," sign-in:"),n),await q(((a,e)=>"auth/account-exists-with-different-credential"===(null==e?void 0:e.code)?"You already have an account with this email. Try signing in with your email and password instead.":"auth/popup-blocked"===(null==e?void 0:e.code)||(null==e?void 0:e.message)&&e.message.includes("popup")&&e.message.includes("blocked")?"Popup was blocked. Please allow popups for this site and try again.":"auth/network-request-failed"===(null==e?void 0:e.code)?"".concat(a," sign-in failed. Please try again."):(null==e?void 0:e.message)||"".concat(a," sign-in failed. Please try again."))(a,n))}finally{E.value=!1}};return{formData:i,showPassword:T,emailTouched:x,passwordTouched:U,emailError:_,isAuthenticating:E,isFormValid:V,handleSubmit:async()=>{if(!V.value)return;E.value=!0;const a=await B("Signing in...");let e=!1;const o=async()=>{if(!e){e=!0;try{await a.dismiss()}catch(o){p.warn("Failed to dismiss sign-in loading overlay:",o)}}};try{const a=(await c(i.value.email,i.value.password)).user;await u.set("firebaseUser",a);const e=await(async(a,e,o)=>{let i=null;const n=new Promise((a,n)=>{i=setTimeout(()=>n(new Error(o)),e)});try{return await Promise.race([a,n])}finally{i&&clearTimeout(i)}})(Y(),12e3,"Signed in, but account details took too long to load. Please try again.");if("complete"!==e.state||!e.user)return void(await D(e));const o=e.user;await u.set("currentUser",o),await z(a.uid,o)}catch(n){p.error("An error occurred during sign-in:",n),await o(),await q((a=>"auth/invalid-credential"===(null==a?void 0:a.code)||"auth/wrong-password"===(null==a?void 0:a.code)||"auth/user-not-found"===(null==a?void 0:a.code)?"Invalid email or password.":"auth/too-many-requests"===(null==a?void 0:a.code)?"Too many sign-in attempts. Please wait a moment and try again.":"auth/network-request-failed"===(null==a?void 0:a.code)?"Unable to reach the sign-in service. Please check your connection and try again.":(null==a?void 0:a.message)||"Failed to sign in. Please check your credentials and try again.")(n))}finally{await o(),E.value=!1}},togglePassword:()=>{T.value=!T.value},markEmailTouched:()=>{x.value=!0},markPasswordTouched:L,handlePasswordBlur:()=>{L()},handleGoogleSignIn:async()=>{await R("Google","google.com",()=>S())}
1,handleAppleSignIn:async()=>{await R("Apple","apple.com",I)},handleAccountLinked:async a=>{if(E.value)return;E.value=!0;const e=await B("Completing sign in...");try{await j(a)}catch(o){p.error("Account linked, but sign-in could not be completed:",o),await q((null==o?void 0:o.message)||"Your accounts were linked, but we could not finish signing you in. Please try again.")}finally{await e.dismiss(),E.value=!1}},goToForgotPassword:()=>{g.push("/forgot-password")},goToSignUp:()=>{g.push(o?"/signin":"/signup/organization")},isIosAppPlatform:a,isNativeApp:e,isSignupDisabledPlatform:o}}}),Q={class:"content-wrapper"},W={class:"signin-wrapper"},J={class:"content-container"},aa={class:"form-group"},ea={class:"form-group"},oa={class:"forgot-password-container"},ia={class:"bottom-section"},na={key:1,class:"signup-prompt Body-XSmall-Small-Regular ion-text-center"};const sa=T(H,[["render",function(a,e,o,i,n,s){const t=x("PInput"),r=x("ion-button"),l=x("Icon"),d=x("ion-content"),c=x("AccountLinkingModal");return U(),_(B,null,[E(d,{"force-overscroll":!1,class:"ion-padding signin-content"},{default:F(()=>[C("div",Q,[C("div",W,[C("div",J,[e[12]||(e[12]=C("div",{class:"logo-container"},[C("img",{src:$,alt:"Pawsitive Foster Logo",class:"pawsitive-logo"})],-1)),e[13]||(e[13]=C("div",{class:"header-section"},[C("h4",{class:"text-h4 signup-heading",style:{font:"var(--text-h4)","font-weight":"var(--font-weight-medium)"}},"ð Welcome back, foster hero!"),C("div",{class:"text-secondary","Body-XSmall-Small-Regular":""},"Enter your details to continue your amazing work.")],-1)),C("form",{onSubmit:e[5]||(e[5]=L((...e)=>a.handleSubmit&&a.handleSubmit(...e),["prevent"]))},[C("div",aa,[E(t,{id:"emailInput",label:"Email",type:"email",modelValue:a.formData.email,"onUpdate:modelValue":e[0]||(e[0]=e=>a.formData.email=e),required:!0,placeholder:"Enter your email",touched:a.emailTouched,errorText:a.emailError,onBlur:a.markEmailTouched,onValidation:e[1]||(e[1]=e=>{a.emailError=e?"":"Invalid email format"}),autocomplete:"email"},null,8,["modelValue","touched","errorText","onBlur"])]),C("div",ea,[E(t,{id:"passwordInput",label:"Current Password",type:"password",modelValue:a.formData.password,"onUpdate:modelValue":e[2]||(e[2]=e=>a.formData.password=e),required:!0,placeholder:"Password",touched:a.passwordTouched,showPassword:a.showPassword,onBlur:a.markPasswordTouched,"onUpdate:showPassword":e[3]||(e[3]=e=>{a.showPassword=e}),autocomplete:"current-password"},null,8,["modelValue","touched","showPassword","onBlur"])]),C("div",oa,[C("a",{onClick:e[4]||(e[4]=(...e)=>a.goToForgotPassword&&a.goToForgotPassword(...e)),class:"text-link"}," Forgot Password? ")]),E(r,{type:"submit",expand:"block",shape:"round",class:"button-primary signin-cta",disabled:!a.isFormValid||a.isAuthenticating},{default:F(()=>[...e[7]||(e[7]=[V(" Sign In ",-1)])]),_:1},8,["disabled"])],32),C("div",ia,[a.isNativeApp?q("",!0):(U(),_(B,{key:0},[e[10]||(e[10]=C("div",{class:"or-divider"},[C("div",{class:"divider-line"}),C("div",{class:"or-text"},"OR"),C("div",{class:"divider-line"})],-1)),E(r,{expand:"block",shape:"round",class:"social-button",onClick:a.handleGoogleSignIn,disabled:a.isAuthenticating},{default:F(()=>[E(l,{name:"google",color:"black",size:"md",slot:"start"}),e[8]||(e[8]=V(" Sign In with Google ",-1))]),_:1},8,["onClick","disabled"]),E(r,{expand:"block",shape:"round",class:"social-button",onClick:a.handleAppleSignIn,disabled:a.isAuthenticating},{default:F(()=>[E(l,{name:"apple",color:"black",size:"md",slot:"start"}),e[9]||(e[9]=V(" Sign In with Apple ",-1))]),_:1},8,["onClick","disabled"])],64)),a.isSignupDisabledPlatform?q("",!0):(U(),_("div",na,[e[11]||(e[11]=V(" Don't have an account? ",-1)),C("a",{onClick:e[6]||(e[6]=(...e)=>a.goToSignUp&&a.goToSignUp(...e)),class:"text-link"}," Organization Sign Up ")]))])])])])]),_:1}),E(c,{onLinked:a.handleAccountLinked},null,8,["onLinked"])],64)}],["__scopeId","data-v-5746c56d"]]),ta=a({__name:"SignInPage",setup(a){const e=M();return z(D),j(async()=>{var a,o;const i=await u.get("currentUser");if(i){const n=e.currentRoute.value.query.redirect;let s=n||"/home";n||(R(i)?s="pending"===(null==(a=i.fosterProfile)?void 0:a.status)&&(null==(o=i.fosterProfile)?void 0:o.onboarding_completed)?"/pending-application":"/foster/home":h(i.role)&&(s="/home")),e.replace(s)}}),(a,e)=>(U(),G(N(O),null,{default:F(()=>[E(sa)]),_:1}))}});
1export{ta as default};
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.