1import{d as P,r as b,f as T,j as e,s as D,t as c}from"./index-CrlHD_rY.js";import{B as M}from"./button-C9mq-HB0.js";import{I as z}from"./input-C_5ShHgB.js";import{L as N}from"./label-C1DSNaZ-.js";import{C as O,s as _,o as I}from"./checkbox-Bzl_gDBE.js";import{P as L}from"./public-layout-Dgt4YvtQ.js";import{c as B}from"./profanity-DJdRvBPF.js";import{l as U}from"./cookie-banner-CZ9Vfr7P.js";import"./utils-CsI7vFqD.js";import"./clsx-B-dksMZM.js";import"./check-ZmngRgNm.js";import"./createLucideIcon-D7E4aMTN.js";import"./x-DbwQtEZ-.js";import"./users-CQ1L-uez.js";import"./mail-B_NaO__j.js";var R={version:"1.1.2"},F="authorization_response",K="/~oauth/initiate",$=["https://oauth.lovable.app","https://lovable.dev"],G="lovable://oauth-callback",W="http://127.0.0.1/iframe-oauth/callback",H=500,V=12e4;function Z(r){let i;const o=new Promise(d=>{i=d}),a=d=>{if(!r.some(u=>d.origin===u))return;const m=d.data;!m||typeof m!="object"||m.type===F&&i(m.response)},p=()=>{window.removeEventListener("message",a)};return window.addEventListener("message",a),{cleanup:p,messagePromise:o}}function X(r){const i=window.screenX!==0||window.screenY!==0||!r,o=i?window.outerWidth*.5:window.screen.width*.5,a=i?window.outerHeight*.5:window.screen.height*.5,p=i?window.screenX+(window.outerWidth-o)/2:(window.screen.width-o)/2,d=i?window.screenY+(window.outerHeight-a)/2:(window.screen.height-a)/2;return{width:o,height:a,left:p,top:d}}function C(r,i){return r.state!==i?{error:new Error("State is invalid")}:r.error?r.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(r.error_description??"Sign in failed")}:!r.access_token||!r.refresh_token?{error:new Error("No tokens received")}:{tokens:{access_token:r.access_token,refresh_token:r.refresh_token},error:null}}function Y(){const r=navigator.userAgent;return!!(/iPhone|iPad|iPod|Android/i.test(r)||/Macintosh/i.test(r)&&navigator.maxTouchPoints>1)}function q(){return typeof crypto<"u"&&crypto.getRandomValues?[...crypto.getRandomValues(new Uint8Array(16))].map(r=>r.toString(16).padStart(2,"0")).join(""):Math.random().toString(36).substring(2)+Date.now().toString(36)}function J(r={}){const i=r.oauthBrokerUrl??K,o=r.supportedOAuthOrigins??$;async function a(p,d={}){let l=!1;try{l=window.self!==window.top}catch{l=!0}const m=navigator.userAgent,u=/LovableApp\//.test(m),E=!u&&/lovable/i.test(m),g=q();let A=d.redirect_uri??window.location.origin;u&&l?A=G:E&&l&&(A=W);const f=new URLSearchParams({...d.extraParams,provider:p,redirect_uri:A,state:g});if(!l)return window.location.href=`${i}?${f.toString()}`,{error:null,redirected:!0};!u&&!E&&f.set("response_mode","web_message");const h=`${i}?${f.toString()}`,v=E?[...o,window.location.origin]:o,{messagePromise:k,cleanup:j}=Z(v);let w;if(Y())w=window.open(h,"_blank");else{const{width:s,height:y,left:x,top:S}=X(l);w=window.open(h,"oauth",`width=${s},height=${y},left=${x},top=${S}`)}if(!w&&(u||E)){let s;const y=new Promise((x,S)=>{s=setTimeout(()=>{S(new Error("OAuth timed out waiting for response"))},V)});try{const x=await Promise.race([k,y]);return C(x,g)}catch(x){return{error:x instanceof Error?x:new Error(String(x))}}finally{s&&clearTimeout(s),j()}}if(!w)return j(),{error:new Error("Popup was blocked")};let t;const n=new Promise((s,y)=>{t=setInterval(()=>{w.closed&&(clearInterval(t),y(new Error("Sign in was cancelled")))},H)});try{const s=await Promise.race([k,n]);return C(s,g)}catch(s){return{error:s instanceof Error?s:new Error(String(s))}}finally{clearInterval(t),j(),w?.close()}}return{signInWithOAuth:a}}typeof window<"u"&&(window.__lovable_cloud_auth_js_version=R.version);function Q(r={}){return J(r)}const ee=Q(),re={auth:{signInWithOAuth:async(r,i)=>{const o=await ee.signInWithOAuth(r,{redirect_uri:i?.redirect_uri,extraParams:{...i?.extraParams}});if(o.redirected||o.error)return o;try{await P.auth.setSession(o.tokens)}catch(a){return{error:a instanceof Error?a:new Error(String(a))}}return o}}},te=I({displayName:_().trim().min(2,"Mind. 2 Zeichen").max(40),email:_().trim().email("Ungültige E-Mail").max(255),password:_().min(8,"Mind. 8 Zeichen").max(72)}),ne=I({email:_().trim().email("Ungültige E-Mail"),password:_().min(1,"Erforderlich")});function be(){const[r,i]=b.useState("signin"),[o,a]=b.useState(!0),[p,d]=b.useState(""),[l,m]=b.useState(""),[u,E]=b.useState(""),[g,A]=b.useState(!1),[f,h]=b.useState(!1),v=T();b.useEffect(()=>{let t=!0;return P.auth.getSession().then(({data:n})=>{t&&(n.session?v({to:"/spiel/dashboard",replace:!0}):a(!1))}),()=>{t=!1}},[v]);const k=async()=>{const t=_().trim().email().safeParse(l);if(!t.success){c.error("Bitte zuerst deine E-Mail-Adresse eintragen.");return}h(!0);const{error:n}=await P.auth.resetPasswordForEmail(t.data,{redirectTo:`${window.location.origin}/passwort-neu`});if(h(!1),n)return c.error("E-Mail konnte nicht gesendet werden.");c.success("Wir haben dir eine E-Mail zum Zurücksetzen geschickt.")},j=async t=>{t.preventDefault(),h(!0);try{if(r==="signup"){const n=te.safeParse({displayName:p,email:l,password:u});if(!n.success){c.error(n.error.issues[0].message);return}if(!g){c.error("Bitte bestätige die Datenschutzhinweise und AGB, um ein Konto zu erstellen.");return}if(B(n.data.displayName)){c.error("Dieser Anzeigename ist nicht möglich. Bitte wähle einen anderen.");return}const{error:s}=await P.auth.signUp({email:n.data.email,password:n.data.password,options:{emailRedirectTo:`${window.location.origin}/spiel/dashboard`,data:{display_name:n.data.displayName}}});if(s)throw s;c.success("Konto erstellt! Du bist jetzt angemeldet."),v({to:"/spiel/dashboard"})}else{const n=ne.safeParse({email:l,password:u});if(!n.success){c.error(n.error.issues[0].message);return}const{error:s}=await P.auth.signInWithPassword(n.data);if(s)throw s;v({to:"/spiel/dashboard"})}}catch(n){c.error(n.message??"Etwas ist schiefgelaufen.")}finally{h(!1)}},w=async()=>
1{if(r==="signup"&&!g){c.error("Bitte bestätige die Datenschutzhinweise und AGB, um ein Konto zu erstellen.");return}h(!0);try{const t=await re.auth.signInWithOAuth("google",{redirect_uri:window.location.origin});if(t.error){c.error("Google-Anmeldung fehlgeschlagen.");return}if(t.redirected)return;v({to:"/spiel/dashboard"})}catch(t){c.error(t.message??"Fehler bei Google-Anmeldung")}finally{h(!1)}};return e.jsx(L,{children:e.jsx("section",{className:"mx-auto grid min-h-[calc(100vh-8rem)] max-w-md place-items-center px-4 py-12 sm:px-6",children:e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("img",{src:U.url,alt:`${D.name} Logo`,width:642,height:226,className:"mx-auto h-20 w-auto"}),e.jsx("h1",{className:"mt-5 font-display text-3xl font-bold",children:r==="signin"?"Willkommen zurück!":"Konto erstellen"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:r==="signin"?"Melde dich an, um Spiele zu tracken und Badges zu sammeln.":"Es ist kostenlos und in 30 Sekunden erledigt."})]}),e.jsxs("div",{className:"mt-8 rounded-3xl border border-border bg-card p-6 shadow-soft sm:p-8",children:[e.jsxs(M,{type:"button",variant:"outline",className:"w-full rounded-full",disabled:f,onClick:w,children:[e.jsxs("svg",{className:"mr-2 h-4 w-4",viewBox:"0 0 24 24","aria-hidden":!0,children:[e.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),e.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.99.66-2.25 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84A11 11 0 0 0 12 23z"}),e.jsx("path",{fill:"#FBBC05",d:"M5.84 14.1A6.6 6.6 0 0 1 5.5 12c0-.73.13-1.44.34-2.1V7.07H2.18A11 11 0 0 0 1 12c0 1.78.43 3.47 1.18 4.93l3.66-2.83z"}),e.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1A11 11 0 0 0 2.18 7.07l3.66 2.83C6.71 7.31 9.14 5.38 12 5.38z"})]}),"Mit Google fortfahren"]}),e.jsxs("div",{className:"my-5 flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsx("span",{className:"h-px flex-1 bg-border"}),"oder mit E-Mail",e.jsx("span",{className:"h-px flex-1 bg-border"})]}),e.jsxs("form",{onSubmit:j,className:"space-y-4",children:[r==="signup"&&e.jsxs("div",{children:[e.jsx(N,{htmlFor:"name",children:"Anzeigename"}),e.jsx(z,{id:"name",autoComplete:"nickname",value:p,onChange:t=>d(t.target.value),placeholder:"Dein Name auf der Bestenliste"})]}),e.jsxs("div",{children:[e.jsx(N,{htmlFor:"email",children:"E-Mail"}),e.jsx(z,{id:"email",type:"email",autoComplete:"email",value:l,onChange:t=>m(t.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(N,{htmlFor:"password",children:"Passwort"}),e.jsx(z,{id:"password",type:"password",autoComplete:r==="signup"?"new-password":"current-password",value:u,onChange:t=>E(t.target.value),required:!0}),r==="signup"&&e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Mind. 8 Zeichen. Bekannte unsichere Passwörter werden abgelehnt."}),r==="signin"&&e.jsx("button",{type:"button",onClick:k,disabled:f,className:"mt-1 text-xs font-semibold text-primary hover:underline",children:"Passwort vergessen?"})]}),r==="signup"&&e.jsxs("div",{className:"flex items-start gap-3 rounded-2xl border border-border bg-muted/30 p-3",children:[e.jsx(O,{id:"consent",checked:g,onCheckedChange:t=>A(t===!0),className:"mt-0.5"}),e.jsxs(N,{htmlFor:"consent",className:"text-xs font-normal leading-relaxed text-muted-foreground",children:["Ich habe die"," ",e.jsx("a",{href:"/datenschutz",target:"_blank",rel:"noopener noreferrer",className:"font-semibold text-primary underline",children:"Datenschutzhinweise"})," ","gelesen und stimme der dort beschriebenen Verarbeitung meiner Daten zur Nutzung der App zu. Die"," ",e.jsx("a",{href:"/agb",target:"_blank",rel:"noopener noreferrer",className:"font-semibold text-primary underline",children:"AGB"})," ","akzeptiere ich. Meine Einwilligung kann ich jederzeit widerrufen."]})]}),e.jsx(M,{type:"submit",className:"w-full rounded-full",disabled:f||r==="signup"&&!g,children:f?"...":r==="signin"?"Anmelden":"Konto erstellen"})]}),e.jsxs("p",{className:"mt-5 text-center text-sm text-muted-foreground",children:[r==="signin"?"Noch kein Konto?":"Schon registriert?"," ",e.jsx("button",{onClick:()=>i(r==="signin"?"signup":"signin"),className:"font-semibold text-primary hover:underline",children:r==="signin"?"Jetzt registrieren":"Anmelden"})]})]}),e.jsxs("p",{className:"mt-5 text-center text-xs text-muted-foreground",children:["Mit der Registrierung akzeptierst du unsere ",e.jsx("a",{href:"/agb",className:"underline",children:"AGB"})," und"," ",e.jsx("a",{href:"/datenschutz",className:"underline",children:"Datenschutzerklärung"}),"."]})]})})})}export{be 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.