1import{s as P,d as j,b as N,r as x,e as T,f as O,j as t,S as I,L}from"./index-I-H4gY_t.js";var R={version:"1.1.2"},C="authorization_response",U="/~oauth/initiate",D=["https://oauth.lovable.app","https://lovable.dev"],F="lovable://oauth-callback",M="http://127.0.0.1/iframe-oauth/callback",B=500,$=12e4;function W(e){let o;const r=new Promise(c=>{o=c}),s=c=>{if(!e.some(d=>c.origin===d))return;const l=c.data;!l||typeof l!="object"||l.type===C&&o(l.response)},m=()=>{window.removeEventListener("message",s)};return window.addEventListener("message",s),{cleanup:m,messagePromise:r}}function V(e){const o=window.screenX!==0||window.screenY!==0||!e,r=o?window.outerWidth*.5:window.screen.width*.5,s=o?window.outerHeight*.5:window.screen.height*.5,m=o?window.screenX+(window.outerWidth-r)/2:(window.screen.width-r)/2,c=o?window.screenY+(window.outerHeight-s)/2:(window.screen.height-s)/2;return{width:r,height:s,left:m,top:c}}function A(e,o){return e.state!==o?{error:new Error("State is invalid")}:e.error?e.error==="legacy_flow"?{error:new Error("This flow is not supported in Preview mode. Please open the app in a new tab to sign in.")}:{error:new Error(e.error_description??"Sign in failed")}:!e.access_token||!e.refresh_token?{error:new Error("No tokens received")}:{tokens:{access_token:e.access_token,refresh_token:e.refresh_token},error:null}}function H(){const e=navigator.userAgent;return!!(/iPhone|iPad|iPod|Android/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1)}function G(){return typeof crypto<"u"&&crypto.getRandomValues?[...crypto.getRandomValues(new Uint8Array(16))].map(e=>e.toString(16).padStart(2,"0")).join(""):Math.random().toString(36).substring(2)+Date.now().toString(36)}function K(e={}){const o=e.oauthBrokerUrl??U,r=e.supportedOAuthOrigins??D;async function s(m,c={}){let u=!1;try{u=window.self!==window.top}catch{u=!0}const l=navigator.userAgent,d=/LovableApp\//.test(l),i=!d&&/lovable/i.test(l),g=G();let p=c.redirect_uri??window.location.origin;d&&u?p=F:i&&u&&(p=M);const b=new URLSearchParams({...c.extraParams,provider:m,redirect_uri:p,state:g});if(!u)return window.location.href=`${o}?${b.toString()}`,{error:null,redirected:!0};!d&&!i&&b.set("response_mode","web_message");const _=`${o}?${b.toString()}`,y=i?[...r,window.location.origin]:r,{messagePromise:S,cleanup:v}=W(y);let w;if(H())w=window.open(_,"_blank");else{const{width:a,height:E,left:f,top:k}=V(u);w=window.open(_,"oauth",`width=${a},height=${E},left=${f},top=${k}`)}if(!w&&(d||i)){let a;const E=new Promise((f,k)=>{a=setTimeout(()=>{k(new Error("OAuth timed out waiting for response"))},$)});try{const f=await Promise.race([S,E]);return A(f,g)}catch(f){return{error:f instanceof Error?f:new Error(String(f))}}finally{a&&clearTimeout(a),v()}}if(!w)return v(),{error:new Error("Popup was blocked")};let n;const h=new Promise((a,E)=>{n=setInterval(()=>{w.closed&&(clearInterval(n),E(new Error("Sign in was cancelled")))},B)});try{const a=await Promise.race([S,h]);return A(a,g)}catch(a){return{error:a instanceof Error?a:new Error(String(a))}}finally{clearInterval(n),v(),w?.close()}}return{signInWithOAuth:s}}typeof window<"u"&&(window.__lovable_cloud_auth_js_version=R.version);function X(e={}){return K(e)}const Y=X(),q={auth:{signInWithOAuth:async(e,o)=>{const r=await Y.signInWithOAuth(e,{redirect_uri:o?.redirect_uri,extraParams:{...o?.extraParams}});if(r.redirected||r.error)return r;try{await P.auth.setSession(r.tokens)}catch(s){return{error:s instanceof Error?s:new Error(String(s))}}return r}}};function J(){const{redirect:e}=j.useSearch(),o=N(),[r,s]=x.useState(""),[m,c]=x.useState(""),[u,l]=x.useState(!1),[d,i]=x.useState(null),[g,p]=x.useState(null),{recordLead:b,bindEmailField:_}=T("auth"),y=O(r,s),S=async()=>{if(i(null),p(null),!r){i("Enter your email above first, then click Forgot password.");return}const{error:n}=await P.auth.resetPasswordForEmail(r,{redirectTo:window.location.origin+"/reset-password"});n?i(n.message):p("Password reset link sent. Check your inbox.")};x.useEffect(()=>{let n=!1;return P.auth.getSession().then(({data:h})=>{!n&&h.session&&o({to:e})}),()=>{n=!0}},[o,e]);const v=async n=>{n.preventDefault(),l(!0),i(null),b(r);const{error:h}=await P.auth.signInWithPassword({email:r,password:m});if(l(!1),h){i(h.message);return}o({to:e})},w=async()=>{i(null);const n=await q.auth.signInWithOAuth("google",{redirect_uri:window.location.origin+e});if(n.error){i(n.error.message??"Google sign-in failed");return}n.redirected||o({to:e})};return t.jsx(I,{showStickyCTA:!1,children:t.jsx("section",{className:"container-edge flex min-h-[70vh] items-center justify-center py-16",children:t.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-border bg-card p-8 shadow-warm",children:[t.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:"Sign in to Everdance"}),t.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Access the content admin."}),t.jsx("button",{type:"button",onClick:w,className:"mt-6 flex w-full items-center justify-center gap-2 rounded-full border border-border bg-background px-5 py-3 text-sm font-medium text-foreground transition hover:bg-secondary",children:"Continue with Google"}),t.jsxs("div",{className:"my-6 flex items-center gap-3 text-xs uppercase tracking-wider text-muted-foreground",children:[t.jsx("span",{className:"h-px flex-1 bg-border"}),"or",t.jsx("span",{className:"h-px flex-1 bg-border"})]}),t.jsxs("form",{onSubmit:v,className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs font-medium text-foreground",children:"Email"}),t.jsx("input",{type:"email",required:!0,value:r,onChange:n=>s(n.target.value),onBlur:n=>{y.onBlur(),_().onBlur(n)},className:"w-full rounded-xl border border-border bg-background px-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-primary/40"}),y.hint]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs font-medium text-foreground",children:"Password"}),t.jsx("input",{type:"password",required:!0,value:m,onChange:n=>c(n.target.value),className:"w-full rounded-xl border border-border bg-background px-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-primary/40"})]}),d&&t.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:d}),g&&t.jsx("div",{className:"rounded-md bg-primary/10 px-3 py-2 text-xs text-foreground",children:g}),t.jsx("button",{type:"submit",disabled:u,className:"w-full rounded-full bg-primary px-5 py-3 text-sm font-medium text-primary-foreground shadow-warm transition hover:opacity-90 disabled:opacity-50",children:u?"Signing inâ¦":"Sign in"}),t.jsx("button",{type:"button",onClick:S,className:"w-full text-center text-xs text-muted-foreground underline hover:text-foreground",children:"Forgot password?"})]}),t.jsxs("p",{className:"mt-6 text-center text-xs text-muted-foreground",children:["Need an account? ",t.jsx(L,{to:"/$locale/contact",params:{locale:"en"},className:"underline",children:"Contact us"})]})]})})})}export{J as component};
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.