import{l as S,r as Q,j as H,t as T,aw as V,w as q,x as Y,dk as W,cm as X,aq as G,ag as K,U as Z,D as j,E as _,T as J,dY as ee,L as te}from"./index-CEmnTf-r.js";function P(a,n,r){return r=y(r),`M ${y(a-r)}, ${y(n)} a ${r},${r} 0 1,0 ${2*r},0 a ${r},${r} 0 1,0 ${-2*r},0`}function O(a,n,r){a=y(a),n=y(n);const s=y(a+r),l=y(n+r);return`M ${a}, ${n} L ${s}, ${n} L ${s}, ${l} L ${a}, ${l} Z `}function oe(a,n,r,s){a=y(a),n=y(n);const l=y(a+s),u=y(n+s),h=y(a+r-s),f=y(n+r-s),m=y(a+r),e=y(n+r);return`M${l} ${n}L${m} ${n}L${m} ${e}L${a} ${e}L${a} ${n}L${l} ${n}L${l} ${f}L${h} ${f}L${h} ${u}L${l} ${u}Z `}function re(a,n,r,s,l){a=y(a),n=y(n),l=y(l);const u=y(a+l),h=y(a+r-l),f=y(n+l),m=y(n+r-l),e=y(a+s),t=y(n+s),o=y(a+r-s),i=y(n+r-s),c=y(a+r),g=y(n+r),d=y(l-s/2),C=y(e+d),p=y(t+d),v=y(o-d),w=y(i-d),E=y(u+d);return`M${u} ${n}L${h} ${n}A${l} ${l} 0 0 1 ${c} ${f}L${c} ${m}A${l} ${l} 0 0 1 ${h} ${g}L${u} ${g}A${l} ${l} 0 0 1 ${a} ${m}L${a} ${f}A${l} ${l} 0 0 1 ${u} ${n}L${u} ${n}L${E} ${i}L${v} ${i}A${d} ${d} 0 0 0 ${o} ${w}L${o} ${p}A${d} ${d} 0 0 0 ${v} ${t}L${C} ${t}A${d} ${d} 0 0 0 ${e} ${p}L${e} ${w}A${d} ${d} 0 0 0 ${C} ${i}L${E} ${i}Z`}function ne(a,n,r,s){const l=y(r),u=y(r-s);n=y(n),a=y(a);const h=y(n-l),f=y(n-u),m=y(n+l),e=y(n+u);return`M${a},${h} A${l},${l} 0 1,1 ${a},${m} A${l},${l} 0 1,1 ${a},${h} M${a},${f} A${u},${u} 0 1,0 ${a},${e} A${u},${u} 0 1,0 ${a},${f} Z`}function ie(a){const{size:n,dotSize:r,borderSize:s,x:l,y:u}=a,h=oe(l,u,n,r*s),f=O(l+r*2,u+r*2,n-r*4);return{eyeBorder:h,eyeInner:f}}function se(a){const{size:n,dotSize:r,borderSize:s,x:l,y:u}=a,h=re(l,u,n,r*s,r*2),f=P(l+n/2,u+n/2,n/2-r*2);return{eyeBorder:h,eyeInner:f}}function ae(a){const{size:n,dotSize:r,borderSize:s,x:l,y:u}=a,h=ne(l+n/2,u+n/2,n/2,r*s),f=P(l+n/2,u+n/2,n/2-r*2);return{eyeBorder:h,eyeInner:f}}const le={default:ie,rounded:se,circle:ae};function ce(a){const n={default:1,sm:.8,xs:.5};return r=>{const{size:s,dotSize:l,borderSize:u,margin:h}=r,{eyeSize:f,positions:m}=$e(s,l,h);let e="",t="";for(const o of m){const{eyeBorder:i,eyeInner:c}=a({size:f,dotSize:l,borderSize:n[u],x:o.x,y:o.y});e+=i,t+=c}return{eyeBorder:e,eyeInner:t}}}function ue(a){const n=le[a];return ce(n)}function de(a){const{x:n,y:r,dotSize:s,dotScale:l,margin:u}=a;let h="";const f=s*l;return h+=O(n*s+(s-f)/2+u,r*s+(s-f)/2+u,f),h}function he(a){const{x:n,y:r,dotSize:s,dotScale:l,margin:u}=a;let h="",f=s/2*l,m=n*s+(s-f*2)/2+f+u,e=r*s+(s-f*2)/2+f+u;return h+=P(m,e,f),h}const fe={default:de,circle:he};function ge(a){const n={default:1,sm:.8,xs:.5};return r=>{const{modules:s,dotSize:l,pointSize:u,customSize:h,margin:f}=r;let m="";for(let e=0;e{const n=class ${constructor(e,t,o,i){if(this.version=e,this.errorCorrectionLevel=t,this.modules=[],this.isFunction=[],e<$.MIN_VERSION||e>$.MAX_VERSION)throw new RangeError("Version value out of range");if(i<-1||i>7)throw new RangeError("Mask value out of range");this.size=e*4+17;let c=[];for(let d=0;d7)throw new RangeError("Invalid value");let d,C;for(d=o;;d++){const E=$.getNumDataCodewords(d,t)*8,R=f.getTotalBits(e,d);if(R<=E){C=R;break}if(d>=i)throw new RangeError("Data too long")}for(const E of[$.Ecc.MEDIUM,$.Ecc.QUARTILE,$.Ecc.HIGH])g&&C<=$.getNumDataCodewords(d,E)*8&&(t=E);let p=[];for(const E of e){s(E.mode.modeBits,4,p),s(E.numChars,E.mode.numCharCountBits(d),p);for(const R of E.getData())p.push(R)}u(p.length==C);const v=$.getNumDataCodewords(d,t)*8;u(p.length<=v),s(0,Math.min(4,v-p.length),p),s(0,(8-p.length%8)%8,p),u(p.length%8==0);for(let E=236;p.lengthw[R>>>3]|=E<<7-(R&7)),new $(d,t,w,c)}getModule(e,t){return 0<=e&&e>>9)*1335;const i=(t<<10|o)^21522;u(i>>>15==0);for(let c=0;c<=5;c++)this.setFunctionModule(8,c,l(i,c));this.setFunctionModule(8,7,l(i,6)),this.setFunctionModule(8,8,l(i,7)),this.setFunctionModule(7,8,l(i,8));for(let c=9;c<15;c++)this.setFunctionModule(14-c,8,l(i,c));for(let c=0;c<8;c++)this.setFunctionModule(this.size-1-c,8,l(i,c));for(let c=8;c<15;c++)this.setFunctionModule(8,this.size-15+c,l(i,c));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let o=0;o<12;o++)e=e<<1^(e>>>11)*7973;const t=this.version<<12|e;u(t>>>18==0);for(let o=0;o<18;o++){const i=l(t,o),c=this.size-11+o%3,g=Math.floor(o/3);this.setFunctionModule(c,g,i),this.setFunctionModule(g,c,i)}}drawFinderPattern(e,t){for(let o=-4;o<=4;o++)for(let i=-4;i<=4;i++){const c=Math.max(Math.abs(i),Math.abs(o)),g=e+i,d=t+o;0<=g&&g{(E!=C-c||z>=d)&&w.push(R[E])});return u(w.length==g),w}drawCodewords(e){if(e.length!=Math.floor($.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let t=0;for(let o=this.size-1;o>=1;o-=2){o==6&&(o=5);for(let i=0;i>>3],7-(t&7)),t++)}}u(t==e.length*8)}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let t=0;t5&&e++):(this.finderPenaltyAddHistory(d,C),g||(e+=this.finderPenaltyCountPatterns(C)*$.PENALTY_N3),g=this.modules[c][p],d=1);e+=this.finderPenaltyTerminateAndCount(g,d,C)*$.PENALTY_N3}for(let c=0;c5&&e++):(this.finderPenaltyAddHistory(d,C),g||(e+=this.finderPenaltyCountPatterns(C)*$.PENALTY_N3),g=this.modules[p][c],d=1);e+=this.finderPenaltyTerminateAndCount(g,d,C)*$.PENALTY_N3}for(let c=0;cg+(d?1:0),t);const o=this.size*this.size,i=Math.ceil(Math.abs(t*20-o*10)/o)-1;return u(0<=i&&i<=9),e+=i*$.PENALTY_N4,u(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{const e=Math.floor(this.version/7)+2,t=Math.floor((this.version*8+e*3+5)/(e*4-4))*2;let o=[6];for(let i=this.size-7;o.length$.MAX_VERSION)throw new RangeError("Version number out of range");let t=(16*e+128)*e+64;if(e>=2){const o=Math.floor(e/7)+2;t-=(25*o-10)*o-55,e>=7&&(t-=36)}return u(208<=t&&t<=29648),t}static getNumDataCodewords(e,t){return Math.floor($.getNumRawDataModules(e)/8)-$.ECC_CODEWORDS_PER_BLOCK[t.ordinal][e]*$.NUM_ERROR_CORRECTION_BLOCKS[t.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw new RangeError("Degree out of range");let t=[];for(let i=0;i0);for(const i of e){const c=i^o.shift();o.push(0),t.forEach((g,d)=>o[d]^=$.reedSolomonMultiply(g,c))}return o}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw new RangeError("Byte out of range");let o=0;for(let i=7;i>=0;i--)o=o<<1^(o>>>7)*285,o^=(t>>>i&1)*e;return u(o>>>8==0),o}finderPenaltyCountPatterns(e){const t=e[1];u(t<=this.size*3);const o=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(o&&e[0]>=t*4&&e[6]>=t?1:0)+(o&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,o){return e&&(this.finderPenaltyAddHistory(t,o),t=0),t+=this.size,this.finderPenaltyAddHistory(t,o),this.finderPenaltyCountPatterns(o)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};n.MIN_VERSION=1,n.MAX_VERSION=40,n.PENALTY_N1=3,n.PENALTY_N2=3,n.PENALTY_N3=40,n.PENALTY_N4=10,n.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],n.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]];let r=n;a.QrCode=r;function s(m,e,t){if(e<0||e>31||m>>>e)throw new RangeError("Value out of range");for(let o=e-1;o>=0;o--)t.push(m>>>o&1)}function l(m,e){return(m>>>e&1)!=0}function u(m){if(!m)throw new Error("Assertion error")}const h=class M{constructor(e,t,o){if(this.mode=e,this.numChars=t,this.bitData=o,t<0)throw new RangeError("Invalid argument");this.bitData=o.slice()}static makeBytes(e){let t=[];for(const o of e)s(o,8,t);return new M(M.Mode.BYTE,e.length,t)}static makeNumeric(e){if(!M.isNumeric(e))throw new RangeError("String contains non-numeric characters");let t=[];for(let o=0;o=1<{(n=>{const r=class{constructor(u,h){this.ordinal=u,this.formatBits=h}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2);let s=r;n.Ecc=s})(a.QrCode||(a.QrCode={}))})(N||(N={}));(a=>{(n=>{const r=class{constructor(u,h){this.modeBits=u,this.numBitsCharCount=h}numCharCountBits(u){return this.numBitsCharCount[Math.floor((u+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]);let s=r;n.Mode=s})(a.QrSegment||(a.QrSegment={}))})(N||(N={}));const I=N,pe=I.QrCode,ye={L:I.QrCode.Ecc.LOW,M:I.QrCode.Ecc.MEDIUM,Q:I.QrCode.Ecc.QUARTILE,H:I.QrCode.Ecc.HIGH};function Ce(a,n){const{level:r="L",minVersion:s=2,maxVersion:l,mask:u,boostLevel:h}=n||{},f=I.QrSegment.makeSegments(a),m=pe.encodeSegments(f,ye[r],s,l,u,h),e=[];for(let t=0;ts-l||n>s-l&&rCe(l,n),[l,n]),c=S.useMemo(()=>y((u-h*2)/i.length),[i,u,h]),g=S.useMemo(()=>{let C=[];for(let p=0;pwe({modules:i,margin:h,size:u,dotSize:c,eyeType:f,eyeBorderSize:m,pointType:e,pointSize:t,customSize:g}),[i,c,r]);return{logo:S.useMemo(()=>{if(!s)return;let C=u-h*2,{src:p,width:v=C/5,height:w=C/5,x:E=C/2-v/2+h,y:R=C/2-w/2+h}=s||{};const z=i.length,A=Array.from({length:z},(L,U)=>U*c+h),x=A[A.findIndex(L=>L>E)-2]-.5||E,B=A[A.findIndex(L=>L>R)-2]-.5||R,k=v+(E-x)*2,D=w+(R-B)*2;return{src:p,width:v,height:w,x:E,y:R,bg:{x,y:B,width:k,height:D}}},[i,c,h,s]),path:d}}function Se(a){const{value:n,config:r,styleConfig:s,logoConfig:l,className:u}=a,{size:h=200,margin:f=0,color:m="#000",bgColor:e="#fff",eyeBorderColor:t,eyeInnerColor:o}=s||{},{path:i,logo:c}=F({config:r,styleConfig:s,logoConfig:l,value:n}),{src:g,x:d,y:C,width:p,height:v,bg:w}=c||{};return S.createElement("svg",{width:h,height:h,viewBox:`0 0 ${h} ${h}`,style:{backgroundColor:e},className:"qr-container qr-svg"+(u?` ${u}`:"")},S.createElement("g",{fill:m},S.createElement("path",{fill:t||m,d:i.eyeBorder}),S.createElement("path",{fill:o||m,d:i.eyeInner}),S.createElement("path",{d:i.points}),g&&S.createElement(S.Fragment,null,S.createElement("rect",{fill:e,x:w==null?void 0:w.x,y:w==null?void 0:w.y,width:w==null?void 0:w.width,height:w==null?void 0:w.height}),S.createElement("image",{href:g,width:p,height:v,x:d,y:C}))))}function Me({ctx:a,bgColor:n="#fff",logo:r}){const{src:s,width:l,height:u,x:h,y:f,bg:m}=r||{};if(!s)return;const e=new Image;e.src=s,e.onload=()=>{a.fillStyle=n,a.fillRect(m.x,m.y,m.width,m.height);const t=e.width/e.height;let o=l,i=u;t>1?i=l/t:o=u*t,a.drawImage(e,h+(l-o)/2,f+(u-i)/2,o,i)}}function Re(a){const{ctx:n,path:r,styleConfig:s}=a,{color:l="#000",bgColor:u="#fff",eyeBorderColor:h,eyeInnerColor:f}=s||{};n.clearRect(0,0,n.canvas.width,n.canvas.height),n.fillStyle=u,n.fillRect(0,0,n.canvas.width,n.canvas.height),n.fillStyle=h||l,n.fill(new Path2D(r.eyeBorder)),n.fillStyle=f||l,n.fill(new Path2D(r.eyeInner)),n.fillStyle=l,n.fill(new Path2D(r.points))}function ve(a){const{value:n,config:r,styleConfig:s,logoConfig:l,className:u}=a,{size:h=200,bgColor:f}=s||{},{path:m,logo:e}=F({config:r,styleConfig:s,logoConfig:l,value:n}),t=S.useRef(null);return Q.useEffect(()=>{if(m&&t.current){const o=t.current.getContext("2d");Re({ctx:o,path:m,styleConfig:s}),e&&Me({ctx:o,bgColor:f,logo:e})}},[m,l,s]),H("canvas",{width:h,height:h,ref:t,className:"qr-container qr-canvas"+(u?` ${u}`:"")})}function ze(a){const{mode:n="canvas"}=a;return n==="svg"?S.createElement(Se,{...a}):S.createElement(ve,{...a})}function b(a,n){return ee.saveAs(a,n)}var Ae=function(a){T(n,a);function n(r){var s=a.call(this,r)||this;return s.ref=S.createRef(),s}return n.prototype.getImageSettings=function(){var r=this.props,s=r.imageSettings,l=r.data;if(!(!s||!V(s)||!s.src||typeof s.src!="string"))return q(s.src)&&(s.src=Y(s.src,l,"| raw")),W(s,function(u,h){return~["width","height","x","y"].indexOf(h)?X(u)?Number(u):null:u})},n.prototype.doAction=function(r,s,l,u){var h,f=this.props.codeSize,m=r==null?void 0:r.actionType;if(m==="saveAs"&&!((h=this.ref)===null||h===void 0)&&h.current)if(this.props.mode==="svg"){var e=this.ref.current.querySelector("svg");if(e){var t=' `).concat(e.innerHTML,` `),o=new Blob([t],{type:"image/svg+xml"});b(o,(u==null?void 0:u.name)||"qr-code.svg")}}else{var i=this.ref.current.querySelector("canvas");i&&i.toBlob(function(c){c&&b(c,u!=null&&u.name?u.name.replace(/\.svg$/,".png"):"qr-code.png")},"image/png")}},n.prototype.render=function(){var r=this.props,s=r.className,l=r.style,u=r.qrcodeClassName,h=r.codeSize,f=r.backgroundColor,m=r.foregroundColor,e=r.placeholder,t=r.level,o=r.defaultValue,i=r.data,c=r.mode,g=r.eyeType,d=r.eyeBorderColor,C=r.eyeBorderSize,p=r.eyeInnerColor,v=r.pointType,w=r.pointSize,E=r.pointSizeRandom,R=r.translate,z=r.classPrefix,A=G(this.props,function(){return te(o,i,"| raw")||void 0});return S.createElement("div",{className:K("".concat(z,"QrCode"),s),style:l,ref:this.ref},A?A.length>2953?S.createElement("span",{className:"text-danger"},R("QRCode.tooLong",{max:2953})):S.createElement(ze,{className:u,value:A,config:{level:t||"L",minVersion:2,boostLevel:!0},styleConfig:{size:h,bgColor:f,color:m,eyeType:g,eyeBorderColor:d,eyeBorderSize:C,eyeInnerColor:p,pointType:v,pointSize:w,pointSizeRandom:E},logoConfig:this.getImageSettings(),mode:c}):S.createElement("span",{className:"".concat(z,"QrCode--placeholder")},e))},n.defaultProps={codeSize:128,qrcodeClassName:"",backgroundColor:"#fff",foregroundColor:"#000",level:"L",placeholder:"-",mode:"canvas"},n}(S.Component),Pe=function(a){T(n,a);function n(r,s){var l=a.call(this,r)||this,u=s;return u.registerComponent(l),l}return n.prototype.componentWillUnmount=function(){var r;(r=a.prototype.componentWillUnmount)===null||r===void 0||r.call(this);var s=this.context;s.unRegisterComponent(this)},n.contextType=Z,n=j([_({type:"qrcode",alias:["qr-code"],name:"qrcode"}),J("design:paramtypes",[Object,Object])],n),n}(Ae);export{Pe as QRCodeRenderer,Ae as default};