1import{b as P,u as U,d as A,e as m,s as c,j as e,B as p,C as F,h as q}from"./index-BoPK12rZ.js";import{I as f}from"./input-B7jnFymG.js";import{L as v}from"./label-CCd9oABz.js";import{T as _,a as B,b as N,c as S}from"./tabs-DWQ6x32b.js";import{M as R}from"./MedicalDisclaimer-DDoRLo7i.js";import{A as D}from"./arrow-right-Blw5VId1.js";import{A as z}from"./arrow-left-Bm3n84ZD.js";import{U as G}from"./user-BOOKI8Fb.js";import"./index-Bu4KJFpo.js";import"./index-DR_KIw6N.js";import"./circle-alert-ChnZ4M4N.js";const Z=()=>{const{language:h,setLanguage:w,t:s}=P(),o=U(),{toast:i}=A(),[d,j]=m.useState(""),[g,y]=m.useState(""),[u,l]=m.useState(!1),[C,E]=m.useState(!0);m.useEffect(()=>{new URLSearchParams(window.location.search).get("reason")==="timeout"&&i({title:s("×¤× ×ª××§×£ ×סש×","Session Expired"),description:s("×××¢×× ×××××, × ××ª×§×ª× ×××××××ת. ×ת×××¨× ×©××.","For security reasons, you were logged out. Please sign in again."),variant:"destructive"})},[]),m.useEffect(()=>{const{data:{subscription:a}}=c.auth.onAuthStateChange(async(n,t)=>{n==="INITIAL_SESSION"?t!=null&&t.user?await r(t.user.id):E(!1):n==="SIGNED_IN"&&(t!=null&&t.user)&&await r(t.user.id)}),r=async n=>{const{data:t}=await c.from("profiles").select("role_type").eq("id",n).maybeSingle(),{data:b}=await c.from("patients").select("id").eq("user_id",n).maybeSingle(),x=t==null?void 0:t.role_type;x==="healthcare_provider"?o("/physician",{replace:!0}):x==="caregiver"?o("/caregiver",{replace:!0}):b?o("/dashboard",{replace:!0}):!x||x==="patient"?o(b?"/dashboard":"/role-selection",{replace:!0}):o("/role-selection",{replace:!0})};return()=>{a.unsubscribe()}},[o]);const I=async a=>{a.preventDefault(),l(!0);try{const{error:r}=await c.auth.signUp({email:d,password:g,options:{emailRedirectTo:window.location.origin}});if(r)throw r;i({title:s("× ×¨×©××ª× ××צ×××!","Signed up successfully!"),description:s("×××§× ×ת ××××××× ×××ש×ר (×× ××ש××× ×× ×× × ×רש ××ש×ר)","Check your email for confirmation (or continue if not required)")})}catch(r){i({title:s("ש××××","Error"),description:r.message,variant:"destructive"})}finally{l(!1)}},k=async a=>{a.preventDefault(),l(!0);try{const{error:r}=await c.auth.signInWithPassword({email:d,password:g});if(r)throw r}catch(r){i({title:s("ש××××","Error"),description:r.message,variant:"destructive"})}finally{l(!1)}},L=async()=>{if(!d){i({title:s("ש××××","Error"),description:s("×××× × ×××××× ×§×××","Please enter your email first"),variant:"destructive"});return}l(!0);try{const r=window.location.hostname==="localhost"||window.location.hostname.includes("lovable.app")?"https://smadar.ai":window.location.origin,{error:n}=await c.auth.resetPasswordForEmail(d,{redirectTo:`${r}/reset-password`});if(n)throw n;i({title:s("× ×©××!","Sent!"),description:s("×××§× ×ת ××××××× ×××פ×ס ×ס×ס××","Check your email for password reset link")})}catch(a){i({title:s("ש××××","Error"),description:a.message,variant:"destructive"})}finally{l(!1)}},T=async()=>{l(!0);try{const{error:a}=await c.auth.signInAnonymously();if(a)throw a}catch{i({title:s("ש××××","Error"),description:s("×× × ××ª× ×××ש×× ×××ר×/ת. × ×¡× ×××רש×.","Cannot continue as guest. Please sign up."),variant:"destructive"})}finally{l(!1)}};return C?e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx("div",{className:"animate-pulse text-muted-foreground",children:s("×××¢×...","Loading...")})}):e.jsxs("div",{className:"min-h-screen bg-background flex flex-col relative overflow-hidden",dir:h==="he"?"rtl":"ltr",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute -top-32 -right-32 w-72 h-72 bg-gradient-to-br from-primary/20 to-transparent rounded-full blur-3xl"}),e.jsx("div",{className:"absolute -bottom-32 -left-32 w-72 h-72 bg-gradient-to-tr from-accent/30 to-transparent rounded-full blur-3xl"})]}),e.jsxs("div",{className:"relative z-10 flex justify-between items-center p-4",children:[e.jsxs(p,{variant:"ghost",size:"sm",onClick:()=>o("/"),className:"gap-2",children:[h==="he"?e.jsx(D,{className:"h-4 w-4"}):e.jsx(z,{className:"h-4 w-4"}),s("××ר×","Back")]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex rounded-full bg-muted p-1",children:[e.jsx("button",{onClick:()=>w("he"),className:`px-3 py-1.5 text-sm rounded-full transition-all ${h==="he"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"×¢×ר×ת"}),e.jsx("button",{onClick:()=>w("en"),className:`px-3 py-1.5 text-sm rounded-full transition-all ${h==="en"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"EN"})]})})]}),e.jsx("main",{className:"flex-1 flex flex-col items-center justify-center px-4 pb-8 relative z-10",children:e.jsxs("div",{className:"max-w-sm w-full space-y-6",children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsxs("div",{className:"mx-auto w-20 h-20 relative",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-brand opacity-20 blur-xl rounded-full"}),e.jsx("img",{src:"/smadar-logo.jpg",alt:s("ס××ר â ×¢××רת ×××××××ת ××××× ×¡×¨××","Smadar â digital assistant for cancer patients"),className:"w-full h-full object-contain drop-shadow-lg rounded-xl relative"})]}),e.jsx("h1",{className:"text-xl font-semibold text-foreground",children:s("×ת××ר×ת ×ס××ר","Sign In to Smadar")})]}),e.jsx(F,{className:"border-border/50 shadow-lg",children:e.jsxs(q,{className:"pt-6",children:[e.jsxs(_,{defaultValue:"signin",className:"w-full",children:[e.jsxs(B,{className:"grid w-full grid-cols-2 mb-4",children:[e.jsx(N,{value:"signin",className:"rounded-xl",children:s("×ת××ר×ת","Sign In")}),e.jsx(N,{value:"signup",className:"rounded-xl",children:s("×רש××","Sign Up")})]}),e.jsx(S,{value:"signin",className:"space-y-4 pt-4",children:e.jsxs("form",{onSubmit:k,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{htmlFor:"signin-email",children:s("××××××","Email")}),e.jsx(f,{id:"signin-email",type:"email",value:d,onChange:a=>j(a.target.value),placeholder:"[email protected]",required:!0,dir:"ltr"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{htmlFor:"signin-password",children:s("ס×ס××","Password")}),e.jsx(f,{id:"signin-password",type:"password",value:g,onChange:a=>y(a.target.value),placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",required:!0,dir:"ltr"})]}),e.jsx(p,{type:"submit",className:"w-full bg-gradient-brand",disabled:u,children:u?s("×ת××ר××...","Signing in..."):s("×ת××ר×","Sign In")}),e.jsx(p,{type:"button",variant:"link",className:"w-full text-sm text-muted-foreground",onClick:L,disabled:u,children:s("ש×××ª× ×¡×ס××","Forgot password?")})]})}),e.jsx(S,{value:"signup",className:"space-y-4 pt-4",children:e.jsxs("form",{onSubmit:I,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{htmlFor:"signup-email",children:s("××××××","Email")}),e.jsx(f,{id:"signup-email",type:"email",value:d,onChange:a=>j(a.target.value),placeholder:"[email protected]",required:!0,dir:"ltr"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{htmlFor:"signup-password",children:s("ס×ס××","Password")}),e.jsx(f,{id:"signup-password",type:"password",value:g,onChange:a=>y(a.target.value),placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",minLength:6,required:!0,dir:"ltr"})]}),e.jsx(p,{type:"submit",className:"w-full bg-gradient-brand",disabled:u,children:u?s("× ×¨×©×××...","Signing up..."):s("××רש××","Sign Up")})]})})]}),e.jsxs("div",{className:"relative my-6",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-card px-2 text-muted-foreground",children:s("××","or")})})]}),e.jsxs(p,{variant:"outline",className:"w-full gap-2",onClick:T,disabled:u,children:[e.jsx(G,{className:"h-4 w-4"}
1),s("××ש××× ×××ר×/ת","Continue as Guest")]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center mt-2",children:s("ש××× ××: ×××ר×/ת ×× ×ª×××× ××שת ×ת××§ ×××ש×ר ××ר","Note: As a guest, you won't be able to access your file from another device")})]})})]})}),e.jsx("footer",{className:"py-6 px-6",children:e.jsx(R,{className:"justify-center"})})]})};export{Z 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.