PageSourceSearch

https://rfpforgeai.com/assets/auth-CJMIrrKo.js

js rfpforgeai.com collected 2026-10-09 22:01:00 UTC 13,789 bytes, 1 lines download raw bytes

1import{s as N,r as d,j as e,u as Q,L as S,t as j}from"./index-DwUM8HjG.js";import{c as Z,u as G,a as M,B as U}from"./button-CzqgLvlk.js";import{L as F,I as A}from"./input-uJ98uv1a.js";import{L as R}from"./label-DmRTP_pp.js";import{P as L,u as ee,c as B,a as te,b as re}from"./index-61SE6DWD.js";import{u as ne}from"./index-CEn_ZFtW.js";import{P as oe}from"./index-7ynCgKYc.js";import{C as se}from"./check-kKD71wVD.js";import{F as ae}from"./file-check-corner-Duho2vpb.js";import{A as ie}from"./arrow-right-CPtRxnWU.js";const ce=[["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"}]],de=Z("mail",ce);var le={version:"1.1.2"},ue="authorization_response",he="/~oauth/initiate",me=["https://oauth.lovable.app","https://lovable.dev"],pe="lovable://oauth-callback",fe="http://127.0.0.1/iframe-oauth/callback",ge=500,we=12e4;function xe(t){let r;const n=new Promise(s=>{r=s}),i=s=>{if(!t.some(u=>s.origin===u))return;const l=s.data;!l||typeof l!="object"||l.type===ue&&r(l.response)},c=()=>{window.removeEventListener("message",i)};return window.addEventListener("message",i),{cleanup:c,messagePromise:n}}function be(t){const r=window.screenX!==0||window.screenY!==0||!t,n=r?window.outerWidth*.5:window.screen.width*.5,i=r?window.outerHeight*.5:window.screen.height*.5,c=r?window.screenX+(window.outerWidth-n)/2:(window.screen.width-n)/2,s=r?window.screenY+(window.outerHeight-i)/2:(window.screen.height-i)/2;return{width:n,height:i,left:c,top:s}}function q(t,r){return t.state!==r?{error:new Error("State is invalid")}:t.error?t.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(t.error_description??"Sign in failed")}:!t.access_token||!t.refresh_token?{error:new Error("No tokens received")}:{tokens:{access_token:t.access_token,refresh_token:t.refresh_token},error:null}}function ve(){const t=navigator.userAgent;return!!(/iPhone|iPad|iPod|Android/i.test(t)||/Macintosh/i.test(t)&&navigator.maxTouchPoints>1)}function ke(){return typeof crypto<"u"&&crypto.getRandomValues?[...crypto.getRandomValues(new Uint8Array(16))].map(t=>t.toString(16).padStart(2,"0")).join(""):Math.random().toString(36).substring(2)+Date.now().toString(36)}function ye(t={}){const r=t.oauthBrokerUrl??he,n=t.supportedOAuthOrigins??me;async function i(c,s={}){let h=!1;try{h=window.self!==window.top}catch{h=!0}const l=navigator.userAgent,u=/LovableApp\//.test(l),g=!u&&/lovable/i.test(l),w=ke();let m=s.redirect_uri??window.location.origin;u&&h?m=pe:g&&h&&(m=fe);const f=new URLSearchParams({...s.extraParams,provider:c,redirect_uri:m,state:w});if(!h)return window.location.href=`${r}?${f.toString()}`,{error:null,redirected:!0};!u&&!g&&f.set("response_mode","web_message");const x=`${r}?${f.toString()}`,b=g?[...n,window.location.origin]:n,{messagePromise:v,cleanup:k}=xe(b);let o;if(ve())o=window.open(x,"_blank");else{const{width:p,height:C,left:_,top:P}=be(h);o=window.open(x,"oauth",`width=${p},height=${C},left=${_},top=${P}`)}if(!o&&(u||g)){let p;const C=new Promise((_,P)=>{p=setTimeout(()=>{P(new Error("OAuth timed out waiting for response"))},we)});try{const _=await Promise.race([v,C]);return q(_,w)}catch(_){return{error:_ instanceof Error?_:new Error(String(_))}}finally{p&&clearTimeout(p),k()}}if(!o)return k(),{error:new Error("Popup was blocked")};let a;const y=new Promise((p,C)=>{a=setInterval(()=>{o.closed&&(clearInterval(a),C(new Error("Sign in was cancelled")))},ge)});try{const p=await Promise.race([v,y]);return q(p,w)}catch(p){return{error:p instanceof Error?p:new Error(String(p))}}finally{clearInterval(a),k(),o?.close()}}return{signInWithOAuth:i}}typeof window<"u"&&(window.__lovable_cloud_auth_js_version=le.version);function _e(t={}){return ye(t)}const Ce=_e(),Ee={auth:{signInWithOAuth:async(t,r)=>{const n=await Ce.signInWithOAuth(t,{redirect_uri:r?.redirect_uri,extraParams:{...r?.extraParams}});if(n.redirected||n.error)return n;try{await N.auth.setSession(n.tokens)}catch(i){return{error:i instanceof Error?i:new Error(String(i))}}return n}}};var I="Checkbox",[je]=re(I),[Ne,O]=je(I);function Pe(t){const{__scopeCheckbox:r,checked:n,children:i,defaultChecked:c,disabled:s,form:h,name:l,onCheckedChange:u,required:g,value:w="on",internal_do_not_use_render:m}=t,[f,x]=ee({prop:n,defaultProp:c??!1,onChange:u,caller:I}),[b,v]=d.useState(null),[k,o]=d.useState(null),a=d.useRef(!1),y=b?!!h||!!b.closest("form"):!0,p={checked:f,disabled:s,setChecked:x,control:b,setControl:v,name:l,form:h,value:w,hasConsumerStoppedPropagationRef:a,required:g,defaultChecked:E(c)?!1:c,isFormControl:y,bubbleInput:k,setBubbleInput:o};return e.jsx(Ne,{scope:r,...p,children:Se(m)?m(p):i})}var H="CheckboxTrigger",W=d.forwardRef(({__scopeCheckbox:t,onKeyDown:r,onClick:n,...i},c)=>{const{control:s,value:h,disabled:l,checked:u,required:g,setControl:w,setChecked:m,hasConsumerStoppedPropagationRef:f,isFormControl:x,bubbleInput:b}=O(H,t),v=G(c,w),k=d.useRef(u);return d.useEffect(()=>{const o=s?.form;if(o){const a=()=>m(k.current);return o.addEventListener("reset",a),()=>o.removeEventListener("reset",a)}},[s,m]),e.jsx(L.button,{type:"button",role:"checkbox","aria-checked":E(u)?"mixed":u,"aria-required":g,"data-state":Y(u),"data-disabled":l?"":void 0,disabled:l,value:h,...i,ref:v,onKeyDown:B(r,o=>{o.key==="Enter"&&o.preventDefault()}),onClick:B(n,o=>{m(a=>E(a)?!0:!a),b&&x&&(f.current=o.isPropagationStopped(),f.current||o.stopPropagation())})})});W.displayName=H;var D=d.forwardRef((t,r)=>{const{__scopeCheckbox:n,name:i,checked:c,defaultChecked:s,required:h,disabled:l,value:u,onCheckedChange:g,form:w,...m}=t;return e.jsx(Pe,{__scopeCheckbox:n,checked:c,defaultChecked:s,disabled:l,required:h,onCheckedChange:g,name:i,form:w,value:u,internal_do_not_use_render:({isFormControl:f})=>e.jsxs(e.Fragment,{children:[e.jsx(W,{...m,ref:r,__scopeCheckbox:n}),f&&e.jsx(X,{__scopeCheckbox:n})]})})});D.displayName=I;var K="CheckboxIndicator",V=d.forwardRef((t,r)=>{const{__scopeCheckbox:n,forceMount:i,...c}=t,s=O(K,n);return e.jsx(oe,{present:i||E(s.checked)||s.checked===!0,children:e.jsx(L.span,{"data-state":Y(s.checked),"data-disabled":s.disabled?"":void 0,...c,ref:r,
1style:{pointerEvents:"none",...t.style}})})});V.displayName=K;var z="CheckboxBubbleInput",X=d.forwardRef(({__scopeCheckbox:t,...r},n)=>{const{control:i,hasConsumerStoppedPropagationRef:c,checked:s,defaultChecked:h,required:l,disabled:u,name:g,value:w,form:m,bubbleInput:f,setBubbleInput:x}=O(z,t),b=G(n,x),v=ne(s),k=te(i);d.useEffect(()=>{const a=f;if(!a)return;const y=window.HTMLInputElement.prototype,C=Object.getOwnPropertyDescriptor(y,"checked").set,_=!c.current;if(v!==s&&C){const P=new Event("click",{bubbles:_});a.indeterminate=E(s),C.call(a,E(s)?!1:s),a.dispatchEvent(P)}},[f,v,s,c]);const o=d.useRef(E(s)?!1:s);return e.jsx(L.input,{type:"checkbox","aria-hidden":!0,defaultChecked:h??o.current,required:l,disabled:u,name:g,value:w,form:m,...r,tabIndex:-1,ref:b,style:{...r.style,...k,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});X.displayName=z;function Se(t){return typeof t=="function"}function E(t){return t==="indeterminate"}function Y(t){return E(t)?"indeterminate":t?"checked":"unchecked"}const J=d.forwardRef(({className:t,...r},n)=>e.jsx(D,{ref:n,className:M("grid place-content-center peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow cursor-pointer focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...r,children:e.jsx(V,{className:M("grid place-content-center text-current"),children:e.jsx(se,{className:"h-4 w-4"})})}));J.displayName=D.displayName;const $="2026-06-07",T="rfp_pending_terms";async function Ie(t,r){const{data:n}=await N.auth.getUser();n.user&&await N.from("profiles").update({terms_version:t,terms_accepted_at:r}).eq("id",n.user.id).is("terms_accepted_at",null)}function $e(){const t=Q(),[r,n]=d.useState("signup"),[i,c]=d.useState(""),[s,h]=d.useState(""),[l,u]=d.useState(""),[g,w]=d.useState(!1),[m,f]=d.useState(!1),[x,b]=d.useState(!1);d.useEffect(()=>{N.auth.getSession().then(async({data:o})=>{if(o.session){const a=typeof window<"u"?localStorage.getItem(T):null;if(a){try{const{version:y,acceptedAt:p}=JSON.parse(a);await Ie(y,p)}catch{}localStorage.removeItem(T)}t({to:"/onboarding"})}})},[t]);async function v(o){if(o.preventDefault(),r==="signup"&&!x){j.error("Please accept the Terms and Conditions to continue.");return}w(!0);try{if(r==="signup"){const a=new Date().toISOString(),{error:y}=await N.auth.signUp({email:i,password:s,options:{emailRedirectTo:`${window.location.origin}/onboarding`,data:{full_name:l,terms_version:$,terms_accepted_at:a}}});if(y)throw y;j.success("Check your email to confirm your account.")}else{const{error:a}=await N.auth.signInWithPassword({email:i,password:s});if(a)throw a;j.success("Welcome back"),t({to:"/onboarding"})}}catch(a){j.error(a instanceof Error?a.message:"Authentication failed")}finally{w(!1)}}async function k(){if(r==="signup"&&!x){j.error("Please accept the Terms and Conditions to continue.");return}if(f(!0),r==="signup")try{localStorage.setItem(T,JSON.stringify({version:$,acceptedAt:new Date().toISOString()}))}catch{}try{const o=await Ee.auth.signInWithOAuth("google",{redirect_uri:`${window.location.origin}/onboarding`});if(o.error){j.error("Google sign-in failed"),f(!1);return}if(o.redirected)return;t({to:"/onboarding"})}catch{j.error("Google sign-in failed"),f(!1)}}return e.jsxs("div",{className:"relative min-h-screen overflow-hidden bg-background",children:[e.jsx("div",{className:"absolute inset-0 grid-pattern opacity-60"}),e.jsx("div",{className:"absolute inset-0 bg-hero-glow"}),e.jsxs("div",{className:"relative mx-auto flex min-h-screen max-w-md flex-col justify-center px-6 py-12",children:[e.jsxs(S,{to:"/",className:"mb-10 inline-flex items-center gap-2",children:[e.jsx("div",{className:"grid h-8 w-8 place-items-center rounded-lg bg-gradient-accent shadow-glow",children:e.jsx(ae,{className:"size-4 text-primary-foreground"})}),e.jsxs("span",{className:"font-display text-lg font-semibold tracking-tight",children:["RFP Forge",e.jsx("span",{className:"text-primary",children:" AI"})]})]}),e.jsxs("div",{className:"rounded-2xl border border-border bg-card/80 p-8 shadow-elevated backdrop-blur",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold tracking-tight",children:r==="signup"?"Create your account":"Welcome back"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:r==="signup"?"
1Start free with 300,000 characters per month.":"Sign in to continue to your dashboard."}),e.jsxs(U,{type:"button",variant:"outline",className:"mt-6 w-full",onClick:k,disabled:m||g,children:[m?e.jsx(F,{className:"animate-spin"}):e.jsx(Ae,{}),"Continue with Google"]}),e.jsxs("div",{className:"my-5 flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsx("div",{className:"h-px flex-1 bg-border"}),e.jsx("span",{children:"or"}),e.jsx("div",{className:"h-px flex-1 bg-border"})]}),e.jsxs("form",{onSubmit:v,className:"space-y-4",children:[r==="signup"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(R,{htmlFor:"name",children:"Name"}),e.jsx(A,{id:"name",value:l,onChange:o=>u(o.target.value),placeholder:"Jane Doe",required:!0})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(R,{htmlFor:"email",children:"Email"}),e.jsx(A,{id:"email",type:"email",value:i,onChange:o=>c(o.target.value),placeholder:"[email protected]",required:!0,autoComplete:"email"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(R,{htmlFor:"password",children:"Password"}),e.jsx(A,{id:"password",type:"password",value:s,onChange:o=>h(o.target.value),placeholder:"••••••••",required:!0,minLength:6,autoComplete:r==="signup"?"new-password":"current-password"})]}),r==="signup"&&e.jsxs("label",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[e.jsx(J,{checked:x,onCheckedChange:o=>b(o===!0),className:"mt-0.5"}),e.jsxs("span",{children:["I have read and agree to the"," ",e.jsx(S,{to:"/terms",target:"_blank",className:"font-medium text-primary hover:underline",children:"Terms and Conditions"}),", including the disclaimers, limitation of liability, and arbitration provisions."]})]}),e.jsxs(U,{type:"submit",variant:"hero",className:"w-full",disabled:g||m||r==="signup"&&!x,children:[g?e.jsx(F,{className:"animate-spin"}):e.jsx(de,{}),r==="signup"?"Create account":"Sign in",e.jsx(ie,{})]})]}),e.jsx("div",{className:"mt-6 text-center text-sm text-muted-foreground",children:r==="signup"?e.jsxs(e.Fragment,{children:["Already have an account? ",e.jsx("button",{onClick:()=>n("signin"),className:"font-medium text-primary hover:underline",children:"Sign in"})]}):e.jsxs(e.Fragment,{children:["New here? ",e.jsx("button",{onClick:()=>n("signup"),className:"font-medium text-primary hover:underline",children:"Create an account"})]})})]}),e.jsxs("p",{className:"mt-6 text-center text-xs text-muted-foreground",children:["By continuing, you agree to our"," ",e.jsx(S,{to:"/terms",className:"underline hover:text-foreground",children:"Terms"})," and"," ",e.jsx(S,{to:"/privacy",className:"underline hover:text-foreground",children:"Privacy Policy"}),"."]})]})]})}function Ae(){return e.jsx("svg",{viewBox:"0 0 24 24",className:"size-4","aria-hidden":"true",children:e.jsx("path",{fill:"#EA4335",d:"M12 10.2v3.9h5.5c-.24 1.4-1.66 4.1-5.5 4.1-3.3 0-6-2.74-6-6.1s2.7-6.1 6-6.1c1.88 0 3.14.8 3.86 1.5l2.64-2.54C16.94 3.4 14.7 2.4 12 2.4 6.78 2.4 2.6 6.58 2.6 12s4.18 9.6 9.4 9.6c5.42 0 9-3.8 9-9.16 0-.62-.06-1.08-.16-1.54H12z"})})}export{$e 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.