import{f as p,s as U,ao as J,v as ee,w as te,d9 as re,ch as oe,ai as ne,ag as se,T as ie,z as le,D as ae,Q as ce,K as ue}from"./index-BPRWoLf4.js";var he=Object.defineProperty,I=Object.getOwnPropertySymbols,D=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable,z=(h,n,l)=>n in h?he(h,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):h[n]=l,S=(h,n)=>{for(var l in n||(n={}))D.call(n,l)&&z(h,l,n[l]);if(I)for(var l of I(n))Q.call(n,l)&&z(h,l,n[l]);return h},b=(h,n)=>{var l={};for(var i in h)D.call(h,i)&&n.indexOf(i)<0&&(l[i]=h[i]);if(h!=null&&I)for(var i of I(h))n.indexOf(i)<0&&Q.call(h,i)&&(l[i]=h[i]);return l};/** * @license QR Code generator library (TypeScript) * Copyright (c) Project Nayuki. * SPDX-License-Identifier: MIT */var A;(h=>{const n=class{constructor(e,t,r,o){if(this.version=e,this.errorCorrectionLevel=t,this.modules=[],this.isFunction=[],en.MAX_VERSION)throw new RangeError("Version value out of range");if(o<-1||o>7)throw new RangeError("Mask value out of range");this.size=e*4+17;let s=[];for(let a=0;a7)throw new RangeError("Invalid value");let a,g;for(a=r;;a++){const E=n.getNumDataCodewords(a,t)*8,w=C.getTotalBits(e,a);if(w<=E){g=w;break}if(a>=o)throw new RangeError("Data too long")}for(const E of[n.Ecc.MEDIUM,n.Ecc.QUARTILE,n.Ecc.HIGH])c&&g<=n.getNumDataCodewords(a,E)*8&&(t=E);let f=[];for(const E of e){i(E.mode.modeBits,4,f),i(E.numChars,E.mode.numCharCountBits(a),f);for(const w of E.getData())f.push(w)}u(f.length==g);const R=n.getNumDataCodewords(a,t)*8;u(f.length<=R),i(0,Math.min(4,R-f.length),f),i(0,(8-f.length%8)%8,f),u(f.length%8==0);for(let E=236;f.lengthM[w>>>3]|=E<<7-(w&7)),new n(a,t,M,s)}getModule(e,t){return 0<=e&&e>>9)*1335;const o=(t<<10|r)^21522;u(o>>>15==0);for(let s=0;s<=5;s++)this.setFunctionModule(8,s,m(o,s));this.setFunctionModule(8,7,m(o,6)),this.setFunctionModule(8,8,m(o,7)),this.setFunctionModule(7,8,m(o,8));for(let s=9;s<15;s++)this.setFunctionModule(14-s,8,m(o,s));for(let s=0;s<8;s++)this.setFunctionModule(this.size-1-s,8,m(o,s));for(let s=8;s<15;s++)this.setFunctionModule(8,this.size-15+s,m(o,s));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let r=0;r<12;r++)e=e<<1^(e>>>11)*7973;const t=this.version<<12|e;u(t>>>18==0);for(let r=0;r<18;r++){const o=m(t,r),s=this.size-11+r%3,c=Math.floor(r/3);this.setFunctionModule(s,c,o),this.setFunctionModule(c,s,o)}}drawFinderPattern(e,t){for(let r=-4;r<=4;r++)for(let o=-4;o<=4;o++){const s=Math.max(Math.abs(o),Math.abs(r)),c=e+o,a=t+r;0<=c&&c{(E!=g-s||v>=a)&&M.push(w[E])});return u(M.length==c),M}drawCodewords(e){if(e.length!=Math.floor(n.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let t=0;for(let r=this.size-1;r>=1;r-=2){r==6&&(r=5);for(let o=0;o>>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(a,g),c||(e+=this.finderPenaltyCountPatterns(g)*n.PENALTY_N3),c=this.modules[s][f],a=1);e+=this.finderPenaltyTerminateAndCount(c,a,g)*n.PENALTY_N3}for(let s=0;s5&&e++):(this.finderPenaltyAddHistory(a,g),c||(e+=this.finderPenaltyCountPatterns(g)*n.PENALTY_N3),c=this.modules[f][s],a=1);e+=this.finderPenaltyTerminateAndCount(c,a,g)*n.PENALTY_N3}for(let s=0;sc+(a?1:0),t);const r=this.size*this.size,o=Math.ceil(Math.abs(t*20-r*10)/r)-1;return u(0<=o&&o<=9),e+=o*n.PENALTY_N4,u(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{const e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2;let r=[6];for(let o=this.size-7;r.lengthn.MAX_VERSION)throw new RangeError("Version number out of range");let t=(16*e+128)*e+64;if(e>=2){const r=Math.floor(e/7)+2;t-=(25*r-10)*r-55,e>=7&&(t-=36)}return u(208<=t&&t<=29648),t}static getNumDataCodewords(e,t){return Math.floor(n.getNumRawDataModules(e)/8)-n.ECC_CODEWORDS_PER_BLOCK[t.ordinal][e]*n.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 o=0;o0);for(const o of e){const s=o^r.shift();r.push(0),t.forEach((c,a)=>r[a]^=n.reedSolomonMultiply(c,s))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw new RangeError("Byte out of range");let r=0;for(let o=7;o>=0;o--)r=r<<1^(r>>>7)*285,r^=(t>>>o&1)*e;return u(r>>>8==0),r}finderPenaltyCountPatterns(e){const t=e[1];u(t<=this.size*3);const r=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(r&&e[0]>=t*4&&e[6]>=t?1:0)+(r&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,r){return e&&(this.finderPenaltyAddHistory(t,r),t=0),t+=this.size,this.finderPenaltyAddHistory(t,r),this.finderPenaltyCountPatterns(r)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};let l=n;l.MIN_VERSION=1,l.MAX_VERSION=40,l.PENALTY_N1=3,l.PENALTY_N2=3,l.PENALTY_N3=40,l.PENALTY_N4=10,l.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]],l.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]],h.QrCode=l;function i(e,t,r){if(t<0||t>31||e>>>t)throw new RangeError("Value out of range");for(let o=t-1;o>=0;o--)r.push(e>>>o&1)}function m(e,t){return(e>>>t&1)!=0}function u(e){if(!e)throw new Error("Assertion error")}const d=class{constructor(e,t,r){if(this.mode=e,this.numChars=t,this.bitData=r,t<0)throw new RangeError("Invalid argument");this.bitData=r.slice()}static makeBytes(e){let t=[];for(const r of e)i(r,8,t);return new d(d.Mode.BYTE,e.length,t)}static makeNumeric(e){if(!d.isNumeric(e))throw new RangeError("String contains non-numeric characters");let t=[];for(let r=0;r=1<{(n=>{const l=class{constructor(m,u){this.ordinal=m,this.formatBits=u}};let i=l;i.LOW=new l(0,1),i.MEDIUM=new l(1,0),i.QUARTILE=new l(2,3),i.HIGH=new l(3,2),n.Ecc=i})(h.QrCode||(h.QrCode={}))})(A||(A={}));(h=>{(n=>{const l=class{constructor(m,u){this.modeBits=m,this.numBitsCharCount=u}numCharCountBits(m){return this.numBitsCharCount[Math.floor((m+7)/17)]}};let i=l;i.NUMERIC=new l(1,[10,12,14]),i.ALPHANUMERIC=new l(2,[9,11,13]),i.BYTE=new l(4,[8,16,16]),i.KANJI=new l(8,[8,10,12]),i.ECI=new l(7,[0,0,0]),n.Mode=i})(h.QrSegment||(h.QrSegment={}))})(A||(A={}));var N=A;/** * @license qrcode.react * Copyright (c) Paul O'Shannessy * SPDX-License-Identifier: ISC */var k={L:N.QrCode.Ecc.LOW,M:N.QrCode.Ecc.MEDIUM,Q:N.QrCode.Ecc.QUARTILE,H:N.QrCode.Ecc.HIGH},x=128,H="L",$="#FFFFFF",Y="#000000",V=!1,L=4,de=.1;function G(h,n=0){const l=[];return h.forEach(function(i,m){let u=null;i.forEach(function(d,C){if(!d&&u!==null){l.push(`M${u+n} ${m+n}h${C-u}v1H${u+n}z`),u=null;return}if(C===i.length-1){if(!d)return;u===null?l.push(`M${C+n},${m+n} h1v1H${C+n}z`):l.push(`M${u+n},${m+n} h${C+1-u}v1H${u+n}z`);return}d&&u===null&&(u=C)})}),l.join("")}function j(h,n){return h.slice().map((l,i)=>i=n.y+n.h?l:l.map((m,u)=>u=n.x+n.w?m:!1))}function X(h,n,l,i){if(i==null)return null;const m=l?L:0,u=h.length+m*2,d=Math.floor(n*de),C=u/n,e=(i.width||d)*C,t=(i.height||d)*C,r=i.x==null?h.length/2-e/2:i.x*C,o=i.y==null?h.length/2-t/2:i.y*C;let s=null;if(i.excavate){let c=Math.floor(r),a=Math.floor(o),g=Math.ceil(e+r-c),f=Math.ceil(t+o-a);s={x:c,y:a,w:g,h:f}}return{x:r,y:o,h:t,w:e,excavation:s}}var fe=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}();function me(h){const n=h,{value:l,size:i=x,level:m=H,bgColor:u=$,fgColor:d=Y,includeMargin:C=V,style:e,imageSettings:t}=n,r=b(n,["value","size","level","bgColor","fgColor","includeMargin","style","imageSettings"]),o=t==null?void 0:t.src,s=p.useRef(null),c=p.useRef(null),[a,g]=p.useState(!1);p.useEffect(()=>{if(s.current!=null){const M=s.current,E=M.getContext("2d");if(!E)return;let w=N.QrCode.encodeText(l,k[m]).getModules();const v=C?L:0,P=w.length+v*2,_=X(w,i,C,t),y=c.current,O=_!=null&&y!==null&&y.complete&&y.naturalHeight!==0&&y.naturalWidth!==0;O&&_.excavation!=null&&(w=j(w,_.excavation));const B=window.devicePixelRatio||1;M.height=M.width=i*B;const T=i/P*B;E.scale(T,T),E.fillStyle=u,E.fillRect(0,0,P,P),E.fillStyle=d,fe?E.fill(new Path2D(G(w,v))):w.forEach(function(W,K){W.forEach(function(q,Z){q&&E.fillRect(Z+v,K+v,1,1)})}),O&&E.drawImage(y,_.x+v,_.y+v,_.w,_.h)}}),p.useEffect(()=>{g(!1)},[o]);const f=S({height:i,width:i},e);let R=null;return o!=null&&(R=p.createElement("img",{src:o,key:o,style:{display:"none"},onLoad:()=>{g(!0)},ref:c})),p.createElement(p.Fragment,null,p.createElement("canvas",S({style:f,height:i,width:i,ref:s},r)),R)}function ge(h){const n=h,{value:l,size:i=x,level:m=H,bgColor:u=$,fgColor:d=Y,includeMargin:C=V,imageSettings:e}=n,t=b(n,["value","size","level","bgColor","fgColor","includeMargin","imageSettings"]);let r=N.QrCode.encodeText(l,k[m]).getModules();const o=C?L:0,s=r.length+o*2,c=X(r,i,C,e);let a=null;e!=null&&c!=null&&(c.excavation!=null&&(r=j(r,c.excavation)),a=p.createElement("image",{xlinkHref:e.src,height:c.h,width:c.w,x:c.x+o,y:c.y+o,preserveAspectRatio:"none"}));const g=G(r,o);return p.createElement("svg",S({height:i,width:i,viewBox:`0 0 ${s} ${s}`},t),p.createElement("path",{fill:u,d:`M0,0 h${s}v${s}H0z`,shapeRendering:"crispEdges"}),p.createElement("path",{fill:d,d:g,shapeRendering:"crispEdges"}),a)}var Ee=h=>{const n=h,{renderAs:l}=n,i=b(n,["renderAs"]);return l==="svg"?p.createElement(ge,S({},i)):p.createElement(me,S({},i))};function F(h,n){var l=URL.createObjectURL(h),i=document.createElement("a");i.href=l,i.download=n,document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(function(){return URL.revokeObjectURL(l)},500)}var Ce=function(h){U(n,h);function n(l){var i=h.call(this,l)||this;return i.ref=p.createRef(),i}return n.prototype.getImageSettings=function(){var l=this.props,i=l.imageSettings,m=l.data;if(!(!i||!J(i)||!i.src||typeof i.src!="string"))return ee(i.src)&&(i.src=te(i.src,m,"| raw")),re(i,function(u,d){return~["width","height","x","y"].indexOf(d)?oe(u)?Number(u):null:u})},n.prototype.doAction=function(l,i,m,u){var d,C=this.props.codeSize,e=l==null?void 0:l.actionType;if(e==="saveAs"&&!((d=this.ref)===null||d===void 0)&&d.current)if(this.props.mode==="svg"){var t=this.ref.current.querySelector("svg");if(t){var r=' `).concat(t.innerHTML,` `),o=new Blob([r],{type:"image/svg+xml"});F(o,(u==null?void 0:u.name)||"qr-code.svg")}}else{var s=this.ref.current.querySelector("canvas");s&&s.toBlob(function(c){c&&F(c,u!=null&&u.name?u.name.replace(/\.svg$/,".png"):"qr-code.png")},"image/png")}},n.prototype.render=function(){var l=this.props,i=l.className,m=l.style,u=l.qrcodeClassName,d=l.codeSize,C=l.backgroundColor,e=l.foregroundColor,t=l.placeholder,r=l.level,o=l.defaultValue,s=l.data,c=l.mode,a=l.translate,g=l.classPrefix,f=ne(this.props,function(){return ue(o,s,"| raw")||void 0});return p.createElement("div",{className:se("".concat(g,"QrCode"),i),style:m,ref:this.ref},f?f.length>2953?p.createElement("span",{className:"text-danger"},a("QRCode.tooLong",{max:2953})):p.createElement(Ee,{className:u,value:f,size:d,bgColor:C,fgColor:e,level:r||"L",imageSettings:this.getImageSettings(),renderAs:c}):p.createElement("span",{className:"".concat(g,"QrCode--placeholder")},t))},n.defaultProps={codeSize:128,qrcodeClassName:"",backgroundColor:"#fff",foregroundColor:"#000",level:"L",placeholder:"-",mode:"canvas"},n}(p.Component),we=function(h){U(n,h);function n(l,i){var m=h.call(this,l)||this,u=i;return u.registerComponent(m),m}return n.prototype.componentWillUnmount=function(){var l;(l=h.prototype.componentWillUnmount)===null||l===void 0||l.call(this);var i=this.context;i.unRegisterComponent(this)},n.contextType=ie,n=le([ae({type:"qrcode",alias:["qr-code"],name:"qrcode"}),ce("design:paramtypes",[Object,Object])],n),n}(Ce);export{we as QRCodeRenderer,Ce as default};