Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0174bfXbDqAn2M7TjkdqGCrn
8 lines
34 KiB
JavaScript
8 lines
34 KiB
JavaScript
import{k as De,r as I,j as u,c as V}from"./index-BlspSYV0.js";var Y={},Fe=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},ye={},S={};let de;const Ue=[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 Ue[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.');de=t};S.isKanjiModeEnabled=function(){return typeof de<"u"};S.toSJIS=function(t){return de(t)};var W={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(s){if(typeof s!="string")throw new Error("Param is not a string");switch(s.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: "+s)}}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 xe(){this.buffer=[],this.length=0}xe.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 s=0;s<t;s++)this.putBit((e>>>t-s-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 ze=xe;function O(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)}O.prototype.set=function(e,t,s,n){const r=e*this.size+t;this.data[r]=s,n&&(this.reservedBit[r]=!0)};O.prototype.get=function(e,t){return this.data[e*this.size+t]};O.prototype.xor=function(e,t,s){this.data[e*this.size+t]^=s};O.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var Ke=O,Ce={};(function(e){const t=S.getSymbolSize;e.getRowColCoords=function(n){if(n===1)return[];const r=Math.floor(n/7)+2,o=t(n),i=o===145?26:Math.ceil((o-13)/(2*r-2))*2,l=[o-7];for(let a=1;a<r-1;a++)l[a]=l[a-1]-i;return l.push(6),l.reverse()},e.getPositions=function(n){const r=[],o=e.getRowColCoords(n),i=o.length;for(let l=0;l<i;l++)for(let a=0;a<i;a++)l===0&&a===0||l===0&&a===i-1||l===i-1&&a===0||r.push([o[l],o[a]]);return r}})(Ce);var Ne={};const Ve=S.getSymbolSize,me=7;Ne.getPositions=function(t){const s=Ve(t);return[[0,0],[s-me,0],[0,s-me]]};var Ee={};(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(r){return r!=null&&r!==""&&!isNaN(r)&&r>=0&&r<=7},e.from=function(r){return e.isValid(r)?parseInt(r,10):void 0},e.getPenaltyN1=function(r){const o=r.size;let i=0,l=0,a=0,c=null,d=null;for(let x=0;x<o;x++){l=a=0,c=d=null;for(let y=0;y<o;y++){let f=r.get(x,y);f===c?l++:(l>=5&&(i+=t.N1+(l-5)),c=f,l=1),f=r.get(y,x),f===d?a++:(a>=5&&(i+=t.N1+(a-5)),d=f,a=1)}l>=5&&(i+=t.N1+(l-5)),a>=5&&(i+=t.N1+(a-5))}return i},e.getPenaltyN2=function(r){const o=r.size;let i=0;for(let l=0;l<o-1;l++)for(let a=0;a<o-1;a++){const c=r.get(l,a)+r.get(l,a+1)+r.get(l+1,a)+r.get(l+1,a+1);(c===4||c===0)&&i++}return i*t.N2},e.getPenaltyN3=function(r){const o=r.size;let i=0,l=0,a=0;for(let c=0;c<o;c++){l=a=0;for(let d=0;d<o;d++)l=l<<1&2047|r.get(c,d),d>=10&&(l===1488||l===93)&&i++,a=a<<1&2047|r.get(d,c),d>=10&&(a===1488||a===93)&&i++}return i*t.N3},e.getPenaltyN4=function(r){let o=0;const i=r.data.length;for(let a=0;a<i;a++)o+=r.data[a];return Math.abs(Math.ceil(o*100/i/5)-10)*t.N4};function s(n,r,o){switch(n){case e.Patterns.PATTERN000:return(r+o)%2===0;case e.Patterns.PATTERN001:return r%2===0;case e.Patterns.PATTERN010:return o%3===0;case e.Patterns.PATTERN011:return(r+o)%3===0;case e.Patterns.PATTERN100:return(Math.floor(r/2)+Math.floor(o/3))%2===0;case e.Patterns.PATTERN101:return r*o%2+r*o%3===0;case e.Patterns.PATTERN110:return(r*o%2+r*o%3)%2===0;case e.Patterns.PATTERN111:return(r*o%3+(r+o)%2)%2===0;default:throw new Error("bad maskPattern:"+n)}}e.applyMask=function(r,o){const i=o.size;for(let l=0;l<i;l++)for(let a=0;a<i;a++)o.isReserved(a,l)||o.xor(a,l,s(r,a,l))},e.getBestMask=function(r,o){const i=Object.keys(e.Patterns).length;let l=0,a=1/0;for(let c=0;c<i;c++){o(c),e.applyMask(c,r);const d=e.getPenaltyN1(r)+e.getPenaltyN2(r)+e.getPenaltyN3(r)+e.getPenaltyN4(r);e.applyMask(c,r),d<a&&(a=d,l=c)}return l}})(Ee);var Z={};const v=W,$=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],q=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];Z.getBlocksCount=function(t,s){switch(s){case v.L:return $[(t-1)*4+0];case v.M:return $[(t-1)*4+1];case v.Q:return $[(t-1)*4+2];case v.H:return $[(t-1)*4+3];default:return}};Z.getTotalCodewordsCount=function(t,s){switch(s){case v.L:return q[(t-1)*4+0];case v.M:return q[(t-1)*4+1];case v.Q:return q[(t-1)*4+2];case v.H:return q[(t-1)*4+3];default:return}};var Be={},X={};const H=new Uint8Array(512),G=new Uint8Array(256);(function(){let t=1;for(let s=0;s<255;s++)H[s]=t,G[t]=s,t<<=1,t&256&&(t^=285);for(let s=255;s<512;s++)H[s]=H[s-255]})();X.log=function(t){if(t<1)throw new Error("log("+t+")");return G[t]};X.exp=function(t){return H[t]};X.mul=function(t,s){return t===0||s===0?0:H[G[t]+G[s]]};(function(e){const t=X;e.mul=function(n,r){const o=new Uint8Array(n.length+r.length-1);for(let i=0;i<n.length;i++)for(let l=0;l<r.length;l++)o[i+l]^=t.mul(n[i],r[l]);return o},e.mod=function(n,r){let o=new Uint8Array(n);for(;o.length-r.length>=0;){const i=o[0];for(let a=0;a<r.length;a++)o[a]^=t.mul(r[a],i);let l=0;for(;l<o.length&&o[l]===0;)l++;o=o.slice(l)}return o},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let o=0;o<n;o++)r=e.mul(r,new Uint8Array([1,t.exp(o)]));return r}})(Be);const Ae=Be;function ce(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}ce.prototype.initialize=function(t){this.degree=t,this.genPoly=Ae.generateECPolynomial(this.degree)};ce.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const s=new Uint8Array(t.length+this.degree);s.set(t);const n=Ae.mod(s,this.genPoly),r=this.degree-n.length;if(r>0){const o=new Uint8Array(this.degree);return o.set(n,r),o}return n};var He=ce,ke={},R={},fe={};fe.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var _={};const Se="[0-9]+",Je="[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
|
||
]))+`;_.KANJI=new RegExp(J,"g");_.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");_.BYTE=new RegExp(Ye,"g");_.NUMERIC=new RegExp(Se,"g");_.ALPHANUMERIC=new RegExp(Je,"g");const Oe=new RegExp("^"+J+"$"),$e=new RegExp("^"+Se+"$"),qe=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");_.testKanji=function(t){return Oe.test(t)};_.testNumeric=function(t){return $e.test(t)};_.testAlphanumeric=function(t){return qe.test(t)};(function(e){const t=fe,s=_;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(o,i){if(!o.ccBits)throw new Error("Invalid mode: "+o);if(!t.isValid(i))throw new Error("Invalid version: "+i);return i>=1&&i<10?o.ccBits[0]:i<27?o.ccBits[1]:o.ccBits[2]},e.getBestModeForData=function(o){return s.testNumeric(o)?e.NUMERIC:s.testAlphanumeric(o)?e.ALPHANUMERIC:s.testKanji(o)?e.KANJI:e.BYTE},e.toString=function(o){if(o&&o.id)return o.id;throw new Error("Invalid mode")},e.isValid=function(o){return o&&o.bit&&o.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(o,i){if(e.isValid(o))return o;try{return n(o)}catch{return i}}})(R);(function(e){const t=S,s=Z,n=W,r=R,o=fe,i=7973,l=t.getBCHDigit(i);function a(y,f,p){for(let w=1;w<=40;w++)if(f<=e.getCapacity(w,p,y))return w}function c(y,f){return r.getCharCountIndicator(y,f)+4}function d(y,f){let p=0;return y.forEach(function(w){const B=c(w.mode,f);p+=B+w.getBitsLength()}),p}function x(y,f){for(let p=1;p<=40;p++)if(d(y,p)<=e.getCapacity(p,f,r.MIXED))return p}e.from=function(f,p){return o.isValid(f)?parseInt(f,10):p},e.getCapacity=function(f,p,w){if(!o.isValid(f))throw new Error("Invalid QR Code version");typeof w>"u"&&(w=r.BYTE);const B=t.getSymbolTotalCodewords(f),h=s.getTotalCodewordsCount(f,p),b=(B-h)*8;if(w===r.MIXED)return b;const g=b-c(w,f);switch(w){case r.NUMERIC:return Math.floor(g/10*3);case r.ALPHANUMERIC:return Math.floor(g/11*2);case r.KANJI:return Math.floor(g/13);case r.BYTE:default:return Math.floor(g/8)}},e.getBestVersionForData=function(f,p){let w;const B=n.from(p,n.M);if(Array.isArray(f)){if(f.length>1)return x(f,B);if(f.length===0)return 1;w=f[0]}else w=f;return a(w.mode,w.getLength(),B)},e.getEncodedBits=function(f){if(!o.isValid(f)||f<7)throw new Error("Invalid QR Code version");let p=f<<12;for(;t.getBCHDigit(p)-l>=0;)p^=i<<t.getBCHDigit(p)-l;return f<<12|p}})(ke);var Pe={};const ie=S,Ie=1335,Ge=21522,be=ie.getBCHDigit(Ie);Pe.getEncodedBits=function(t,s){const n=t.bit<<3|s;let r=n<<10;for(;ie.getBCHDigit(r)-be>=0;)r^=Ie<<ie.getBCHDigit(r)-be;return(n<<10|r)^Ge};var Te={};const Qe=R;function D(e){this.mode=Qe.NUMERIC,this.data=e.toString()}D.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)};D.prototype.getLength=function(){return this.data.length};D.prototype.getBitsLength=function(){return D.getBitsLength(this.data.length)};D.prototype.write=function(t){let s,n,r;for(s=0;s+3<=this.data.length;s+=3)n=this.data.substr(s,3),r=parseInt(n,10),t.put(r,10);const o=this.data.length-s;o>0&&(n=this.data.substr(s),r=parseInt(n,10),t.put(r,o*3+1))};var We=D;const Ze=R,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 F(e){this.mode=Ze.ALPHANUMERIC,this.data=e}F.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};F.prototype.getLength=function(){return this.data.length};F.prototype.getBitsLength=function(){return F.getBitsLength(this.data.length)};F.prototype.write=function(t){let s;for(s=0;s+2<=this.data.length;s+=2){let n=te.indexOf(this.data[s])*45;n+=te.indexOf(this.data[s+1]),t.put(n,11)}this.data.length%2&&t.put(te.indexOf(this.data[s]),6)};var Xe=F;const et=R;function U(e){this.mode=et.BYTE,typeof e=="string"?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}U.getBitsLength=function(t){return t*8};U.prototype.getLength=function(){return this.data.length};U.prototype.getBitsLength=function(){return U.getBitsLength(this.data.length)};U.prototype.write=function(e){for(let t=0,s=this.data.length;t<s;t++)e.put(this.data[t],8)};var tt=U;const nt=R,rt=S;function z(e){this.mode=nt.KANJI,this.data=e}z.getBitsLength=function(t){return t*13};z.prototype.getLength=function(){return this.data.length};z.prototype.getBitsLength=function(){return z.getBitsLength(this.data.length)};z.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let s=rt.toSJIS(this.data[t]);if(s>=33088&&s<=40956)s-=33088;else if(s>=57408&&s<=60351)s-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+`
|
||
Make sure your charset is UTF-8`);s=(s>>>8&255)*192+(s&255),e.put(s,13)}};var ot=z,Me={exports:{}};(function(e){var t={single_source_shortest_paths:function(s,n,r){var o={},i={};i[n]=0;var l=t.PriorityQueue.make();l.push(n,0);for(var a,c,d,x,y,f,p,w,B;!l.empty();){a=l.pop(),c=a.value,x=a.cost,y=s[c]||{};for(d in y)y.hasOwnProperty(d)&&(f=y[d],p=x+f,w=i[d],B=typeof i[d]>"u",(B||w>p)&&(i[d]=p,l.push(d,p),o[d]=c))}if(typeof r<"u"&&typeof i[r]>"u"){var h=["Could not find a path from ",n," to ",r,"."].join("");throw new Error(h)}return o},extract_shortest_path_from_predecessor_list:function(s,n){for(var r=[],o=n;o;)r.push(o),s[o],o=s[o];return r.reverse(),r},find_path:function(s,n,r){var o=t.single_source_shortest_paths(s,n,r);return t.extract_shortest_path_from_predecessor_list(o,r)},PriorityQueue:{make:function(s){var n=t.PriorityQueue,r={},o;s=s||{};for(o in n)n.hasOwnProperty(o)&&(r[o]=n[o]);return r.queue=[],r.sorter=s.sorter||n.default_sorter,r},default_sorter:function(s,n){return s.cost-n.cost},push:function(s,n){var r={value:s,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})(Me);var st=Me.exports;(function(e){const t=R,s=We,n=Xe,r=tt,o=ot,i=_,l=S,a=st;function c(h){return unescape(encodeURIComponent(h)).length}function d(h,b,g){const m=[];let C;for(;(C=h.exec(g))!==null;)m.push({data:C[0],index:C.index,mode:b,length:C[0].length});return m}function x(h){const b=d(i.NUMERIC,t.NUMERIC,h),g=d(i.ALPHANUMERIC,t.ALPHANUMERIC,h);let m,C;return l.isKanjiModeEnabled()?(m=d(i.BYTE,t.BYTE,h),C=d(i.KANJI,t.KANJI,h)):(m=d(i.BYTE_KANJI,t.BYTE,h),C=[]),b.concat(g,m,C).sort(function(A,k){return A.index-k.index}).map(function(A){return{data:A.data,mode:A.mode,length:A.length}})}function y(h,b){switch(b){case t.NUMERIC:return s.getBitsLength(h);case t.ALPHANUMERIC:return n.getBitsLength(h);case t.KANJI:return o.getBitsLength(h);case t.BYTE:return r.getBitsLength(h)}}function f(h){return h.reduce(function(b,g){const m=b.length-1>=0?b[b.length-1]:null;return m&&m.mode===g.mode?(b[b.length-1].data+=g.data,b):(b.push(g),b)},[])}function p(h){const b=[];for(let g=0;g<h.length;g++){const m=h[g];switch(m.mode){case t.NUMERIC:b.push([m,{data:m.data,mode:t.ALPHANUMERIC,length:m.length},{data:m.data,mode:t.BYTE,length:m.length}]);break;case t.ALPHANUMERIC:b.push([m,{data:m.data,mode:t.BYTE,length:m.length}]);break;case t.KANJI:b.push([m,{data:m.data,mode:t.BYTE,length:c(m.data)}]);break;case t.BYTE:b.push([{data:m.data,mode:t.BYTE,length:c(m.data)}])}}return b}function w(h,b){const g={},m={start:{}};let C=["start"];for(let E=0;E<h.length;E++){const A=h[E],k=[];for(let T=0;T<A.length;T++){const P=A[T],L=""+E+T;k.push(L),g[L]={node:P,lastCount:0},m[L]={};for(let K=0;K<C.length;K++){const M=C[K];g[M]&&g[M].node.mode===P.mode?(m[M][L]=y(g[M].lastCount+P.length,P.mode)-y(g[M].lastCount,P.mode),g[M].lastCount+=P.length):(g[M]&&(g[M].lastCount=P.length),m[M][L]=y(P.length,P.mode)+4+t.getCharCountIndicator(P.mode,b))}}C=k}for(let E=0;E<C.length;E++)m[C[E]].end=0;return{map:m,table:g}}function B(h,b){let g;const m=t.getBestModeForData(h);if(g=t.from(b,m),g!==t.BYTE&&g.bit<m.bit)throw new Error('"'+h+'" cannot be encoded with mode '+t.toString(g)+`.
|
||
Suggested mode is: `+t.toString(m));switch(g===t.KANJI&&!l.isKanjiModeEnabled()&&(g=t.BYTE),g){case t.NUMERIC:return new s(h);case t.ALPHANUMERIC:return new n(h);case t.KANJI:return new o(h);case t.BYTE:return new r(h)}}e.fromArray=function(b){return b.reduce(function(g,m){return typeof m=="string"?g.push(B(m,null)):m.data&&g.push(B(m.data,m.mode)),g},[])},e.fromString=function(b,g){const m=x(b,l.isKanjiModeEnabled()),C=p(m),E=w(C,g),A=a.find_path(E.map,"start","end"),k=[];for(let T=1;T<A.length-1;T++)k.push(E.table[A[T]].node);return e.fromArray(f(k))},e.rawSplit=function(b){return e.fromArray(x(b,l.isKanjiModeEnabled()))}})(Te);const ee=S,ne=W,it=ze,at=Ke,lt=Ce,ut=Ne,ae=Ee,le=Z,dt=He,Q=ke,ct=Pe,ft=R,re=Te;function ht(e,t){const s=e.size,n=ut.getPositions(t);for(let r=0;r<n.length;r++){const o=n[r][0],i=n[r][1];for(let l=-1;l<=7;l++)if(!(o+l<=-1||s<=o+l))for(let a=-1;a<=7;a++)i+a<=-1||s<=i+a||(l>=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(o+l,i+a,!0,!0):e.set(o+l,i+a,!1,!0))}}function gt(e){const t=e.size;for(let s=8;s<t-8;s++){const n=s%2===0;e.set(s,6,n,!0),e.set(6,s,n,!0)}}function mt(e,t){const s=lt.getPositions(t);for(let n=0;n<s.length;n++){const r=s[n][0],o=s[n][1];for(let i=-2;i<=2;i++)for(let l=-2;l<=2;l++)i===-2||i===2||l===-2||l===2||i===0&&l===0?e.set(r+i,o+l,!0,!0):e.set(r+i,o+l,!1,!0)}}function bt(e,t){const s=e.size,n=Q.getEncodedBits(t);let r,o,i;for(let l=0;l<18;l++)r=Math.floor(l/3),o=l%3+s-8-3,i=(n>>l&1)===1,e.set(r,o,i,!0),e.set(o,r,i,!0)}function oe(e,t,s){const n=e.size,r=ct.getEncodedBits(t,s);let o,i;for(o=0;o<15;o++)i=(r>>o&1)===1,o<6?e.set(o,8,i,!0):o<8?e.set(o+1,8,i,!0):e.set(n-15+o,8,i,!0),o<8?e.set(8,n-o-1,i,!0):o<9?e.set(8,15-o-1+1,i,!0):e.set(8,15-o-1,i,!0);e.set(n-8,8,1,!0)}function wt(e,t){const s=e.size;let n=-1,r=s-1,o=7,i=0;for(let l=s-1;l>0;l-=2)for(l===6&&l--;;){for(let a=0;a<2;a++)if(!e.isReserved(r,l-a)){let c=!1;i<t.length&&(c=(t[i]>>>o&1)===1),e.set(r,l-a,c),o--,o===-1&&(i++,o=7)}if(r+=n,r<0||s<=r){r-=n,n=-n;break}}}function pt(e,t,s){const n=new it;s.forEach(function(a){n.put(a.mode.bit,4),n.put(a.getLength(),ft.getCharCountIndicator(a.mode,e)),a.write(n)});const r=ee.getSymbolTotalCodewords(e),o=le.getTotalCodewordsCount(e,t),i=(r-o)*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<l;a++)n.put(a%2?17:236,8);return yt(n,e,t)}function yt(e,t,s){const n=ee.getSymbolTotalCodewords(t),r=le.getTotalCodewordsCount(t,s),o=n-r,i=le.getBlocksCount(t,s),l=n%i,a=i-l,c=Math.floor(n/i),d=Math.floor(o/i),x=d+1,y=c-d,f=new dt(y);let p=0;const w=new Array(i),B=new Array(i);let h=0;const b=new Uint8Array(e.buffer);for(let A=0;A<i;A++){const k=A<a?d:x;w[A]=b.slice(p,p+k),B[A]=f.encode(w[A]),p+=k,h=Math.max(h,k)}const g=new Uint8Array(n);let m=0,C,E;for(C=0;C<h;C++)for(E=0;E<i;E++)C<w[E].length&&(g[m++]=w[E][C]);for(C=0;C<y;C++)for(E=0;E<i;E++)g[m++]=B[E][C];return g}function xt(e,t,s,n){let r;if(Array.isArray(e))r=re.fromArray(e);else if(typeof e=="string"){let c=t;if(!c){const d=re.rawSplit(e);c=Q.getBestVersionForData(d,s)}r=re.fromString(e,c||40)}else throw new Error("Invalid data");const o=Q.getBestVersionForData(r,s);if(!o)throw new Error("The amount of data is too big to be stored in a QR Code");if(!t)t=o;else if(t<o)throw new Error(`
|
||
The chosen QR Code version cannot contain this amount of data.
|
||
Minimum version required to store current data is: `+o+`.
|
||
`);const i=pt(t,s,r),l=ee.getSymbolSize(t),a=new at(l);return ht(a,t),gt(a),mt(a,t),oe(a,s,0),t>=7&&bt(a,t),wt(a,i),isNaN(n)&&(n=ae.getBestMask(a,oe.bind(null,a,s))),ae.applyMask(n,a),oe(a,s,n),{modules:a,version:t,errorCorrectionLevel:s,maskPattern:n,segments:r}}ye.create=function(t,s){if(typeof t>"u"||t==="")throw new Error("No input text");let n=ne.M,r,o;return typeof s<"u"&&(n=ne.from(s.errorCorrectionLevel,ne.M),r=Q.from(s.version),o=ae.from(s.maskPattern),s.toSJISFunc&&ee.setToSJISFunction(s.toSJISFunc)),xt(t,r,n,o)};var je={},he={};(function(e){function t(s){if(typeof s=="number"&&(s=s.toString()),typeof s!="string")throw new Error("Color should be defined as hex string");let n=s.slice().replace("#","").split("");if(n.length<3||n.length===5||n.length>8)throw new Error("Invalid hex color: "+s);(n.length===3||n.length===4)&&(n=Array.prototype.concat.apply([],n.map(function(o){return[o,o]}))),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,o=n.width&&n.width>=21?n.width:void 0,i=n.scale||4;return{width:o,scale:o?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 o=e.getScale(n,r);return Math.floor((n+r.margin*2)*o)},e.qrToImageData=function(n,r,o){const i=r.modules.size,l=r.modules.data,a=e.getScale(i,o),c=Math.floor((i+o.margin*2)*a),d=o.margin*a,x=[o.color.light,o.color.dark];for(let y=0;y<c;y++)for(let f=0;f<c;f++){let p=(y*c+f)*4,w=o.color.light;if(y>=d&&f>=d&&y<c-d&&f<c-d){const B=Math.floor((y-d)/a),h=Math.floor((f-d)/a);w=x[l[B*i+h]?1:0]}n[p++]=w.r,n[p++]=w.g,n[p++]=w.b,n[p]=w.a}}})(he);(function(e){const t=he;function s(r,o,i){r.clearRect(0,0,o.width,o.height),o.style||(o.style={}),o.height=i,o.width=i,o.style.height=i+"px",o.style.width=i+"px"}function n(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(o,i,l){let a=l,c=i;typeof a>"u"&&(!i||!i.getContext)&&(a=i,i=void 0),i||(c=n()),a=t.getOptions(a);const d=t.getImageWidth(o.modules.size,a),x=c.getContext("2d"),y=x.createImageData(d,d);return t.qrToImageData(y.data,o,a),s(x,c,d),x.putImageData(y,0,0),c},e.renderToDataURL=function(o,i,l){let a=l;typeof a>"u"&&(!i||!i.getContext)&&(a=i,i=void 0),a||(a={});const c=e.render(o,i,a),d=a.type||"image/png",x=a.rendererOpts||{};return c.toDataURL(d,x.quality)}})(je);var _e={};const Ct=he;function we(e,t){const s=e.a/255,n=t+'="'+e.hex+'"';return s<1?n+" "+t+'-opacity="'+s.toFixed(2).slice(1)+'"':n}function se(e,t,s){let n=e+t;return typeof s<"u"&&(n+=" "+s),n}function Nt(e,t,s){let n="",r=0,o=!1,i=0;for(let l=0;l<e.length;l++){const a=Math.floor(l%t),c=Math.floor(l/t);!a&&!o&&(o=!0),e[l]?(i++,l>0&&a>0&&e[l-1]||(n+=o?se("M",a+s,.5+c+s):se("m",r,0),r=0,o=!1),a+1<t&&e[l+1]||(n+=se("h",i),i=0)):r++}return n}_e.render=function(t,s,n){const r=Ct.getOptions(s),o=t.modules.size,i=t.modules.data,l=o+r.margin*2,a=r.color.light.a?"<path "+we(r.color.light,"fill")+' d="M0 0h'+l+"v"+l+'H0z"/>':"",c="<path "+we(r.color.dark,"stroke")+' d="'+Nt(i,o,r.margin)+'"/>',d='viewBox="0 0 '+l+" "+l+'"',y='<svg xmlns="http://www.w3.org/2000/svg" '+(r.width?'width="'+r.width+'" height="'+r.width+'" ':"")+d+' shape-rendering="crispEdges">'+a+c+`</svg>
|
||
`;return typeof n=="function"&&n(null,y),y};const Et=Fe,ue=ye,ve=je,Bt=_e;function ge(e,t,s,n,r){const o=[].slice.call(arguments,1),i=o.length,l=typeof o[i-1]=="function";if(!l&&!Et())throw new Error("Callback required as last argument");if(l){if(i<2)throw new Error("Too few arguments provided");i===2?(r=s,s=t,t=n=void 0):i===3&&(t.getContext&&typeof r>"u"?(r=n,n=void 0):(r=n,n=s,s=t,t=void 0))}else{if(i<1)throw new Error("Too few arguments provided");return i===1?(s=t,t=n=void 0):i===2&&!t.getContext&&(n=s,s=t,t=void 0),new Promise(function(a,c){try{const d=ue.create(s,n);a(e(d,t,n))}catch(d){c(d)}})}try{const a=ue.create(s,n);r(null,e(a,t,n))}catch(a){r(a)}}Y.create=ue.create;Y.toCanvas=ge.bind(null,ve.render);Y.toDataURL=ge.bind(null,ve.renderToDataURL);Y.toString=ge.bind(null,function(e,t,s){return Bt.render(e,s)});const pe={current_password:"",new_password:"",new_password_confirmation:"",two_factor_code:""};function kt(){const{user:e,refreshUser:t}=De(),[s,n]=I.useState("idle"),[r,o]=I.useState(""),[i,l]=I.useState(""),[a,c]=I.useState(""),[d,x]=I.useState(""),[y,f]=I.useState([]),[p,w]=I.useState(""),[B,h]=I.useState(!1),[b,g]=I.useState(pe),[m,C]=I.useState(""),[E,A]=I.useState(""),[k,T]=I.useState(!1),P=async N=>{if(N.preventDefault(),C(""),A(""),b.new_password!==b.new_password_confirmation){C("Die neuen Passwörter stimmen nicht überein");return}T(!0);try{await V.post("/auth/change-password",b),g(pe),A("Passwort erfolgreich geändert.")}catch(j){C(j.message)}finally{T(!1)}},L=async()=>{w(""),h(!0);try{const N=await V.get("/auth/2fa/setup");l(N.secret),o(await Y.toDataURL(N.otpauth_url)),c(""),n("setup")}catch(N){w(N.message)}finally{h(!1)}},K=async N=>{N.preventDefault(),w(""),h(!0);try{const j=await V.post("/auth/2fa/enable",{code:a});f(j.recovery_codes),n("recovery-codes"),await t()}catch(j){w(j.message)}finally{h(!1)}},M=()=>{n("idle"),f([]),x("")},Re=async N=>{N.preventDefault(),w(""),h(!0);try{await V.post("/auth/2fa/disable",{password:d}),x(""),n("idle"),await t()}catch(j){w(j.message)}finally{h(!1)}},Le=async N=>{N.preventDefault(),w(""),h(!0);try{const j=await V.post("/auth/2fa/recovery-codes",{password:d});f(j.recovery_codes),n("recovery-codes")}catch(j){w(j.message)}finally{h(!1)}};return u.jsxs("div",{className:"max-w-xl",children:[u.jsx("h1",{className:"mb-1 text-xl font-bold text-neutral-900 dark:text-white",children:"Mein Konto"}),u.jsxs("p",{className:"mb-6 text-sm text-neutral-500 dark:text-neutral-400",children:["Angemeldet als ",u.jsx("strong",{children:e==null?void 0:e.username}),e!=null&&e.is_super_admin?" (Super-Admin)":"","."]}),u.jsxs("div",{className:"mb-6 rounded-xl border border-neutral-200 bg-white p-6 dark:border-neutral-800 dark:bg-neutral-900",children:[u.jsx("h2",{className:"mb-1 font-semibold text-neutral-900 dark:text-white",children:"Passwort ändern"}),u.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."]}),u.jsxs("form",{onSubmit:P,children:[u.jsxs("div",{className:"mb-4",children:[u.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Aktuelles Passwort"}),u.jsx("input",{type:"password",value:b.current_password,onChange:N=>g({...b,current_password:N.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"})]}),u.jsxs("div",{className:"mb-4",children:[u.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Neues Passwort"}),u.jsx("input",{type:"password",value:b.new_password,onChange:N=>g({...b,new_password:N.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"})]}),u.jsxs("div",{className:"mb-4",children:[u.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Neues Passwort wiederholen"}),u.jsx("input",{type:"password",value:b.new_password_confirmation,onChange:N=>g({...b,new_password_confirmation:N.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)&&u.jsxs("div",{className:"mb-4",children:[u.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"2FA-Code zur Bestätigung"}),u.jsx("input",{value:b.two_factor_code,onChange:N=>g({...b,two_factor_code:N.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"})]}),m&&u.jsx("p",{className:"mb-4 text-sm text-red-600",children:m}),E&&u.jsx("p",{className:"mb-4 text-sm text-green-600 dark:text-green-400",children:E}),u.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:k?"Wird geändert…":"Passwort ändern"})]})]}),u.jsxs("div",{className:"rounded-xl border border-neutral-200 bg-white p-6 dark:border-neutral-800 dark:bg-neutral-900",children:[u.jsx("h2",{className:"mb-1 font-semibold text-neutral-900 dark:text-white",children:"Zwei-Faktor-Authentifizierung"}),u.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."}),s==="idle"&&u.jsxs(u.Fragment,{children:[u.jsxs("p",{className:"mb-4 text-sm",children:["Status:"," ",e!=null&&e.two_factor_enabled?u.jsx("span",{className:"font-semibold text-green-600 dark:text-green-400",children:"Aktiv"}):u.jsx("span",{className:"font-semibold text-neutral-500 dark:text-neutral-400",children:"Nicht aktiv"})]}),e!=null&&e.two_factor_enabled?u.jsxs("div",{className:"flex flex-wrap gap-2",children:[u.jsx("button",{onClick:()=>{n("regenerate"),w("")},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"}),u.jsx("button",{onClick:()=>{n("disable"),w("")},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"})]}):u.jsx("button",{onClick:L,disabled:B,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"})]}),s==="setup"&&u.jsxs("form",{onSubmit:K,children:[u.jsxs("ol",{className:"mb-4 list-decimal space-y-2 pl-5 text-sm text-neutral-700 dark:text-neutral-300",children:[u.jsx("li",{children:"Öffne die Google Authenticator App (oder eine kompatible App)."}),u.jsx("li",{children:"Scanne den folgenden QR-Code:"})]}),u.jsx("div",{className:"mb-4 flex justify-center",children:r&&u.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"})}),u.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: ",u.jsx("br",{}),u.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})]}),u.jsxs("div",{className:"mb-4",children:[u.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Bestätigungscode aus der App"}),u.jsx("input",{value:a,onChange:N=>c(N.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"})]}),p&&u.jsx("p",{className:"mb-4 text-sm text-red-600",children:p}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx("button",{type:"submit",disabled:B,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"}),u.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"})]})]}),s==="recovery-codes"&&u.jsxs("div",{children:[u.jsx("p",{className:"mb-3 text-sm font-semibold text-neutral-900 dark:text-white",children:"Wiederherstellungscodes – jetzt sicher speichern!"}),u.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."}),u.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:y.map(N=>u.jsx("span",{children:N},N))}),u.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"})]}),s==="disable"&&u.jsxs("form",{onSubmit:Re,children:[u.jsxs("div",{className:"mb-4",children:[u.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Passwort zur Bestätigung"}),u.jsx("input",{type:"password",value:d,onChange:N=>x(N.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"})]}),p&&u.jsx("p",{className:"mb-4 text-sm text-red-600",children:p}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx("button",{type:"submit",disabled:B,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"}),u.jsx("button",{type:"button",onClick:()=>{n("idle"),x("")},className:"rounded-md border border-neutral-300 px-4 py-2 text-sm dark:border-neutral-700",children:"Abbrechen"})]})]}),s==="regenerate"&&u.jsxs("form",{onSubmit:Le,children:[u.jsx("p",{className:"mb-3 text-sm text-neutral-500 dark:text-neutral-400",children:"Die bisherigen Wiederherstellungscodes werden ungültig."}),u.jsxs("div",{className:"mb-4",children:[u.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Passwort zur Bestätigung"}),u.jsx("input",{type:"password",value:d,onChange:N=>x(N.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"})]}),p&&u.jsx("p",{className:"mb-4 text-sm text-red-600",children:p}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx("button",{type:"submit",disabled:B,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"}),u.jsx("button",{type:"button",onClick:()=>{n("idle"),x("")},className:"rounded-md border border-neutral-300 px-4 py-2 text-sm dark:border-neutral-700",children:"Abbrechen"})]})]})]})]})}export{kt as default};
|