import{j as e}from"./query-vendor-CZu0EHPe.js";import{r,u as U,f as O,L as n}from"./react-vendor-0bvDbF03.js";import{b as z,u as B,S as K,K as V,B as o,U as ae}from"./index-Ddmt5XbY.js";import{I as k}from"./input-Du6wEETt.js";import{C as J}from"./checkbox-BIaiAF9T.js";import{G as Y,F as _,X as H,M as Q}from"./SocialIcons-DWGIwkB0.js";import{u as Z}from"./i18n-vendor-Cl4-lKeC.js";import{M as $}from"./mail-DuInVrft.js";import{E as ee}from"./eye-off-TfM2DW6B.js";import{E as se}from"./eye-CNI5NUjd.js";import"./supabase-vendor-CNV44oIa.js";import"./helmet-vendor-NlTFkN97.js";import"./index-mXG3wuIW.js";const fe=()=>{const{t:s}=Z("auth"),{getLocalizedPath:l}=z(),[x,T]=r.useState(""),[i,G]=r.useState(""),[g,E]=r.useState(!1),[h,I]=r.useState(!1),[p,L]=r.useState(!1),[w,b]=r.useState(!1),[v,y]=r.useState(!1),c=U(),d=O(),m=window.location.pathname.includes("reset-password"),{signIn:F,signInWithGoogle:u,signInWithFacebook:f,signInWithTwitter:X,signInWithMicrosoft:W,user:C,isLoading:M}=B();r.useEffect(()=>{if(C){const a=d.state?.redirectTo;a?c(a):sessionStorage.getItem("storyMakerDraft")?c("/story-maker"):c("/stories")}},[C,c,d.state]);const[A,S]=r.useState(null);r.useEffect(()=>{S(null)},[x,i]);const P=async a=>{a.preventDefault();try{await F(x,i)}catch(t){console.error("Login error:",t),S("invalid_credentials")}},j=()=>{const a=d.state?.redirectTo;a&&sessionStorage.setItem("pendingAuthRedirect",a)},N=async()=>{try{I(!0),j(),await u()}catch(a){console.error("Google sign in error:",a)}finally{I(!1)}},R=async()=>{try{L(!0),j(),await f()}catch(a){console.error("Facebook sign in error:",a)}finally{L(!1)}},q=async()=>{try{b(!0),j(),await X()}catch(a){console.error("X sign in error:",a)}finally{b(!1)}},D=async()=>{try{y(!0),j(),await W()}catch(a){console.error("Microsoft sign in error:",a)}finally{y(!1)}};return e.jsxs("div",{className:"min-h-screen flex items-center justify-center px-4 py-12 bg-gradient-to-r from-nature-yellow/20 to-nature-coral/70",children:[e.jsx(K,{title:s(m?"meta.resetPassword.title":"meta.login.title"),description:s(m?"meta.resetPassword.description":"meta.login.description"),keywords:m?void 0:s("meta.login.keywords"),canonical:m?window.location.pathname:"/login",noIndex:!0}),e.jsx("div",{className:"bg-white rounded-2xl shadow-xl overflow-hidden max-w-md w-full border border-border",children:e.jsxs("div",{className:"p-6 sm:p-8",children:[e.jsx("div",{className:"flex justify-center mb-8",children:e.jsxs(n,{to:"/",className:"flex items-center gap-2",children:[e.jsx("img",{src:"/lovable-uploads/50fd1cc2-8d37-4dad-b091-61fd6bc2cc9e.png",alt:"StorySparkle Logo",className:"h-8 w-8"}),e.jsxs("span",{className:"font-bold text-xl",children:[e.jsx("span",{className:"text-nature-red",children:"Story"}),e.jsx("span",{className:"text-nature-coral",children:"Sparkle"})]})]})}),e.jsx("h1",{className:"text-2xl font-bold mb-6 text-center",children:s("login.title")}),A&&e.jsxs("div",{className:"mb-4 rounded-lg border border-destructive/30 bg-destructive/5 p-4 text-sm",children:[e.jsx("p",{className:"font-medium text-destructive mb-2",children:s("login.errorTitle")}),e.jsxs("ul",{className:"space-y-1.5 text-muted-foreground",children:[e.jsx("li",{children:e.jsx(n,{to:l("/reset-password"),className:"text-nature-red hover:underline",children:s("login.forgotPassword")})}),e.jsx("li",{children:s("login.checkVerification")}),e.jsx("li",{children:e.jsx(n,{to:l("/signup"),className:"text-nature-red hover:underline",children:s("login.noAccountYet")})})]})]}),e.jsxs("form",{onSubmit:P,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"email",className:"text-sm font-medium",children:s("login.email")}),e.jsxs("div",{className:"relative",children:[e.jsx($,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(k,{id:"email",type:"email",placeholder:"you@example.com",className:"pl-10",value:x,onChange:a=>T(a.target.value),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("label",{htmlFor:"password",className:"text-sm font-medium",children:s("login.password")}),e.jsx(n,{to:"/reset-password",className:"text-xs text-sparkle-purple hover:underline",children:s("login.forgotPassword")})]}),e.jsxs("div",{className:"relative",children:[e.jsx(V,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(k,{id:"password",type:g?"text":"password",placeholder:"•••••••",className:"pl-10 pr-10",value:i,onChange:a=>G(a.target.value),required:!0}),e.jsx("button",{type:"button",tabIndex:-1,onClick:()=>E(!g),className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-muted-foreground hover:text-foreground",children:g?e.jsx(ee,{className:"h-4 w-4"}):e.jsx(se,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(J,{id:"remember"}),e.jsx("label",{htmlFor:"remember",className:"text-sm text-muted-foreground",children:s("login.rememberMe")})]}),e.jsx(o,{type:"submit",className:"w-full bg-nature-red hover:bg-nature-coral",disabled:M,children:M?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),s("login.signingIn")]}):s("login.signIn")})]}),e.jsxs("div",{className:"mt-6",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-border"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-white px-2 text-muted-foreground",children:s("login.orContinueWith")})})]}),e.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-3",children:[e.jsxs(o,{variant:"outline",className:"w-full",onClick:N,disabled:h,children:[e.jsx(Y,{className:"mr-2 h-6 w-6",alt:"Sign in with Google"}),h?"...":"Google"]}),e.jsxs(o,{variant:"outline",className:"w-full",onClick:R,disabled:p,children:[e.jsx(_,{className:"mr-2 h-6 w-6",alt:"Sign in with Facebook"}),p?"...":"Facebook"]}),e.jsxs(o,{variant:"outline",className:"w-full",onClick:q,disabled:w,children:[e.jsx(H,{className:"mr-2 h-6 w-6",alt:"Sign in with X"}),w?"...":"X"]}),e.jsxs(o,{variant:"outline",className:"w-full",onClick:D,disabled:v,children:[e.jsx(Q,{className:"mr-2 h-6 w-6",alt:"Sign in with Microsoft"}),v?"...":"Microsoft"]})]})]}),e.jsxs("p",{className:"mt-6 text-center text-sm text-muted-foreground",children:[s("login.noAccount")," ",e.jsx(n,{to:l("/signup"),state:d.state,className:"text-nature-red font-medium hover:underline",children:s("login.signUpLink")})]})]})})]})},je=()=>{const{t:s}=Z("auth"),{getLocalizedPath:l}=z(),[x,T]=r.useState(""),[i,G]=r.useState(""),[g,E]=r.useState(""),[h,I]=r.useState(!1),[p,L]=r.useState(!1),[w,b]=r.useState(!1),[v,y]=r.useState(!1),[c,d]=r.useState(!1),[m,F]=r.useState(!1),u=U(),f=O(),{signUp:X,signInWithGoogle:W,signInWithFacebook:C,signInWithTwitter:M,signInWithMicrosoft:A,user:S,isLoading:P}=B();r.useEffect(()=>{if(S){const t=f.state?.redirectTo;t?u(t):sessionStorage.getItem("storyMakerDraft")?u("/story-maker"):u("/stories")}},[S,u,f.state]);const j=async t=>{if(t.preventDefault(),!!p)try{await X(i,g,"reader",x),u(l("/verify-email"),{state:{email:i},replace:!0})}catch(te){console.error("Sign up error:",te)}},N=()=>{const t=f.state?.redirectTo;t&&sessionStorage.setItem("pendingAuthRedirect",t)},R=async()=>{try{b(!0),N(),await W()}catch(t){console.error("Google sign in error:",t)}finally{b(!1)}},q=async()=>{try{y(!0),N(),await C()}catch(t){console.error("Facebook sign in error:",t)}finally{y(!1)}},D=async()=>{try{d(!0),N(),await M()}catch(t){console.error("X sign in error:",t)}finally{d(!1)}},a=async()=>{try{F(!0),N(),await A()}catch(t){console.error("Microsoft sign in error:",t)}finally{F(!1)}};return e.jsxs("div",{className:"min-h-screen flex items-center justify-center px-4 py-12 bg-gradient-to-r from-nature-yellow/20 to-nature-coral/70",children:[e.jsx(K,{title:s("meta.signup.title"),description:s("meta.signup.description"),keywords:s("meta.signup.keywords",{defaultValue:""})||void 0,canonical:"/signup"}),e.jsx("div",{className:"bg-white rounded-2xl shadow-xl overflow-hidden max-w-md w-full border border-border",children:e.jsxs("div",{className:"p-6 sm:p-8",children:[e.jsx("div",{className:"flex justify-center mb-8",children:e.jsxs(n,{to:"/",className:"flex items-center gap-2",children:[e.jsx("img",{src:"/lovable-uploads/50fd1cc2-8d37-4dad-b091-61fd6bc2cc9e.png",alt:"StorySparkle Logo",className:"h-8 w-8"}),e.jsxs("span",{className:"font-bold text-xl",children:[e.jsx("span",{className:"text-nature-red",children:"Story"}),e.jsx("span",{className:"text-nature-coral",children:"Sparkle"})]})]})}),e.jsx("h1",{className:"text-2xl font-bold mb-2 text-center",children:s("signup.title")}),e.jsx("p",{className:"text-muted-foreground text-center text-sm mb-6",children:s("signup.subtitle")}),e.jsxs("form",{onSubmit:j,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"name",className:"text-sm font-medium",children:s("signup.readerName")}),e.jsxs("div",{className:"relative",children:[e.jsx(ae,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(k,{id:"name",placeholder:"John Doe",className:"pl-10",value:x,onChange:t=>T(t.target.value),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"signup-email",className:"text-sm font-medium",children:s("signup.email")}),e.jsxs("div",{className:"relative",children:[e.jsx($,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(k,{id:"signup-email",type:"email",placeholder:"you@example.com",className:"pl-10",value:i,onChange:t=>G(t.target.value),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"signup-password",className:"text-sm font-medium",children:s("signup.password")}),e.jsxs("div",{className:"relative",children:[e.jsx(V,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(k,{id:"signup-password",type:h?"text":"password",placeholder:"Create a strong password",className:"pl-10 pr-10",value:g,onChange:t=>E(t.target.value),required:!0}),e.jsx("button",{type:"button",tabIndex:-1,onClick:()=>I(!h),className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-muted-foreground hover:text-foreground",children:h?e.jsx(ee,{className:"h-4 w-4"}):e.jsx(se,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("signup.passwordRequirements")})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(J,{id:"terms",className:"mt-1",checked:p,onCheckedChange:t=>L(t===!0),required:!0}),e.jsxs("label",{htmlFor:"terms",className:"text-sm text-muted-foreground",children:[s("signup.agreeToTerms")," ",e.jsx(n,{to:l("/terms"),className:"text-sparkle-purple hover:underline",children:s("signup.termsOfService")})," ",s("signup.and")," ",e.jsx(n,{to:l("/privacy"),className:"text-sparkle-purple hover:underline",children:s("signup.privacyPolicy")})]})]}),e.jsx(o,{type:"submit",className:"w-full",disabled:P||!p,children:P?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),s("signup.creatingAccount")]}):s("signup.createAccount")})]}),e.jsxs("div",{className:"mt-6",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-border"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-white px-2 text-muted-foreground",children:s("signup.orContinueWith")})})]}),e.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-3",children:[e.jsxs(o,{variant:"outline",className:"w-full",onClick:R,disabled:w,children:[e.jsx(Y,{className:"mr-2 h-6 w-6",alt:"Sign up with Google"}),w?"...":"Google"]}),e.jsxs(o,{variant:"outline",className:"w-full",onClick:q,disabled:v,children:[e.jsx(_,{className:"mr-2 h-6 w-6",alt:"Sign up with Facebook"}),v?"...":"Facebook"]}),e.jsxs(o,{variant:"outline",className:"w-full",onClick:D,disabled:c,children:[e.jsx(H,{className:"mr-2 h-6 w-6",alt:"Sign up with X"}),c?"...":"X"]}),e.jsxs(o,{variant:"outline",className:"w-full",onClick:a,disabled:m,children:[e.jsx(Q,{className:"mr-2 h-6 w-6",alt:"Sign up with Microsoft"}),m?"...":"Microsoft"]})]})]}),e.jsxs("p",{className:"mt-6 text-center text-sm text-muted-foreground",children:[s("signup.haveAccount")," ",e.jsx(n,{to:l("/login"),state:f.state,className:"text-nature-red font-medium hover:underline",children:s("signup.signInLink")})]})]})})]})};export{fe as LoginPage,je as SignupPage};
//# sourceMappingURL=AuthPages-DauqFLxY.js.map