1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[94217],{33316:(e,t,a)=>{"use strict";a.d(t,{dj:()=>u});var s=a(7620);let r=0,i=new Map,n=e=>{if(i.has(e))return;let t=setTimeout(()=>{i.delete(e),d({type:"REMOVE_TOAST",toastId:e})},1e6);i.set(e,t)},l=[],o={toasts:[]};function d(e){o=((e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,1)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case"DISMISS_TOAST":{let{toastId:a}=t;return a?n(a):e.toasts.forEach(e=>{n(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===a||void 0===a?{...e,open:!1}:e)}}case"REMOVE_TOAST":if(void 0===t.toastId)return{...e,toasts:[]};return{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}})(o,e),l.forEach(e=>{e(o)})}function c(e){let{...t}=e,a=(r=(r+1)%Number.MAX_SAFE_INTEGER).toString(),s=()=>d({type:"DISMISS_TOAST",toastId:a});return d({type:"ADD_TOAST",toast:{...t,id:a,open:!0,onOpenChange:e=>{e||s()}}}),{id:a,dismiss:s,update:e=>d({type:"UPDATE_TOAST",toast:{...e,id:a}})}}function u(){let[e,t]=s.useState(o);return s.useEffect(()=>(l.push(t),()=>{let e=l.indexOf(t);e>-1&&l.splice(e,1)}),[e]),{...e,toast:c,dismiss:e=>d({type:"DISMISS_TOAST",toastId:e})}}},49694:(e,t,a)=>{"use strict";async function s(e){if(!e)return{ok:!1,error:"Missing session token"};try{let t=await fetch("/api/auth/ensure-profile",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`,"x-access-token":e}});if(!t.ok){let e=await t.json().catch(()=>({}));return{ok:!1,error:e.error||`ensure-profile failed (${t.status})`}}return{ok:!0}}catch(e){return{ok:!1,error:e instanceof Error?e.message:"ensure-profile network error"}}}a.d(t,{E:()=>s})},55904:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>b});var s=a(54568),r=a(7620),i=a(56005),n=a(48272),l=a(85244),o=a(11357),d=a(85508),c=a(1460),u=a(27541),m=a(32682),h=a(35136),x=a(49694),g=a(12631),p=a(33316),y=a(53);let f=i.A;function v(){let e=(0,u.useRouter)(),t=(0,u.useSearchParams)(),{toast:a}=(0,p.dj)(),{user:i,loading:v}=(0,c.A)(),b=(0,y.gG)(t),j=(0,y.x6)(t),k=(0,y.x0)(t),[w,S]=(0,r.useState)("email"),[N,T]=(0,r.useState)(""),[E,P]=(0,r.useState)(Array(6).fill("")),[A,_]=(0,r.useState)(!1),[O,C]=(0,r.useState)(""),[I,L]=(0,r.useState)(!1),[D,M]=(0,r.useState)(0),[R,$]=(0,r.useState)(null),q=(0,r.useRef)(!1),U=j?o.EW:l.JS,W=j?o.W7:l.zR,F=j?o.No:l.Mw,V=j?o.DU:l.wv,J=j?o.IY:"px-5 sm:px-8 py-5 sm:py-7 space-y-4 sm:space-y-5",z=j?"lc-auth-primary":"inline-flex items-center justify-center gap-2 px-6 py-2.5 sm:py-3 rounded-xl bg-emerald-600 hover:bg-emerald-500 dark:bg-emerald-500 dark:hover:bg-emerald-400 disabled:opacity-60 text-white font-semibold text-sm transition-colors duration-200 w-full",X=j?"w-full pl-10 pr-4 py-2.5 sm:py-3 rounded-xl border border-gray-200 bg-white text-gray-900 placeholder-gray-500 transition text-sm":`w-full pl-10 pr-4 py-2.5 sm:py-3 rounded-xl border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-950 text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400 transition text-sm ${l.jE}`,Y=j?"Sign in | Local Commons":"Sign in | LocalXP";(0,r.useEffect)(()=>{let e=null==t?void 0:t.get("invite");e&&$(e)},[t]),(0,r.useEffect)(()=>{(null==t?void 0:t.get("logged_out"))==="1"&&a({title:"Logged out",description:"You have been signed out successfully."})},[t,a]),(0,r.useEffect)(()=>{q.current||"success"===w||!v&&i&&(0,m.NJ)(i.id,{returnUrl:b},d.supabase).then(async t=>{await (0,h.C)(t,e,{embed:k})||C("Session could not reach the dashboard. Try signing in again or clear site data.")}).catch(t=>{console.error("Error determining redirect:",t),(0,h.C)(b||"/app",e,{embed:k})})},[i,v,e,b,w,k]),(0,r.useEffect)(()=>{if(q.current||"success"===w||i)return;let t=!1;return(async()=>{var a;let{data:s,error:r}=await d.supabase.auth.getSession();if(!t&&!r&&(null==(a=s.session)?void 0:a.user))try{let a=await (0,m.NJ)(s.session.user.id,{returnUrl:b},d.supabase);!t&&(await (0,h.C)(a,e,{embed:k})||C("Session could not reach the dashboard. Try signing in again."))}catch{t||(0,h.C)(b||"/app",e,{embed:k})}})(),()=>{t=!0}},[i,w,e,b,k]),(0,r.useEffect)(()=>{let e=document.querySelector('meta[name="viewport"]');e&&e.setAttribute("content","width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no")},[]),(0,r.useEffect)(()=>
1{if(D>0){let e=setTimeout(()=>{M(D-1)},1e3);return()=>clearTimeout(e)}},[D]);let B=async function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e&&e.preventDefault(),_(!0),C(""),t&&P(Array(6).fill(""));try{let{error:e}=await d.supabase.auth.signInWithOtp({email:N,options:{shouldCreateUser:!1,emailRedirectTo:void 0}});if(e){let t=(e.message||"").toLowerCase();t.includes("user not found")||t.includes("signups not allowed for otp")||t.includes("signup is disabled")?C("We couldn't find an account with that email. Please check for typos or create an account to continue."):e.message.includes("rate limit")||e.message.includes("Too Many Requests")?(C("Too many sign-in attempts. Please wait a few minutes before trying again."),M(120)):C(e.message);return}L(!0),t?(C(""),M(60)):S("otp")}catch(e){var a;console.error("Send OTP error:",e),(null==e||null==(a=e.message)?void 0:a.includes("429"))||(null==e?void 0:e.status)===429?(C("Too many sign-in attempts. Please wait a few minutes before trying again."),M(120)):C("Failed to send OTP. Please try again.")}finally{_(!1)}},G=async()=>{_(!0),C(""),q.current=!0;let t=crypto.randomUUID();try{var a,s,r,i,n,l;let o=E.join("");if(6!==o.length){C("Please enter the complete 6-digit verification code."),_(!1);return}let{data:c,error:u}=await d.supabase.auth.verifyOtp({email:N,token:o,type:"email"});if(u){console.error("OTP verification failed:",u);let e="Failed to verify code. Please try again.",t=!1;(null==(a=u.message)?void 0:a.includes("expired"))?(e="Verification code has expired. Please request a new one.",t=!0):(null==(s=u.message)?void 0:s.includes("invalid"))||(null==(r=u.message)?void 0:r.includes("Invalid"))?e="Invalid verification code. Please check the code and try again.":(null==(i=u.message)?void 0:i.includes("too_many_requests"))?(e="Too many attempts. Please wait a moment before trying again.",t=!0):(null==(n=u.message)?void 0:n.includes("Token has already been used"))?(e="This code has already been used. Please request a new code.",t=!0):e=u.message||e,C(e),t&&P(Array(6).fill("")),_(!1);return}if(c.user&&c.session){let a;S("success");let s=await (0,x.E)(c.session.access_token);if(!s.ok){C(s.error||"Could not finish setting up your account. Please try again."),_(!1),q.current=!1;return}let r=null;if(R)try{let e=await fetch("/api/invite/complete-join",{method:"POST",headers:{"Content-Type":"application/json",...(null==(l=c.session)?void 0:l.access_token)?{Authorization:`Bearer ${c.session.access_token}`,"x-access-token":c.session.access_token}:{},"x-request-id":t},body:JSON.stringify({invite_code:R})}),a=await e.json();e.ok&&a.joined?(sessionStorage.setItem("joined_via_invite","true"),r=a.tenant_slug||null):(console.error("Invite join failed:",a.error||e.status),C(a.error||"Failed to join community. You can join later from the invite link."))}catch(e){console.error("Invite join network error:",e),C("Network error joining community. You can join later from the invite link.")}if(r)a=`/t/${r}`;else try{a=await (0,m.NJ)(c.user.id,{returnUrl:b},d.supabase)}catch(e){console.error("Error determining redirect, using fallback:",e),a=b||"/app"}setTimeout(()=>{(0,h.C)(a,e,{embed:k})},1500)}else C("Verification failed. Please try again or request a new code."),q.current=!1}catch(e){console.error("Verify OTP exception:",e),C("An error occurred during verification. Please try again."),q.current=!1}finally{_(!1)}};if((0,r.useEffect)(()=>{"otp"!==w||6!==E.join("").length||A||G()},[E,w]),E.every(e=>""!==e),"success"===w)return(0,s.jsx)(U,{title:j?"Signed in | Layer Cake":"Signed in | LocalXP",children:(0,s.jsxs)("div",{className:`${W} ${j?"lc-auth-loading":"p-5 sm:p-10 text-center"}`,children:[j?(0,s.jsx)("div",{className:"lc-auth-spinner","aria-hidden":!0}):(0,s.jsx)("div",{className:"w-12 h-12 sm:w-16 sm:h-16 bg-emerald-100 dark:bg-emerald-900/40 rounded-full flex items-center justify-center mx-auto mb-3 sm:mb-5",children:(0,s.jsx)("svg",{className:"w-6 h-6 sm:w-8 sm:h-8 text-emerald-600 dark:text-emerald-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),(0,s.jsx)("h2",{className:j?void 0:"text-lg sm:text-2xl font-bold text-gray-900 dark:text-white mb-1.5 sm:mb-2",children:"Welcome back!"}),(0,s.jsx)("p",{className:j?void 0:"text-sm sm:text-base text-gray-600 dark:text-gray-400 mb-2 sm:mb-3",children:j?"Signed in â heading back to the Living Mapâ¦":"You've been signed in successfully."}),j?null:(0,s.jsx)("p",{className:"text-xs sm:text-sm text-gray-500 dark:text-gray-500 animate-pulse",children:"Redirecting..."})]})});if(v)return(0,s.jsx)(U,{title:Y,children:(0,s.jsxs)("div",{className:`${W} ${j?"lc-auth-loading":"p-10 text-center"}`,children:[j?(0,s.jsx)("div",{className:"lc-auth-spinner","aria-hidden":!0}):(0,s.jsx)("div",{className:"w-16 h-16 bg-emerald-100 dark:bg-emerald-900/40 rounded-full flex items-center justify-center mx-auto mb-5",children:(0,s.jsx)("div",{className:"w-8 h-8 border-2 border-emerald-500 border-t-transparent roun
1ded-full animate-spin"})}),(0,s.jsx)("h2",{className:j?void 0:"text-xl font-semibold text-gray-900 dark:text-white mb-2",children:"Checking authenticationâ¦"}),(0,s.jsx)("p",{className:j?void 0:"text-sm text-gray-500 dark:text-gray-400",children:"Please wait while we verify your session."})]})});let H=(0,y.i2)("/signup",t),K="email"===w?j?k?"Sign in":"Sign in to the Living Map":"Sign in to LocalXP":"Enter verification code",Q="email"===w?j?k?"Weâll email you a one-time code":"Place, edit, and save on this place â weâll email you a code":"Enter your email and we'll send you a code":`We sent a 6-digit code to ${N}`;return(0,s.jsx)(U,{title:Y,children:(0,s.jsxs)("div",{className:W,children:[(0,s.jsx)("div",{className:F,children:j?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("h1",{children:K}),(0,s.jsx)("p",{children:Q})]}):(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("h1",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:K}),(0,s.jsx)("p",{className:"text-sm text-gray-500 dark:text-slate-300 mt-1",children:Q})]})}),(0,s.jsxs)("div",{className:J,children:[O&&(0,s.jsx)("div",{className:j?"lc-auth-error":"rounded-xl border border-red-200 dark:border-red-800 bg-red-50 dark:bg-red-950/40 px-4 py-3",children:(0,s.jsx)("p",{className:j?void 0:"text-sm text-red-600 dark:text-red-400",children:O})}),"email"===w&&(0,s.jsxs)("form",{onSubmit:B,className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"email",className:j?void 0:"block text-sm font-medium text-gray-700 dark:text-slate-100 mb-1",children:"Email address"}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)(f,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-slate-400 pointer-events-none"}),(0,s.jsx)("input",{id:"email",type:"email",value:N,onChange:e=>T(e.target.value),onFocus:e=>{setTimeout(()=>{e.target.scrollIntoView({behavior:"smooth",block:"center"})},300)},className:X,placeholder:"[email protected]",required:!0})]})]}),(0,s.jsx)("button",{type:"submit",disabled:A||!N,className:z,children:A?"Sendingâ¦":"Send code"})]}),"otp"===w&&(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)(g.AnimatedOTPInput,{value:E,onChange:e=>{P(e)},disabled:A}),A&&(0,s.jsx)("p",{className:j?"text-center text-sm animate-pulse":"text-center text-sm text-emerald-600 dark:text-emerald-400 animate-pulse",children:"Verifyingâ¦"}),(0,s.jsx)("button",{type:"button",onClick:()=>B(void 0,!0),disabled:A||D>0,className:z,children:D>0?`Resend code (${D}s)`:"Resend code"}),(0,s.jsx)("div",{className:"text-center",children:(0,s.jsx)("button",{type:"button",onClick:()=>{S("email"),P(Array(6).fill("")),L(!1),M(0),C("")},className:j?"lc-auth-muted-btn":"text-sm text-gray-400 dark:text-slate-400 hover:text-gray-600 dark:hover:text-slate-200 transition-colors",children:"â Back to sign in"})})]})]}),(0,s.jsx)("div",{className:V,children:(0,s.jsxs)("p",{className:j?void 0:"text-sm text-gray-500 dark:text-gray-400",children:["Don't have an account?"," ",(0,s.jsx)(n.default,{href:H,className:j?void 0:"text-emerald-600 hover:text-emerald-500 dark:text-emerald-400 dark:hover:text-emerald-300 font-medium transition-colors",children:"Sign up"})]})})]})})}function b(){return(0,s.jsx)(r.Suspense,{fallback:(0,s.jsx)(l.JS,{title:"Sign in | LocalXP",children:(0,s.jsx)("div",{className:`${l.zR} flex items-center justify-center min-h-[280px]`,children:(0,s.jsx)("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Loadingâ¦"})})}),children:(0,s.jsx)(v,{})})}},56005:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(97720).A)("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]])},74741:(e,t,a)=>{Promise.resolve().then(a.bind(a,55904))}},e=>{e.O(0,[79721,96349,71863,21928,24904,90845,98837,19664,60996,81095,70273,16836,52138,10489,55807,95208,31304,71416,49016,72177,16158,12631,74764,64435,53568,587,90018,77358],()=>e(e.s=74741)),_N_E=e.O()}]);
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.