1import{j as e}from"./vendor-markdown-BcWX1uEp.js";import{r}from"./vendor-react-CvxdUEaJ.js";import{u as F,X as M}from"./index-BWurHp8h.js";const I=({isOpen:m,onClose:o,initialView:j="login"})=>{const[s,x]=r.useState(j),[i,g]=r.useState(""),[a,h]=r.useState(""),[b,f]=r.useState(""),[c,n]=r.useState(!1),[p,l]=r.useState(""),[y,d]=r.useState(""),v=r.useId(),{login:w,signup:N,resetPassword:S,loginWithGoogle:C}=F();if(r.useEffect(()=>{m&&window.dispatchEvent(new Event("tm-auth-request"))},[m]),!m)return null;const k=async t=>{t.preventDefault(),l(""),d(""),n(!0);try{if(s==="signup"){if(a!==b)throw new Error("Passwords do not match");if(a.length<6)throw new Error("Password must be at least 6 characters");await N(i,a),d("Account created successfully!"),setTimeout(()=>o(),1500)}else s==="login"?(await w(i,a),o()):s==="reset"&&(await S(i),d("Password reset email sent! Check your inbox."),x("login"))}catch(A){l(A.message)}finally{n(!1)}},E=()=>{g(""),h(""),f(""),l(""),d("")},u=t=>{E(),x(t)},P=async()=>{l(""),n(!0);try{await C(),setTimeout(()=>{n(!1),o()},500)}catch(t){n(!1),t.code==="auth/popup-closed-by-user"||t.code==="auth/cancelled-popup-request"||l(t.message)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":v,className:"bg-white rounded-lg max-w-md w-full p-6 relative",children:[e.jsx("button",{onClick:o,"aria-label":"Close",className:"absolute top-4 right-4 text-gray-400 hover:text-gray-600",children:e.jsx(M,{className:"w-5 h-5"})}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("h2",{id:v,className:"text-2xl font-bold text-gray-900 mb-2",children:[s==="login"&&"Sign In",s==="signup"&&"Create Account",s==="reset"&&"Reset Password"]}),e.jsxs("p",{className:"text-gray-600",children:[s==="login"&&"Welcome back! Sign in to track your usage.",s==="signup"&&"Create an account to get 30 free pages and track your usage.",s==="reset"&&"Enter your email to receive a password reset link."]})]}),p&&e.jsx("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded text-red-700 text-sm",children:p}),y&&e.jsx("div",{className:"mb-4 p-3 bg-green-50 border border-green-200 rounded text-green-700 text-sm",children:y}),s!=="reset"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:P,disabled:c,className:"w-full flex items-center justify-center gap-3 bg-white border border-gray-300 text-gray-700 py-2 px-4 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[e.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),e.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),e.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),e.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),c?"Signing in...":"Continue with Google"]}),s==="signup"&&e.jsxs("div",{className:"text-xs text-gray-500 text-center mt-2",children:["By continuing, you agree to our"," ",e.jsx("a",{href:"/terms",className:"text-blue-600 hover:underline",children:"Terms of Service"})," ","and"," ",e.jsx("a",{href:"/privacy",className:"text-blue-600 hover:underline",children:"Privacy Policy"}),"."]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t border-gray-300"})}),e.jsx("div",{className:"relative flex justify-center text-sm",children:e.jsx("span",{className:"px-2 bg-white text-gray-500",children:"Or"})})]})]}),e.jsxs("form",{onSubmit:k,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Email"}),e.jsx("input",{type:"email",required:!0,value:i,onChange:t=>g(t.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"Enter your email"})]}),s!=="reset"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Password"}),e.jsx("input",{type:"password",required:!0,value:a,onChange:t=>h(t.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"Enter your password",minLength:6})]}),s==="signup"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Confirm Password"}),e.jsx("input",{type:"password",required:!0,value:b,onChange:t=>f(t.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"Confirm your password",minLength:6})]}),s==="signup"&&e.jsxs("div",{className:"text-xs text-gray-500 text-center",children:["By continuing, you agree to our"," ",e.jsx("a",{href:"/terms",className:"text-blue-600 hover:underline",children:"Terms of Service"})," ","and"," ",e.jsx("a",{href:"/privacy",className:"text-blue-600 hover:underline",children:"Privacy Policy"}),"."]}
1),e.jsx("button",{type:"submit",disabled:c,className:"w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",children:c?"Processing...":s==="login"?"Sign In":s==="signup"?"Create Account":"Send Reset Email"})]}),e.jsxs("div",{className:"mt-6 text-center text-sm",children:[s==="login"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>u("reset"),className:"text-blue-600 hover:text-blue-700",children:"Forgot password?"}),e.jsxs("div",{className:"mt-2",children:["Don't have an account?"," ",e.jsx("button",{onClick:()=>u("signup"),className:"text-blue-600 hover:text-blue-700 font-medium",children:"Sign up"})]})]}),s==="signup"&&e.jsxs("div",{children:["Already have an account?"," ",e.jsx("button",{onClick:()=>u("login"),className:"text-blue-600 hover:text-blue-700 font-medium",children:"Sign in"})]}),s==="reset"&&e.jsxs("div",{children:["Remember your password?"," ",e.jsx("button",{onClick:()=>u("login"),className:"text-blue-600 hover:text-blue-700 font-medium",children:"Sign in"})]})]})]})})};export{I 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.