PageSourceSearch

https://longtermemory.com/assets/Login-DGJNYDbv.js

js longtermemory.com collected 2026-09-24 10:34:59 UTC 13,104 bytes, 86 lines download raw bytes

1import{j as e,G as A,a as S}from"./index-b1g_5Tpl.js";import{r as l,u as R,e as _}from"./vendor-react-CO4_mtH0.js";import{c as z}from"./utils-CHcZDCx0.js";import{u as D}from"./usePostAuthFlow-BHmsjEKh.js";const P=l.forwardRef(({className:p,type:d,...s},a)=>e.jsx("input",{type:d,className:z("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",p),ref:a,...s}));P.displayName="Input";const L=l.forwardRef(({className:p,...d},s)=>e.jsx("label",{ref:s,className:z("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",p),...d}));L.displayName="Label";function W({children:p}){const d=l.useRef(null);return l.useEffect(()=>{const s=d.current;if(!s)return;const a=s.getContext("2d");if(!a)return;s.width=window.innerWidth,s.height=window.innerHeight;const v=()=>{s.width=window.innerWidth,s.height=window.innerHeight};window.addEventListener("resize",v);class h{x;y;size;speedX;speedY;opacity;pulseSpeed;pulsePhase;constructor(){this.x=Math.random()*s.width,this.y=Math.random()*s.height,this.size=Math.random()*2.5+1,this.speedX=(Math.random()-.5)*.3,this.speedY=(Math.random()-.5)*.3,this.opacity=Math.random()*.4+.3,this.pulseSpeed=Math.random()*.02+.01,this.pulsePhase=Math.random()*Math.PI*2}update(){s&&(this.x+=this.speedX,this.y+=this.speedY,this.x>s.width&&(this.x=0),this.x<0&&(this.x=s.width),this.y>s.height&&(this.y=0),this.y<0&&(this.y=s.height),this.pulsePhase+=this.pulseSpeed)}draw(){if(!a)return;const t=Math.sin(this.pulsePhase)*.3+.7;a.fillStyle=`rgba(200, 150, 255, ${this.opacity*t})`,a.beginPath(),a.arc(this.x,this.y,this.size*t,0,Math.PI*2),a.fill(),a.fillStyle=`rgba(200, 150, 255, ${this.opacity*t*.3})`,a.beginPath(),a.arc(this.x,this.y,this.size*t*2,0,Math.PI*2),a.fill()}}const u=window.innerWidth<768,g=u?15:80,r=[];for(let i=0;i<g;i++)r.push(new h);let f;function m(){if(!(!a||!s)){if(a.clearRect(0,0,s.width,s.height),r.forEach(i=>{i.update(),i.draw()}),!u)for(let i=0;i<r.length;i++)for(let t=i+1;t<r.length;t++){const b=r[i].x-r[t].x,y=r[i].y-r[t].y,j=Math.sqrt(b*b+y*y);if(j<150){const N=Math.sin(r[i].pulsePhase)*.3+.7,x=Math.sin(r[t].pulsePhase)*.3+.7,k=(N+x)/2;a.strokeStyle=`rgba(180, 130, 255, ${.15*(1-j/150)*k})`,a.lineWidth=1,a.beginPath(),a.moveTo(r[i].x,r[i].y),a.lineTo(r[t].x,r[t].y),a.stroke()}}f=requestAnimationFrame(m)}}return m(),()=>{window.removeEventListener("resize",v),cancelAnimationFrame(f)}},[]),e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
2        @keyframes grid-move {
3          0% { transform: translate(0, 0); }
4          100% { transform: translate(50px, 50px); }
5        }
6        @keyframes float-1 {
7          0%, 100% { transform: translate(0, 0) scale(1); }
8          33% { transform: translate(100px, 150px) scale(1.1); }
9          66% { transform: translate(-50px, 100px) scale(0.9); }
10        }
11        @keyframes float-2 {
12          0%, 100% { transform: translate(0, 0) scale(1); }
13          33% { transform: translate(-150px, -100px) scale(1.2); }
14          66% { transform: translate(80px, -150px) scale(0.85); }
15        }
16        @keyframes float-3 {
17          0%, 100% { transform: translate(-50%, -50%) scale(1); }
18          50% { transform: translate(-30%, -60%) scale(1.15); }
19        }
20        @keyframes pulse-opacity {
21          0%, 100% { opacity: 0.4; }
22          50% { opacity: 0.6; }
23        }
24        @keyframes brain-wave-expand {
25          0% { width: 0; height: 0; opacity: 0.6; }
26          50% { opacity: 0.3; }
27          100% { width: 1200px; height: 1200px; opacity: 0; }
28        }
29        .grid-bg::before {
30          content: '';
31          position: absolute;
32          width: 100%;
33          height: 100%;
34          background-image:
35            linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px),
36            linear-gradient(180deg, rgba(255,255,255,.03) 1px, transparent 1px);
37          background-size: 50px 50px;
38          animation: grid-move 20s linear infinite;
39        }
40        .particle-bg-orb-1 {
41          width: 400px;
42          height: 400px;
43          background: radial-gradient(circle, rgba(138, 43, 226, 0.6) 0%, transparent 70%);
44          top: -200px;
45          left: -200px;
46          animation: float-1 20s infinite, pulse-opacity 4s ease-in-out infinite;
47        }
48        .particle-bg-orb-2 {
49          width: 500px;
50          height: 500px;
51          background: radial-gradient(circle, rgba(75, 0, 130, 0.5) 0%, transparent 70%);
52          bottom: -250px;
53          right: -250px;
54          animation: float-2 25s infinite, pulse-opacity 5s ease-in-out infinite;
55        }
56        .particle-bg-orb-3 {
57          width: 350px;
58          height: 350px;
59          background: radial-gradient(circle, rgba(148, 0, 211, 0.4) 0%, transparent 70%);
60          top: 50%;
61          left: 50%;
62          transform: translate(-50%, -50%);
63          animation: float-3 30s infinite, pulse-opacity 6s ease-in-out infinite;
64        }
65        .particle-bg-wave-ring {
66          position: absolute;
67          top: 50%;
68          left: 50%;
69          transform: translate(-50%, -50%);
70          border: 2px solid rgba(138, 43, 226, 0.3);
71          border-radius: 50%;
72          animation: brain-wave-expand 8s ease-out infinite;
73        }
74        .particle-bg-wave-ring:nth-child(2) { animation-delay: 2s; }
75        .particle-bg-wave-ring:nth-child(3) { animation-delay: 4s; }
76        .particle-bg-wave-ring:nth-child(4) { animation-delay: 6s; }
77        @media (max-width: 767px) {
78          .particle-bg-orb-3 { display: none; }
79          .particle-bg-wave-ring:nth-child(3),
80          .particle-bg-wave-ring:nth-child(4) { display: none; }
81        }
82      `}),e.jsxs("div",{className:"relative flex min-h-screen items-center justify-center overflow-hidden px-4 py-12",style:{background:"#0a0e27",backgroundImage:`
83            radial-gradient(circle at 20% 30%, rgba(138, 43, 226, 0.12) 0%, transparent 50%),
84            radial-gradient(circle at 80% 70%, rgba(75, 0, 130, 0.12) 0%, transparent 50%),
85            radial-gradient(circle at 40% 80%, rgba(148, 0, 211, 0.08) 0%, transparent 50%)
86          `},children:[e.jsx("canvas",{ref:d,className:"absolute inset-0 z-0"}),e.jsxs("div",{className:"absolute inset-0 pointer-events-none z-0",style:{to
86p:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:[e.jsx("div",{className:"particle-bg-wave-ring"}),e.jsx("div",{className:"particle-bg-wave-ring"}),e.jsx("div",{className:"particle-bg-wave-ring"}),e.jsx("div",{className:"particle-bg-wave-ring"})]}),e.jsxs("div",{className:"absolute inset-0 overflow-hidden z-0",children:[e.jsx("div",{className:"particle-bg-orb-1 absolute rounded-full",style:{filter:"blur(60px)",opacity:.4}}),e.jsx("div",{className:"particle-bg-orb-2 absolute rounded-full",style:{filter:"blur(60px)",opacity:.4}}),e.jsx("div",{className:"particle-bg-orb-3 absolute rounded-full",style:{filter:"blur(60px)",opacity:.4}})]}),e.jsx("div",{className:"relative z-10 w-full flex justify-center",children:p})]})]})}function X(){const p=R(),[d,s]=_(),[a,v]=l.useState({email:""}),[h,u]=l.useState({}),[g,r]=l.useState(!1),[f,m]=l.useState(""),[i,t]=l.useState(null),[b,y]=l.useState(!1),[j,N]=l.useState(!1),[x,k]=l.useState(""),{completeAuthentication:M}=D();l.useEffect(()=>{localStorage.getItem("auth_token")&&p("/dashboard",{replace:!0})},[p]),l.useEffect(()=>{const o=d.get("error");o&&(t({text:o,type:"danger"}),d.delete("error"),s(d,{replace:!0}))},[d,s]);const C=o=>{const{name:n,value:c}=o.target;v(w=>({...w,[n]:c})),h[n]&&u(w=>{const E={...w};return delete E[n],E})},O=async o=>{o.preventDefault(),r(!0),u({}),m(""),t(null);try{const n=await S.login(a);n.status==200||!n.status?(t({text:"Magic link sent to your email. Click it to proceed!",type:"success"}),y(!0),setTimeout(()=>{N(!0)},5e3)):n.status==404?(t({text:"Open your Email and click the Link to complete registration!",type:"success"}),y(!0),setTimeout(()=>{N(!0)},5e3)):t({text:"An error occurred during login..",type:"danger"})}catch(n){const c=n;if(c.response?.data?.message)t({text:c.response.data.message,type:"danger"});else if(c.response?.status===422){const w=c.response.data;u(w.errors||{})}else c.response?.status===401?m("Invalid email or password"):m("An error occurred. Please try again.")}finally{r(!1)}},I=async o=>{if(o.credential){r(!0),t(null);try{const n=await S.googleLogin(o.credential);await M(n.token)}catch{t({text:"Google sign-in failed. Please try again.",type:"danger"})}finally{r(!1)}}},G=()=>{t({text:"Google sign-in was cancelled or failed.",type:"danger"})},T=o=>{const n=o.target.value.replace(/\D/g,"").slice(0,6);k(n)},F=async o=>{if(o.preventDefault(),x.length===6){r(!0),t(null);try{const n=await S.verifyOtp({email:a.email,otp:x});n.token&&await M(n.token)}catch(n){const c=n;c.response?.data?.message?t({text:c.response.data.message,type:"danger"}):t({text:"Invalid OTP code. Please try again.",type:"danger"})}finally{r(!1)}}};return e.jsxs(W,{children:[e.jsxs("div",{className:"w-full max-w-md 
86space-y-0",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight text-white",children:"Sign in to LongTerMemory"}),e.jsx("p",{className:"mt-2 text-sm text-white/60",children:"Use your email or Google account — no password needed"})]}),e.jsxs("div",{className:"rounded-xl px-4 sm:px-8 py-10 backdrop-blur-lg",children:[e.jsxs("form",{onSubmit:O,className:"space-y-6",children:[f&&e.jsx("div",{className:"rounded-md bg-red-500/20 border border-red-500/30 p-4 text-sm text-red-200",children:f}),i&&e.jsx("div",{className:`rounded-md p-4 text-sm border ${i.type==="success"?"bg-green-500/20 border-green-500/30 text-green-200":"bg-red-500/20 border-red-500/30 text-red-200"}`,children:i.text}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{htmlFor:"email",className:"sr-only",children:"Email address"}),e.jsx(P,{placeholder:"Email address",id:"email",name:"email",type:"email",autoComplete:"email",required:!0,value:a.email,onChange:C,className:`bg-white/10 border-white/20 text-white placeholder-white/40 focus:border-purple-500/50 focus:bg-white/15 ${h.email?"border-red-500":""}`,disabled:b}),h.email&&e.jsx("p",{className:"text-sm text-red-300",children:h.email[0]})]}),e.jsx("button",{type:"submit",disabled:g||b,className:"w-full rounded-lg border-2 border-purple-500/50 bg-purple-500/20 px-6 py-3 text-sm font-medium text-white backdrop-blur-lg transition-all duration-300 hover:bg-purple-500/30 hover:shadow-[0_8px_24px_rgba(138,43,226,0.4)] disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-purple-500/20",children:g?"Signing in...":"Sign in"})]}),e.jsxs("div",{className:"mt-6 flex flex-col items-center gap-3",children:[e.jsxs("div",{className:"flex items-center w-full gap-3",children:[e.jsx("div",{className:"flex-1 h-px bg-white/20"}),e.jsx("span",{className:"text-xs text-white/40 whitespace-nowrap",children:"or continue with Google"}),e.jsx("div",{className:"flex-1 h-px bg-white/20"})]}),e.jsx(A,{onSuccess:I,onError:G,useOneTap:!1,shape:"rectangular",theme:"outline",size:"large",width:"368"})]}),j&&e.jsxs("form",{onSubmit:F,className:"mt-6 sm:mt-12 pt-6 sm:pt-12 border-t border-white/10 space-y-4",children:[e.jsx("div",{className:"text-center",children:e.jsxs("p",{className:"text-sm text-white/80 mb-2",children:["Or enter the 6-digit ",e.jsx("b",{children:"OTP Code"})," from your email:"]})}),e.jsx("div",{className:"space-y-2",children:e.jsx(P,{id:"otp",name:"otp",type:"text",inputMode:"numeric",pattern:"[0-9]*",maxLength:6,placeholder:"000000",value:x,onChange:T,className:"bg-white/10 border-white/20 text-white placeholder-white/40 focus:border-purple-500/50 focus:bg-white/15 text-center text-2xl tracking-[0.5em] font-mono"})}),e.jsx("button",{type:"submit",disabled:g||x.length!==6,className:"w-full rounded-lg border-2 border-green-500/50 bg-green-500/20 px-6 py-3 text-sm font-medium text-white backdrop-blur-lg transition-all duration-300 hover:bg-green-500/30 hover:shadow-[0_8px_24px_rgba(34,197,94,0.4)] disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-green-500/20",children:g?"Verifying...":"Verify OTP"})]})]})]}),e.jsx("button",{onClick:()=>p("/"),className:"fixed bottom-8 left-1/2 -translate-x-1/2 z-10 p-3.5 rounded-full border border-white/25 bg-white/10 text-white/60 hover:text-white hover:bg-white/15 hover:border-white/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-purple-400 focus-visible:ring-offset-2 focus-visible:ring-offset-[#0a0e27] transition-all","aria-label":"Back to homepage",children:e.jsx("svg",{"aria-hidden":"true",className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 12H5m7-7l-7 7 7 7"})})})]})}export{X 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.