import{k as Fe,r as B,j as d,c as _}from"./index-DdrBheBF.js";var O={},Ue=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},ye={},S={};let ce;const ze=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];S.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17};S.getSymbolTotalCodewords=function(t){return ze[t]};S.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};S.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');ce=t};S.isKanjiModeEnabled=function(){return typeof ce<"u"};S.toSJIS=function(t){return ce(t)};var W={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+o)}}e.isValid=function(n){return n&&typeof n.bit<"u"&&n.bit>=0&&n.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})(W);function Ne(){this.buffer=[],this.length=0}Ne.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let o=0;o>>t-o-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var Ke=Ne;function Y(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}Y.prototype.set=function(e,t,o,n){const r=e*this.size+t;this.data[r]=o,n&&(this.reservedBit[r]=!0)};Y.prototype.get=function(e,t){return this.data[e*this.size+t]};Y.prototype.xor=function(e,t,o){this.data[e*this.size+t]^=o};Y.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var Ve=Y,Ce={};(function(e){const t=S.getSymbolSize;e.getRowColCoords=function(n){if(n===1)return[];const r=Math.floor(n/7)+2,s=t(n),i=s===145?26:Math.ceil((s-13)/(2*r-2))*2,l=[s-7];for(let a=1;a=0&&r<=7},e.from=function(r){return e.isValid(r)?parseInt(r,10):void 0},e.getPenaltyN1=function(r){const s=r.size;let i=0,l=0,a=0,u=null,c=null;for(let y=0;y=5&&(i+=t.N1+(l-5)),u=h,l=1),h=r.get(p,y),h===c?a++:(a>=5&&(i+=t.N1+(a-5)),c=h,a=1)}l>=5&&(i+=t.N1+(l-5)),a>=5&&(i+=t.N1+(a-5))}return i},e.getPenaltyN2=function(r){const s=r.size;let i=0;for(let l=0;l=10&&(l===1488||l===93)&&i++,a=a<<1&2047|r.get(c,u),c>=10&&(a===1488||a===93)&&i++}return i*t.N3},e.getPenaltyN4=function(r){let s=0;const i=r.data.length;for(let a=0;a=0;){const i=s[0];for(let a=0;a0){const s=new Uint8Array(this.degree);return s.set(n,r),s}return n};var Je=fe,je={},L={},he={};he.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var T={};const Se="[0-9]+",Oe="[A-Z $%*+\\-./:]+";let J="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";J=J.replace(/u/g,"\\u");const Ye="(?:(?![A-Z0-9 $%*+\\-./:]|"+J+`)(?:.|[\r ]))+`;T.KANJI=new RegExp(J,"g");T.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");T.BYTE=new RegExp(Ye,"g");T.NUMERIC=new RegExp(Se,"g");T.ALPHANUMERIC=new RegExp(Oe,"g");const $e=new RegExp("^"+J+"$"),qe=new RegExp("^"+Se+"$"),Ge=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");T.testKanji=function(t){return $e.test(t)};T.testNumeric=function(t){return qe.test(t)};T.testAlphanumeric=function(t){return Ge.test(t)};(function(e){const t=he,o=T;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(s,i){if(!s.ccBits)throw new Error("Invalid mode: "+s);if(!t.isValid(i))throw new Error("Invalid version: "+i);return i>=1&&i<10?s.ccBits[0]:i<27?s.ccBits[1]:s.ccBits[2]},e.getBestModeForData=function(s){return o.testNumeric(s)?e.NUMERIC:o.testAlphanumeric(s)?e.ALPHANUMERIC:o.testKanji(s)?e.KANJI:e.BYTE},e.toString=function(s){if(s&&s.id)return s.id;throw new Error("Invalid mode")},e.isValid=function(s){return s&&s.bit&&s.ccBits};function n(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+r)}}e.from=function(s,i){if(e.isValid(s))return s;try{return n(s)}catch{return i}}})(L);(function(e){const t=S,o=Z,n=W,r=L,s=he,i=7973,l=t.getBCHDigit(i);function a(p,h,w){for(let x=1;x<=40;x++)if(h<=e.getCapacity(x,w,p))return x}function u(p,h){return r.getCharCountIndicator(p,h)+4}function c(p,h){let w=0;return p.forEach(function(x){const k=u(x.mode,h);w+=k+x.getBitsLength()}),w}function y(p,h){for(let w=1;w<=40;w++)if(c(p,w)<=e.getCapacity(w,h,r.MIXED))return w}e.from=function(h,w){return s.isValid(h)?parseInt(h,10):w},e.getCapacity=function(h,w,x){if(!s.isValid(h))throw new Error("Invalid QR Code version");typeof x>"u"&&(x=r.BYTE);const k=t.getSymbolTotalCodewords(h),g=o.getTotalCodewordsCount(h,w),f=(k-g)*8;if(x===r.MIXED)return f;const m=f-u(x,h);switch(x){case r.NUMERIC:return Math.floor(m/10*3);case r.ALPHANUMERIC:return Math.floor(m/11*2);case r.KANJI:return Math.floor(m/13);case r.BYTE:default:return Math.floor(m/8)}},e.getBestVersionForData=function(h,w){let x;const k=n.from(w,n.M);if(Array.isArray(h)){if(h.length>1)return y(h,k);if(h.length===0)return 1;x=h[0]}else x=h;return a(x.mode,x.getLength(),k)},e.getEncodedBits=function(h){if(!s.isValid(h)||h<7)throw new Error("Invalid QR Code version");let w=h<<12;for(;t.getBCHDigit(w)-l>=0;)w^=i<=0;)r^=Pe<0&&(n=this.data.substr(o),r=parseInt(n,10),t.put(r,s*3+1))};var Ze=F;const Xe=L,te=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function U(e){this.mode=Xe.ALPHANUMERIC,this.data=e}U.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};U.prototype.getLength=function(){return this.data.length};U.prototype.getBitsLength=function(){return U.getBitsLength(this.data.length)};U.prototype.write=function(t){let o;for(o=0;o+2<=this.data.length;o+=2){let n=te.indexOf(this.data[o])*45;n+=te.indexOf(this.data[o+1]),t.put(n,11)}this.data.length%2&&t.put(te.indexOf(this.data[o]),6)};var et=U;const tt=L;function z(e){this.mode=tt.BYTE,typeof e=="string"?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}z.getBitsLength=function(t){return t*8};z.prototype.getLength=function(){return this.data.length};z.prototype.getBitsLength=function(){return z.getBitsLength(this.data.length)};z.prototype.write=function(e){for(let t=0,o=this.data.length;t=33088&&o<=40956)o-=33088;else if(o>=57408&&o<=60351)o-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+` Make sure your charset is UTF-8`);o=(o>>>8&255)*192+(o&255),e.put(o,13)}};var ot=K,Ie={exports:{}};(function(e){var t={single_source_shortest_paths:function(o,n,r){var s={},i={};i[n]=0;var l=t.PriorityQueue.make();l.push(n,0);for(var a,u,c,y,p,h,w,x,k;!l.empty();){a=l.pop(),u=a.value,y=a.cost,p=o[u]||{};for(c in p)p.hasOwnProperty(c)&&(h=p[c],w=y+h,x=i[c],k=typeof i[c]>"u",(k||x>w)&&(i[c]=w,l.push(c,w),s[c]=u))}if(typeof r<"u"&&typeof i[r]>"u"){var g=["Could not find a path from ",n," to ",r,"."].join("");throw new Error(g)}return s},extract_shortest_path_from_predecessor_list:function(o,n){for(var r=[],s=n;s;)r.push(s),o[s],s=o[s];return r.reverse(),r},find_path:function(o,n,r){var s=t.single_source_shortest_paths(o,n,r);return t.extract_shortest_path_from_predecessor_list(s,r)},PriorityQueue:{make:function(o){var n=t.PriorityQueue,r={},s;o=o||{};for(s in n)n.hasOwnProperty(s)&&(r[s]=n[s]);return r.queue=[],r.sorter=o.sorter||n.default_sorter,r},default_sorter:function(o,n){return o.cost-n.cost},push:function(o,n){var r={value:o,cost:n};this.queue.push(r),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(Ie);var it=Ie.exports;(function(e){const t=L,o=Ze,n=et,r=nt,s=ot,i=T,l=S,a=it;function u(g){return unescape(encodeURIComponent(g)).length}function c(g,f,m){const b=[];let N;for(;(N=g.exec(m))!==null;)b.push({data:N[0],index:N.index,mode:f,length:N[0].length});return b}function y(g){const f=c(i.NUMERIC,t.NUMERIC,g),m=c(i.ALPHANUMERIC,t.ALPHANUMERIC,g);let b,N;return l.isKanjiModeEnabled()?(b=c(i.BYTE,t.BYTE,g),N=c(i.KANJI,t.KANJI,g)):(b=c(i.BYTE_KANJI,t.BYTE,g),N=[]),f.concat(m,b,N).sort(function(A,j){return A.index-j.index}).map(function(A){return{data:A.data,mode:A.mode,length:A.length}})}function p(g,f){switch(f){case t.NUMERIC:return o.getBitsLength(g);case t.ALPHANUMERIC:return n.getBitsLength(g);case t.KANJI:return s.getBitsLength(g);case t.BYTE:return r.getBitsLength(g)}}function h(g){return g.reduce(function(f,m){const b=f.length-1>=0?f[f.length-1]:null;return b&&b.mode===m.mode?(f[f.length-1].data+=m.data,f):(f.push(m),f)},[])}function w(g){const f=[];for(let m=0;m=0&&l<=6&&(a===0||a===6)||a>=0&&a<=6&&(l===0||l===6)||l>=2&&l<=4&&a>=2&&a<=4?e.set(s+l,i+a,!0,!0):e.set(s+l,i+a,!1,!0))}}function mt(e){const t=e.size;for(let o=8;o>l&1)===1,e.set(r,s,i,!0),e.set(s,r,i,!0)}function se(e,t,o){const n=e.size,r=ft.getEncodedBits(t,o);let s,i;for(s=0;s<15;s++)i=(r>>s&1)===1,s<6?e.set(s,8,i,!0):s<8?e.set(s+1,8,i,!0):e.set(n-15+s,8,i,!0),s<8?e.set(8,n-s-1,i,!0):s<9?e.set(8,15-s-1+1,i,!0):e.set(8,15-s-1,i,!0);e.set(n-8,8,1,!0)}function wt(e,t){const o=e.size;let n=-1,r=o-1,s=7,i=0;for(let l=o-1;l>0;l-=2)for(l===6&&l--;;){for(let a=0;a<2;a++)if(!e.isReserved(r,l-a)){let u=!1;i>>s&1)===1),e.set(r,l-a,u),s--,s===-1&&(i++,s=7)}if(r+=n,r<0||o<=r){r-=n,n=-n;break}}}function xt(e,t,o){const n=new at;o.forEach(function(a){n.put(a.mode.bit,4),n.put(a.getLength(),ht.getCharCountIndicator(a.mode,e)),a.write(n)});const r=ee.getSymbolTotalCodewords(e),s=de.getTotalCodewordsCount(e,t),i=(r-s)*8;for(n.getLengthInBits()+4<=i&&n.put(0,4);n.getLengthInBits()%8!==0;)n.putBit(0);const l=(i-n.getLengthInBits())/8;for(let a=0;a=7&&pt(a,t),wt(a,i),isNaN(n)&&(n=le.getBestMask(a,se.bind(null,a,o))),le.applyMask(n,a),se(a,o,n),{modules:a,version:t,errorCorrectionLevel:o,maskPattern:n,segments:r}}ye.create=function(t,o){if(typeof t>"u"||t==="")throw new Error("No input text");let n=ne.M,r,s;return typeof o<"u"&&(n=ne.from(o.errorCorrectionLevel,ne.M),r=Q.from(o.version),s=le.from(o.maskPattern),o.toSJISFunc&&ee.setToSJISFunction(o.toSJISFunc)),Nt(t,r,n,s)};var Te={},ge={};(function(e){function t(o){if(typeof o=="number"&&(o=o.toString()),typeof o!="string")throw new Error("Color should be defined as hex string");let n=o.slice().replace("#","").split("");if(n.length<3||n.length===5||n.length>8)throw new Error("Invalid hex color: "+o);(n.length===3||n.length===4)&&(n=Array.prototype.concat.apply([],n.map(function(s){return[s,s]}))),n.length===6&&n.push("F","F");const r=parseInt(n.join(""),16);return{r:r>>24&255,g:r>>16&255,b:r>>8&255,a:r&255,hex:"#"+n.slice(0,6).join("")}}e.getOptions=function(n){n||(n={}),n.color||(n.color={});const r=typeof n.margin>"u"||n.margin===null||n.margin<0?4:n.margin,s=n.width&&n.width>=21?n.width:void 0,i=n.scale||4;return{width:s,scale:s?4:i,margin:r,color:{dark:t(n.color.dark||"#000000ff"),light:t(n.color.light||"#ffffffff")},type:n.type,rendererOpts:n.rendererOpts||{}}},e.getScale=function(n,r){return r.width&&r.width>=n+r.margin*2?r.width/(n+r.margin*2):r.scale},e.getImageWidth=function(n,r){const s=e.getScale(n,r);return Math.floor((n+r.margin*2)*s)},e.qrToImageData=function(n,r,s){const i=r.modules.size,l=r.modules.data,a=e.getScale(i,s),u=Math.floor((i+s.margin*2)*a),c=s.margin*a,y=[s.color.light,s.color.dark];for(let p=0;p=c&&h>=c&&p"u"&&(!i||!i.getContext)&&(a=i,i=void 0),i||(u=n()),a=t.getOptions(a);const c=t.getImageWidth(s.modules.size,a),y=u.getContext("2d"),p=y.createImageData(c,c);return t.qrToImageData(p.data,s,a),o(y,u,c),y.putImageData(p,0,0),u},e.renderToDataURL=function(s,i,l){let a=l;typeof a>"u"&&(!i||!i.getContext)&&(a=i,i=void 0),a||(a={});const u=e.render(s,i,a),c=a.type||"image/png",y=a.rendererOpts||{};return u.toDataURL(c,y.quality)}})(Te);var _e={};const Ct=ge;function we(e,t){const o=e.a/255,n=t+'="'+e.hex+'"';return o<1?n+" "+t+'-opacity="'+o.toFixed(2).slice(1)+'"':n}function oe(e,t,o){let n=e+t;return typeof o<"u"&&(n+=" "+o),n}function Et(e,t,o){let n="",r=0,s=!1,i=0;for(let l=0;l0&&a>0&&e[l-1]||(n+=s?oe("M",a+o,.5+u+o):oe("m",r,0),r=0,s=!1),a+1':"",u="',c='viewBox="0 0 '+l+" "+l+'"',p=''+a+u+` `;return typeof n=="function"&&n(null,p),p};const kt=Ue,ue=ye,Re=Te,At=_e;function me(e,t,o,n,r){const s=[].slice.call(arguments,1),i=s.length,l=typeof s[i-1]=="function";if(!l&&!kt())throw new Error("Callback required as last argument");if(l){if(i<2)throw new Error("Too few arguments provided");i===2?(r=o,o=t,t=n=void 0):i===3&&(t.getContext&&typeof r>"u"?(r=n,n=void 0):(r=n,n=o,o=t,t=void 0))}else{if(i<1)throw new Error("Too few arguments provided");return i===1?(o=t,t=n=void 0):i===2&&!t.getContext&&(n=o,o=t,t=void 0),new Promise(function(a,u){try{const c=ue.create(o,n);a(e(c,t,n))}catch(c){u(c)}})}try{const a=ue.create(o,n);r(null,e(a,t,n))}catch(a){r(a)}}O.create=ue.create;O.toCanvas=me.bind(null,Re.render);O.toDataURL=me.bind(null,Re.renderToDataURL);O.toString=me.bind(null,function(e,t,o){return At.render(e,o)});const xe={current_password:"",new_password:"",new_password_confirmation:"",two_factor_code:""},ie="w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm dark:border-neutral-700 dark:bg-neutral-900";function Bt({user:e,refreshUser:t}){const[o,n]=B.useState("idle"),[r,s]=B.useState(""),[i,l]=B.useState(""),[a,u]=B.useState(""),[c,y]=B.useState(""),[p,h]=B.useState(!1),w=async(f,m)=>{u(""),y(""),h(!0);try{await f(),await t(),n("idle"),l(""),m&&y(m)}catch(b){u(b.message)}finally{h(!1)}},x=f=>{f.preventDefault(),w(()=>_.post("/auth/email",{email:r,password:i}),`Bestätigungslink an ${r} gesendet. Die Adresse gilt erst nach dem Klick darauf.`)},k=f=>{f.preventDefault(),w(()=>_.post("/auth/email/remove",{password:i}),"E-Mail-Adresse entfernt.")},g=()=>{n("idle"),l(""),u("")};return d.jsxs("div",{className:"mb-6 rounded-xl border border-neutral-200 bg-white p-6 dark:border-neutral-800 dark:bg-neutral-900",children:[d.jsx("h2",{className:"mb-1 font-semibold text-neutral-900 dark:text-white",children:"E-Mail-Adresse"}),d.jsx("p",{className:"mb-4 text-sm text-neutral-500 dark:text-neutral-400",children:e!=null&&e.two_factor_enabled?"Da die Authenticator-App aktiv ist, wird beim Login sie abgefragt, nicht die E-Mail.":"Mit bestätigter Adresse bekommst du beim Login einen Code per Mail, den du zusätzlich zum Passwort eingibst."}),o==="idle"&&d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"mb-2 text-sm",children:e!=null&&e.email&&(e!=null&&e.email_verified)?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"font-medium text-neutral-800 dark:text-neutral-100",children:e.email})," ",d.jsx("span",{className:"font-semibold text-green-600 dark:text-green-400",children:"· bestätigt"})]}):d.jsx("span",{className:"text-neutral-500 dark:text-neutral-400",children:"Keine E-Mail-Adresse hinterlegt."})}),(e==null?void 0:e.pending_email)&&d.jsxs("div",{className:"mb-4 rounded-md border border-amber-200 bg-amber-50 p-3 text-sm text-amber-800 dark:border-amber-900/50 dark:bg-amber-900/20 dark:text-amber-300",children:[d.jsx("strong",{children:e.pending_email})," wartet auf Bestätigung. Klick auf den Link in der Mail.",d.jsxs("div",{className:"mt-2 flex flex-wrap gap-3",children:[d.jsx("button",{type:"button",disabled:p,onClick:()=>w(()=>_.post("/auth/email/resend",{}),`Neuer Link an ${e.pending_email} gesendet.`),className:"font-medium hover:underline disabled:opacity-60",children:"Link erneut senden"}),d.jsx("button",{type:"button",disabled:p,onClick:()=>w(()=>_.post("/auth/email/cancel",{})),className:"font-medium hover:underline disabled:opacity-60",children:"Änderung verwerfen"})]})]}),c&&d.jsx("p",{className:"mb-4 text-sm text-green-600 dark:text-green-400",children:c}),a&&d.jsx("p",{className:"mb-4 text-sm text-red-600",children:a}),d.jsxs("div",{className:"flex flex-wrap gap-2",children:[d.jsx("button",{onClick:()=>{n("edit"),s(""),u(""),y("")},className:"rounded-md bg-brand-500 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-600",children:e!=null&&e.email?"E-Mail-Adresse ändern":"E-Mail-Adresse hinterlegen"}),((e==null?void 0:e.email)||(e==null?void 0:e.pending_email))&&d.jsx("button",{onClick:()=>{n("remove"),u(""),y("")},className:"rounded-md border border-red-300 px-4 py-2 text-sm font-medium text-red-600 hover:bg-red-50 dark:border-red-900 dark:hover:bg-red-900/20",children:"Entfernen"})]})]}),o==="edit"&&d.jsxs("form",{onSubmit:x,children:[d.jsxs("div",{className:"mb-4",children:[d.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Neue E-Mail-Adresse"}),d.jsx("input",{type:"email",value:r,onChange:f=>s(f.target.value),required:!0,autoFocus:!0,className:ie})]}),d.jsxs("div",{className:"mb-4",children:[d.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Passwort zur Bestätigung"}),d.jsx("input",{type:"password",value:i,onChange:f=>l(f.target.value),required:!0,className:ie})]}),a&&d.jsx("p",{className:"mb-4 text-sm text-red-600",children:a}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{type:"submit",disabled:p,className:"rounded-md bg-brand-500 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-600 disabled:opacity-60",children:p?"Wird gesendet…":"Bestätigungslink senden"}),d.jsx("button",{type:"button",onClick:g,className:"rounded-md border border-neutral-300 px-4 py-2 text-sm dark:border-neutral-700",children:"Abbrechen"})]})]}),o==="remove"&&d.jsxs("form",{onSubmit:k,children:[d.jsx("p",{className:"mb-3 text-sm text-neutral-500 dark:text-neutral-400",children:"Ohne E-Mail-Adresse (und ohne Authenticator-App) reicht beim Login wieder das Passwort."}),d.jsxs("div",{className:"mb-4",children:[d.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Passwort zur Bestätigung"}),d.jsx("input",{type:"password",value:i,onChange:f=>l(f.target.value),required:!0,autoFocus:!0,className:ie})]}),a&&d.jsx("p",{className:"mb-4 text-sm text-red-600",children:a}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{type:"submit",disabled:p,className:"rounded-md bg-red-600 px-4 py-2 text-sm font-semibold text-white hover:bg-red-700 disabled:opacity-60",children:"E-Mail-Adresse entfernen"}),d.jsx("button",{type:"button",onClick:g,className:"rounded-md border border-neutral-300 px-4 py-2 text-sm dark:border-neutral-700",children:"Abbrechen"})]})]})]})}function St(){const{user:e,refreshUser:t}=Fe(),[o,n]=B.useState("idle"),[r,s]=B.useState(""),[i,l]=B.useState(""),[a,u]=B.useState(""),[c,y]=B.useState(""),[p,h]=B.useState([]),[w,x]=B.useState(""),[k,g]=B.useState(!1),[f,m]=B.useState(xe),[b,N]=B.useState(""),[E,A]=B.useState(""),[j,P]=B.useState(!1),v=async C=>{if(C.preventDefault(),N(""),A(""),f.new_password!==f.new_password_confirmation){N("Die neuen Passwörter stimmen nicht überein");return}P(!0);try{await _.post("/auth/change-password",f),m(xe),A("Passwort erfolgreich geändert.")}catch(I){N(I.message)}finally{P(!1)}},D=async()=>{x(""),g(!0);try{const C=await _.get("/auth/2fa/setup");l(C.secret),s(await O.toDataURL(C.otpauth_url)),u(""),n("setup")}catch(C){x(C.message)}finally{g(!1)}},V=async C=>{C.preventDefault(),x(""),g(!0);try{const I=await _.post("/auth/2fa/enable",{code:a});h(I.recovery_codes),n("recovery-codes"),await t()}catch(I){x(I.message)}finally{g(!1)}},M=()=>{n("idle"),h([]),y("")},Le=async C=>{C.preventDefault(),x(""),g(!0);try{await _.post("/auth/2fa/disable",{password:c}),y(""),n("idle"),await t()}catch(I){x(I.message)}finally{g(!1)}},De=async C=>{C.preventDefault(),x(""),g(!0);try{const I=await _.post("/auth/2fa/recovery-codes",{password:c});h(I.recovery_codes),n("recovery-codes")}catch(I){x(I.message)}finally{g(!1)}};return d.jsxs("div",{className:"max-w-xl",children:[d.jsx("h1",{className:"mb-1 text-xl font-bold text-neutral-900 dark:text-white",children:"Mein Konto"}),d.jsxs("p",{className:"mb-6 text-sm text-neutral-500 dark:text-neutral-400",children:["Angemeldet als ",d.jsx("strong",{children:e==null?void 0:e.username}),e!=null&&e.is_super_admin?" (Super-Admin)":"","."]}),d.jsx(Bt,{user:e,refreshUser:t}),d.jsxs("div",{className:"mb-6 rounded-xl border border-neutral-200 bg-white p-6 dark:border-neutral-800 dark:bg-neutral-900",children:[d.jsx("h2",{className:"mb-1 font-semibold text-neutral-900 dark:text-white",children:"Passwort ändern"}),d.jsxs("p",{className:"mb-4 text-sm text-neutral-500 dark:text-neutral-400",children:["Vergib ein neues Passwort für dein Konto.",(e==null?void 0:e.two_factor_enabled)&&" Da 2FA aktiv ist, musst du die Änderung zusätzlich mit deinem Code bestätigen."]}),d.jsxs("form",{onSubmit:v,children:[d.jsxs("div",{className:"mb-4",children:[d.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Aktuelles Passwort"}),d.jsx("input",{type:"password",value:f.current_password,onChange:C=>m({...f,current_password:C.target.value}),required:!0,className:"w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm dark:border-neutral-700 dark:bg-neutral-900"})]}),d.jsxs("div",{className:"mb-4",children:[d.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Neues Passwort"}),d.jsx("input",{type:"password",value:f.new_password,onChange:C=>m({...f,new_password:C.target.value}),required:!0,minLength:8,className:"w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm dark:border-neutral-700 dark:bg-neutral-900"})]}),d.jsxs("div",{className:"mb-4",children:[d.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Neues Passwort wiederholen"}),d.jsx("input",{type:"password",value:f.new_password_confirmation,onChange:C=>m({...f,new_password_confirmation:C.target.value}),required:!0,minLength:8,className:"w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm dark:border-neutral-700 dark:bg-neutral-900"})]}),(e==null?void 0:e.two_factor_enabled)&&d.jsxs("div",{className:"mb-4",children:[d.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"2FA-Code zur Bestätigung"}),d.jsx("input",{value:f.two_factor_code,onChange:C=>m({...f,two_factor_code:C.target.value}),required:!0,inputMode:"numeric",placeholder:"123456 oder Wiederherstellungscode",className:"w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm dark:border-neutral-700 dark:bg-neutral-900"})]}),b&&d.jsx("p",{className:"mb-4 text-sm text-red-600",children:b}),E&&d.jsx("p",{className:"mb-4 text-sm text-green-600 dark:text-green-400",children:E}),d.jsx("button",{type:"submit",disabled:j,className:"rounded-md bg-brand-500 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-600 disabled:opacity-60",children:j?"Wird geändert…":"Passwort ändern"})]})]}),d.jsxs("div",{className:"rounded-xl border border-neutral-200 bg-white p-6 dark:border-neutral-800 dark:bg-neutral-900",children:[d.jsx("h2",{className:"mb-1 font-semibold text-neutral-900 dark:text-white",children:"Zwei-Faktor-Authentifizierung"}),d.jsx("p",{className:"mb-4 text-sm text-neutral-500 dark:text-neutral-400",children:"Schützt dein Konto zusätzlich mit einem Code aus der Google Authenticator App."}),o==="idle"&&d.jsxs(d.Fragment,{children:[d.jsxs("p",{className:"mb-4 text-sm",children:["Status:"," ",e!=null&&e.two_factor_enabled?d.jsx("span",{className:"font-semibold text-green-600 dark:text-green-400",children:"Aktiv"}):d.jsx("span",{className:"font-semibold text-neutral-500 dark:text-neutral-400",children:"Nicht aktiv"})]}),e!=null&&e.two_factor_enabled?d.jsxs("div",{className:"flex flex-wrap gap-2",children:[d.jsx("button",{onClick:()=>{n("regenerate"),x("")},className:"rounded-md border border-neutral-300 px-4 py-2 text-sm font-medium hover:bg-neutral-50 dark:border-neutral-700 dark:hover:bg-neutral-800",children:"Neue Wiederherstellungscodes erzeugen"}),d.jsx("button",{onClick:()=>{n("disable"),x("")},className:"rounded-md border border-red-300 px-4 py-2 text-sm font-medium text-red-600 hover:bg-red-50 dark:border-red-900 dark:hover:bg-red-900/20",children:"2FA deaktivieren"})]}):d.jsx("button",{onClick:D,disabled:k,className:"rounded-md bg-brand-500 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-600 disabled:opacity-60",children:"2FA aktivieren"})]}),o==="setup"&&d.jsxs("form",{onSubmit:V,children:[d.jsxs("ol",{className:"mb-4 list-decimal space-y-2 pl-5 text-sm text-neutral-700 dark:text-neutral-300",children:[d.jsx("li",{children:"Öffne die Google Authenticator App (oder eine kompatible App)."}),d.jsx("li",{children:"Scanne den folgenden QR-Code:"})]}),d.jsx("div",{className:"mb-4 flex justify-center",children:r&&d.jsx("img",{src:r,alt:"QR-Code für Zwei-Faktor-Authentifizierung",className:"h-48 w-48 rounded-lg border border-neutral-200 dark:border-neutral-700"})}),d.jsxs("p",{className:"mb-4 text-center text-xs text-neutral-500 dark:text-neutral-400",children:["Geht das Scannen nicht? Gib diesen Code manuell ein: ",d.jsx("br",{}),d.jsx("code",{className:"mt-1 inline-block rounded bg-neutral-100 px-2 py-1 font-mono tracking-wider dark:bg-neutral-800",children:i})]}),d.jsxs("div",{className:"mb-4",children:[d.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Bestätigungscode aus der App"}),d.jsx("input",{value:a,onChange:C=>u(C.target.value),required:!0,autoFocus:!0,inputMode:"numeric",placeholder:"123456",className:"w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-center text-lg tracking-widest dark:border-neutral-700 dark:bg-neutral-900"})]}),w&&d.jsx("p",{className:"mb-4 text-sm text-red-600",children:w}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{type:"submit",disabled:k,className:"rounded-md bg-brand-500 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-600 disabled:opacity-60",children:"Bestätigen & aktivieren"}),d.jsx("button",{type:"button",onClick:()=>n("idle"),className:"rounded-md border border-neutral-300 px-4 py-2 text-sm dark:border-neutral-700",children:"Abbrechen"})]})]}),o==="recovery-codes"&&d.jsxs("div",{children:[d.jsx("p",{className:"mb-3 text-sm font-semibold text-neutral-900 dark:text-white",children:"Wiederherstellungscodes – jetzt sicher speichern!"}),d.jsx("p",{className:"mb-3 text-sm text-neutral-500 dark:text-neutral-400",children:"Jeder Code funktioniert einmalig, falls du keinen Zugriff mehr auf die Authenticator-App hast. Diese Codes werden nur jetzt angezeigt."}),d.jsx("div",{className:"mb-4 grid grid-cols-2 gap-2 rounded-md bg-neutral-100 p-4 font-mono text-sm dark:bg-neutral-800",children:p.map(C=>d.jsx("span",{children:C},C))}),d.jsx("button",{onClick:M,className:"rounded-md bg-brand-500 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-600",children:"Ich habe die Codes gespeichert"})]}),o==="disable"&&d.jsxs("form",{onSubmit:Le,children:[d.jsxs("div",{className:"mb-4",children:[d.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Passwort zur Bestätigung"}),d.jsx("input",{type:"password",value:c,onChange:C=>y(C.target.value),required:!0,autoFocus:!0,className:"w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm dark:border-neutral-700 dark:bg-neutral-900"})]}),w&&d.jsx("p",{className:"mb-4 text-sm text-red-600",children:w}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{type:"submit",disabled:k,className:"rounded-md bg-red-600 px-4 py-2 text-sm font-semibold text-white hover:bg-red-700 disabled:opacity-60",children:"2FA jetzt deaktivieren"}),d.jsx("button",{type:"button",onClick:()=>{n("idle"),y("")},className:"rounded-md border border-neutral-300 px-4 py-2 text-sm dark:border-neutral-700",children:"Abbrechen"})]})]}),o==="regenerate"&&d.jsxs("form",{onSubmit:De,children:[d.jsx("p",{className:"mb-3 text-sm text-neutral-500 dark:text-neutral-400",children:"Die bisherigen Wiederherstellungscodes werden ungültig."}),d.jsxs("div",{className:"mb-4",children:[d.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Passwort zur Bestätigung"}),d.jsx("input",{type:"password",value:c,onChange:C=>y(C.target.value),required:!0,autoFocus:!0,className:"w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm dark:border-neutral-700 dark:bg-neutral-900"})]}),w&&d.jsx("p",{className:"mb-4 text-sm text-red-600",children:w}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{type:"submit",disabled:k,className:"rounded-md bg-brand-500 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-600 disabled:opacity-60",children:"Neue Codes erzeugen"}),d.jsx("button",{type:"button",onClick:()=>{n("idle"),y("")},className:"rounded-md border border-neutral-300 px-4 py-2 text-sm dark:border-neutral-700",children:"Abbrechen"})]})]})]})]})}export{St as default};