1import{i as e}from"./chunk-aKtaBQYM.js";import{F as t,P as n,R as r,i,t as a}from"./jsx-runtime-PM9hl9fp.js";import{n as o}from"./esm-BD9Gasrs.js";import{t as s}from"./useMutation-BFQI1hdD.js";import{t as c}from"./AppLogo-CB78DcaP.js";import{n as l}from"./ErrorLabel-BXvHCSYG.js";import{t as u}from"./iconBase-DKTQXI5c.js";import{t as d}from"./Button-BiuXcStA.js";import{n as f,t as p}from"./TextInput-dcbLrEJO.js";import{o as m}from"./global-DMuzIvY8.js";import{t as h}from"./client-R_PR2ZS_.js";var g={page:`_page_4gqf7_1`},_={leftPane:`_leftPane_1mgzy_1`,logoWrapper:`_logoWrapper_1mgzy_9`,contentWrapper:`_contentWrapper_1mgzy_14`,title:`_title_1mgzy_22`,subtitle:`_subtitle_1mgzy_30`,divider:`_divider_1mgzy_37`,footer:`_footer_1mgzy_58`,errorBanner:`_errorBanner_1mgzy_76`,successTitle:`_successTitle_1mgzy_85`,successText:`_successText_1mgzy_93`},v=e(r(),1);function y(e){return u({tag:`svg`,attr:{version:`1.1`,x:`0px`,y:`0px`,viewBox:`0 0 48 48`,enableBackground:`new 0 0 48 48`},child:[{tag:`path`,attr:{fill:`#FFC107`,d:`M43.611,20.083H42V20H24v8h11.303c-1.649,4.657-6.08,8-11.303,8c-6.627,0-12-5.373-12-12\r 2 c0-6.627,5.373-12,12-12c3.059,0,5.842,1.154,7.961,3.039l5.657-5.657C34.046,6.053,29.268,4,24,4C12.955,4,4,12.955,4,24\r 3 c0,11.045,8.955,20,20,20c11.045,0,20-8.955,20-20C44,22.659,43.862,21.35,43.611,20.083z`},child:[]},{tag:`path`,attr:{fill:`#FF3D00`,d:`M6.306,14.691l6.571,4.819C14.655,15.108,18.961,12,24,12c3.059,0,5.842,1.154,7.961,3.039l5.657-5.657\r 4 C34.046,6.053,29.268,4,24,4C16.318,4,9.656,8.337,6.306,14.691z`},child:[]},{tag:`path`,attr:{fill:`#4CAF50`,d:`M24,44c5.166,0,9.86-1.977,13.409-5.192l-6.19-5.238C29.211,35.091,26.715,36,24,36\r 5 c-5.202,0-9.619-3.317-11.283-7.946l-6.522,5.025C9.505,39.556,16.227,44,24,44z`},child:[]},{tag:`path`,attr:{fill:`#1976D2`,d:`M43.611,20.083H42V20H24v8h11.303c-0.792,2.237-2.231,4.166-4.087,5.571\r 6 c0.001-0.001,0.002-0.001,0.003-0.002l6.19,5.238C36.971,39.205,44,34,44,24C44,22.659,43.862,21.35,43.611,20.083z`},child:[]}]})(e)}async function b({email:e,redirectTo:t}){let n=await fetch(`/api/auth/send-magic-link`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({email:e,redirectTo:t})}),r=await n.json();if(!n.ok||r.error)throw Error(r.error||`Something went wrong!`);return r}var x=a();function S({redirectTo:e}){let t=h(),n=o(),[r,a]=(0,v.useState)(null),{mutateAsync:u,isPending:m,isSuccess:g}=s({mutationFn:b,onSuccess:()=>{a(null),n?.capture(`magic_link_sent`)},onError:e=>a(e.message)}),S=l({defaultValues:{email:``},onSubmit:async({value:t})=>{await u({email:t.email,redirectTo:e})}});if(g)return(0,x.jsx)(`div`,{className:_.leftPane,children:(0,x.jsxs)(`div`,{className:_.contentWrapper,children:[(0,x.jsx)(`h2`,{className:_.successTitle,children:`Please check your email`}),(0,x.jsx)(`p`,{className:_.successText,children:`We have sent a magic link to your email. Click the link inside to sign in instantly.`})]})});return(0,x.jsxs)(`div`,{className:_.leftPane,children:[(0,x.jsx)(`div`,{className:_.logoWrapper,children:(0,x.jsx)(c,{})}),(0,x.jsxs)(`div`,{className:_.contentWrapper,children:[(0,x.jsx)(`h1`,{className:_.title,children:`Welcome`}),(0,x.jsx)(`p`,{className:_.subtitle,children:`Please sign in to access your account`}),(0,x.jsxs)(d,{variant:`secondary`,handleClick:C,children:[(0,x.jsx)(y,{size:20}),` Continue with Google`]}),(0,x.jsx)(`div`,{className:_.divider,children:(0,x.jsx)(`span`,{children:`or continue with email`})}),(0,x.jsxs)(f,{onSubmit:S.handleSubmit,children:[(0,x.jsx)(p,{form:S,name:`email`,label:`Email`,placeholder:`Enter your email`}),(0,x.jsx)(d,{variant:`primary`,handleClick:S.handleSubmit,isDisabled:m,type:`submit`,children:m?`Sending Link...`:`Send Login Link`}),r&&(0,x.jsx)(`div`,{className:_.errorBanner,children:r})]}),(0,x.jsxs)(`div`,{className:_.footer,children:[`By continuing, you agree to Carousel.in's`,(0,x.jsx)(i,{to:`/terms`,children:`Terms of Service`}),`and`,(0,x.jsx)(i,{to:`/privacy`,children:`Privacy Policy`}),`.`]})]})]});async function C(){n?.capture(`google_login_initiated`);let{error:r}=await t.auth.signInWithOAuth({provider:`google`,options:{redirectTo:e?`${window.location.origin}/verify?redirectTo=${encodeURIComponent(e)}`:`${window.location.origin}/verify`}});r&&a(r.message)}}var C=()=>
6m(`Login`),w=t(function(){let[e]=n(),t=e.get(`redirectTo`)||void 0;return(0,x.jsx)(`div`,{className:g.page,children:(0,x.jsx)(S,{redirectTo:t})})});export{w as default,C as meta};
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.