New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@qrcode-js/core

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@qrcode-js/core - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

lib/types.d.ts

2

dist/awesome-qr.js

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.AwesomeQR=e():t.AwesomeQR=e()}(this,(()=>(()=>{"use strict";var t={207:function(t,e,r){var o=this&&this.__assign||function(){return o=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},o.apply(this,arguments)},n=this&&this.__awaiter||function(t,e,r,o){return new(r||(r=Promise))((function(n,i){function a(t){try{u(o.next(t))}catch(t){i(t)}}function s(t){try{u(o.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}u((o=o.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var r,o,n,i,a={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,o&&(n=2&i[0]?o.return:i[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,i[1])).done)return n;switch(o=0,n&&(i=[2&i[0],n.value]),i[0]){case 0:case 1:n=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((n=(n=a.trys).length>0&&n[n.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!n||i[1]>n[0]&&i[1]<n[3])){a.label=i[1];break}if(6===i[0]&&a.label<n[1]){a.label=n[1],n=i;break}if(n&&a.label<n[2]){a.label=n[2],a.ops.push(i);break}n[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],o=0}finally{r=n=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.AwesomeQR=void 0;var a=r(536),s=function(){function t(e,r,n){var i=Object.assign({},n);console.log("ciao"),Object.keys(t.defaultOptions).forEach((function(e){e in i||Object.defineProperty(i,e,{value:t.defaultOptions[e],enumerable:!0,writable:!0})})),i.components?"object"==typeof i.components&&Object.keys(t.defaultComponentOptions).forEach((function(e){e in i.components?Object.defineProperty(i.components,e,{value:o(o({},t.defaultComponentOptions[e]),i.components[e]),enumerable:!0,writable:!0}):Object.defineProperty(i.components,e,{value:t.defaultComponentOptions[e],enumerable:!0,writable:!0})})):i.components=t.defaultComponentOptions,this.createCanvas=e,this.loadImage=r,this.options=i,this.canvas=this.createCanvas(n.size,n.size),this.canvasContext=this.canvas.getContext("2d"),this.qrCode=new a.QRCodeModel(-1,this.options.correctLevel),Number.isInteger(this.options.maskPattern)&&(this.qrCode.maskPattern=this.options.maskPattern),Number.isInteger(this.options.version)&&(this.qrCode.typeNumber=this.options.version),this.qrCode.addData(this.options.text),this.qrCode.make()}return t.prototype.draw=function(){var t=this;return new Promise((function(e){return t._draw().then(e)}))},t.prototype._clear=function(){this.canvasContext.clearRect(0,0,this.canvas.width,this.canvas.height)},t._removeColor=function(t){var e=t.globalCompositeOperation,r=t.fillStyle;t.globalCompositeOperation="destination-out",t.fillStyle="#FFFFFF",t.fill(),t.globalCompositeOperation=e,t.fillStyle=r},t._prepareRoundedCornerClip=function(t,e,r,o,n,i){t.beginPath(),t.moveTo(e,r),t.arcTo(e+o,r,e+o,r+n,i),t.arcTo(e+o,r+n,e,r+n,i),t.arcTo(e,r+n,e,r,i),t.arcTo(e,r,e+o,r,i),t.closePath()},t._getAverageRGB=function(t,e){var r,o,n={r:0,g:0,b:0},i=-4,a={r:0,g:0,b:0},s=0;o=e.naturalHeight||e.height;var u,l=t(r=e.naturalWidth||e.width,o).getContext("2d");if(!l)return n;l.drawImage(e,0,0);try{u=l.getImageData(0,0,r,o)}catch(t){return n}for(;(i+=20)<u.data.length;)u.data[i]>200||u.data[i+1]>200||u.data[i+2]>200||(++s,a.r+=u.data[i],a.g+=u.data[i+1],a.b+=u.data[i+2]);return a.r=~~(a.r/s),a.g=~~(a.g/s),a.b=~~(a.b/s),a},t._drawDot=function(e,r,o,n,i,a){t._prepareRoundedCornerClip(e,(r+(1-i)/2)*n,(o+(1-i)/2)*n,i*n,i*n,.5*i*a*n),e.fill()},t._drawTelegramDot=function(t,e,r,o,n,i){var a=e*o,s=r*o,u=n*o/2;t.beginPath(),t.moveTo(a,s),t.arcTo(a+o,s,a+o,s+o,i.top||i.right?0:u),t.arcTo(a+o,s+o,a,s+o,i.bottom||i.right?0:u),t.arcTo(a,s+o,a,s,i.bottom||i.left?0:u),t.arcTo(a,s,a+o,s,i.top||i.left?0:u),t.closePath(),t.fill()},t.prototype._drawPoint=function(e,r,o,n,i,a){var s,u,l,h,c=(null===(u=null===(s=this.options.components)||void 0===s?void 0:s.data)||void 0===u?void 0:u.scale)||.4,f=(null===(h=null===(l=this.options.components)||void 0===l?void 0:l.data)||void 0===h?void 0:h.round)||0,p=this.options.drawFunction;return void 0===p?t._drawDot(e,r,o,n,c,f):"telegram"==p?t._drawTelegramDot(e,r,o,n,f,a):"function"==typeof p?p(e,r,o,n,c,f,i,a):void 0},t.prototype._drawFinder=function(e,r,o,n){var i,a,s=Math.min(Math.max((null===(a=null===(i=this.options.components)||void 0===i?void 0:i.finder)||void 0===a?void 0:a.round)||0,0),1);t._prepareRoundedCornerClip(e,r*n,o*n,7*n,7*n,3.5*s*n),e.fill(),t._prepareRoundedCornerClip(e,(r+1)*n,(o+1)*n,5*n,5*n,2.5*s*n),t._removeColor(e),t._prepareRoundedCornerClip(e,(r+2)*n,(o+2)*n,3*n,3*n,1.5*s*n),e.fill()},t.prototype._draw=function(){return n(this,void 0,void 0,(function(){var e,r,o,n,s,u,l,h,c,f,p,g,d,m,v,C,b,y,E,w,P,L,T,_,R,D,k,M,A,B,O,N;return i(this,(function(i){switch(i.label){case 0:for(e=this.qrCode.moduleCount,r=this.options.size,((o=this.options.margin)<0||2*o>=r)&&(o=0),n=r-2*o,s=Math.ceil(o),u=Math.ceil(n/e),h=(l=u*e)+2*s,c=this.createCanvas(h,h),(f=c.getContext("2d")).fillStyle=this.options.colorDark,this._clear(),f.save(),f.translate(s,s),this.options.onEvent&&this.options.onEvent("before-data",f,{nCount:e,nSize:u}),p=a.QRUtil.getPatternPosition(this.qrCode.typeNumber),g=e/2,this.options.logoImage&&(L=Math.min(Math.max(this.options.logoScale,0),1),(T=this.options.logoMargin)<0&&(T=0),D=.5*(l-(R=l*L)),g=Math.floor(D/u)),d=function(t,r){return r>=g&&r<e-g&&t>=g&&t<e-g},m=0;m<e;m++)for(v=0;v<e;v++)if(!(v<8&&(m<8||m>=e-8)||v>=e-8&&m<8||d(m,v))){for(C=6==m&&v>=8&&v<=e-8||6==v&&m>=8&&m<=e-8,b=!1,y=0;y<p.length;y++)for(E=0;E<p.length;E++){if(m>=p[y]-2&&m<=p[y]+2&&v>=p[E]-2&&v<=p[E]+2){b=!0;break}if(m==p[y]&&v==p[E]){b=!0;break}}this.qrCode.isDark(m,v)&&this._drawPoint(f,v,m,u,{isTiming:C,isAlignment:b},{top:0!=m&&this.qrCode.isDark(m-1,v)&&!d(m-1,v)||!1,left:0!=v&&this.qrCode.isDark(m,v-1)&&!d(m,v-1)||!1,right:v!=e-1&&this.qrCode.isDark(m,v+1)&&!d(m,v+1)||!1,bottom:m!=e-1&&this.qrCode.isDark(m+1,v)&&!d(m+1,v)||!1})}return this._drawFinder(f,0,0,u),this._drawFinder(f,e-7,0,u),this._drawFinder(f,0,e-7,u),void 0!==this.options.gradient&&(w=this.options.gradient(f,l),f.fillStyle=w,f.globalCompositeOperation="source-in",f.fillRect(0,0,l,l),f.globalCompositeOperation="source-over"),this.options.whiteMargin&&(f.fillStyle="#FFFFFF",f.fillRect(-s,-s,h,s),f.fillRect(-s,l,h,s),f.fillRect(l,-s,s,h),f.fillRect(-s,-s,s,h)),this.options.logoImage?[4,this.loadImage(this.options.logoImage)]:[3,2];case 1:P=i.sent(),L=Math.min(Math.max(this.options.logoScale,0),1),T=this.options.logoMargin,_=Math.min(Math.max(this.options.logoCornerRadius,0),1),T<0&&(T=0),D=.5*(l-(R=l*L)),t._prepareRoundedCornerClip(f,D,D,R,R,_*R*.5),f.clip(),f.drawImage(P,D,D,R,R),i.label=2;case 2:return this.options.onEvent&&this.options.onEvent("before-background",f,{nCount:e,nSize:u}),k=this.createCanvas(h,h),M=k.getContext("2d"),this.options.backgroundImage?[4,this.loadImage(this.options.backgroundImage)]:[3,4];case 3:return A=i.sent(),B=this.options.backgroundDimming,this.options.autoColor&&(O=t._getAverageRGB(this.createCanvas,A),this.options.colorDark="rgb("+O.r+","+O.g+","+O.b+")"),M.drawImage(A,0,0,A.width,A.height,0,0,h,h),M.rect(0,0,h,h),M.fillStyle=B,M.fill(),[3,5];case 4:M.rect(0,0,h,h),M.fillStyle=this.options.colorLight,M.fill(),i.label=5;case 5:return M.drawImage(c,0,0,h,h),f.drawImage(k,-s,-s,h,h),(N=this.createCanvas(r,r)).getContext("2d").drawImage(c,0,0,r,r),this.canvas=N,function(t){try{return t instanceof HTMLElement}catch(e){return"object"==typeof t&&1===t.nodeType&&"object"==typeof t.style&&"object"==typeof t.ownerDocument}}(this.canvas)?[2,Promise.resolve(this.canvas.toDataURL())]:[2,Promise.resolve(this.canvas.toBuffer())]}}))}))},t.CorrectLevel=a.QRErrorCorrectLevel,t.defaultComponentOptions={data:{scale:1,round:0},finder:{round:0}},t.defaultOptions={text:"",size:400,margin:20,colorDark:"#000000",colorLight:"#ffffff",correctLevel:a.QRErrorCorrectLevel.M,backgroundImage:void 0,backgroundDimming:"rgba(0,0,0,0)",logoImage:void 0,logoScale:.2,logoMargin:4,logoCornerRadius:8,whiteMargin:!0,components:t.defaultComponentOptions,autoColor:!0},t}();e.AwesomeQR=s},607:function(t,e,r){var o=this&&this.__createBinding||(Object.create?function(t,e,r,o){void 0===o&&(o=r),Object.defineProperty(t,o,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,o){void 0===o&&(o=r),t[o]=e[r]}),n=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||e.hasOwnProperty(r)||o(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(r(536),e);var i=r(207);Object.defineProperty(e,"AwesomeQR",{enumerable:!0,get:function(){return i.AwesomeQR}})},536:(t,e)=>{function r(t){var e=encodeURI(t).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return e.length+(e.length!=Number(t)?3:0)}Object.defineProperty(e,"__esModule",{value:!0}),e.QRMath=e.QRUtil=e.QRMaskPattern=e.QRErrorCorrectLevel=e.QRCodeModel=void 0;var o=function(){function t(t){this.mode=i.MODE_8BIT_BYTE,this.parsedData=[],this.data=t;for(var e=[],r=0,o=this.data.length;r<o;r++){var n=[],a=this.data.charCodeAt(r);a>65536?(n[0]=240|(1835008&a)>>>18,n[1]=128|(258048&a)>>>12,n[2]=128|(4032&a)>>>6,n[3]=128|63&a):a>2048?(n[0]=224|(61440&a)>>>12,n[1]=128|(4032&a)>>>6,n[2]=128|63&a):a>128?(n[0]=192|(1984&a)>>>6,n[1]=128|63&a):n[0]=a,e.push(n)}this.parsedData=Array.prototype.concat.apply([],e),this.parsedData.length!=this.data.length&&(this.parsedData.unshift(191),this.parsedData.unshift(187),this.parsedData.unshift(239))}return t.prototype.getLength=function(){return this.parsedData.length},t.prototype.write=function(t){for(var e=0,r=this.parsedData.length;e<r;e++)t.put(this.parsedData[e],8)},t}(),n=function(){function t(t,r){void 0===t&&(t=-1),void 0===r&&(r=e.QRErrorCorrectLevel.L),this.moduleCount=0,this.dataList=[],this.typeNumber=t,this.errorCorrectLevel=r,this.moduleCount=0,this.dataList=[]}return t.prototype.addData=function(t){if(this.typeNumber<=0)this.typeNumber=function(t,o){for(var n=1,i=r(t),a=0,s=c.length;a<s;a++){var u=0;switch(o){case e.QRErrorCorrectLevel.L:u=c[a][0];break;case e.QRErrorCorrectLevel.M:u=c[a][1];break;case e.QRErrorCorrectLevel.Q:u=c[a][2];break;case e.QRErrorCorrectLevel.H:u=c[a][3]}if(i<=u)break;n++}if(n>c.length)throw new Error("Too long data");return n}(t,this.errorCorrectLevel);else{if(this.typeNumber>40)throw new Error("Invalid QR version: "+this.typeNumber);if(!function(t,o,n){var i=r(o),a=t-1,s=0;switch(n){case e.QRErrorCorrectLevel.L:s=c[a][0];break;case e.QRErrorCorrectLevel.M:s=c[a][1];break;case e.QRErrorCorrectLevel.Q:s=c[a][2];break;case e.QRErrorCorrectLevel.H:s=c[a][3]}return i<=s}(this.typeNumber,t,this.errorCorrectLevel))throw new Error("Data is too long for QR version: "+this.typeNumber)}var n=new o(t);this.dataList.push(n),this.dataCache=void 0},t.prototype.isDark=function(t,e){if(t<0||this.moduleCount<=t||e<0||this.moduleCount<=e)throw new Error(t+","+e);return this.modules[t][e]},t.prototype.getModuleCount=function(){return this.moduleCount},t.prototype.make=function(){this.makeImpl(!1,this.getBestMaskPattern())},t.prototype.makeImpl=function(e,r){this.moduleCount=4*this.typeNumber+17,this.modules=new Array(this.moduleCount);for(var o=0;o<this.moduleCount;o++){this.modules[o]=new Array(this.moduleCount);for(var n=0;n<this.moduleCount;n++)this.modules[o][n]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(e,r),this.typeNumber>=7&&this.setupTypeNumber(e),null==this.dataCache&&(this.dataCache=t.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,r)},t.prototype.setupPositionProbePattern=function(t,e){for(var r=-1;r<=7;r++)if(!(t+r<=-1||this.moduleCount<=t+r))for(var o=-1;o<=7;o++)e+o<=-1||this.moduleCount<=e+o||(this.modules[t+r][e+o]=0<=r&&r<=6&&(0==o||6==o)||0<=o&&o<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=o&&o<=4)},t.prototype.getBestMaskPattern=function(){if(Number.isInteger(this.maskPattern)&&Object.values(e.QRMaskPattern).includes(this.maskPattern))return this.maskPattern;for(var t=0,r=0,o=0;o<8;o++){this.makeImpl(!0,o);var n=a.getLostPoint(this);(0==o||t>n)&&(t=n,r=o)}return r},t.prototype.setupTimingPattern=function(){for(var t=8;t<this.moduleCount-8;t++)null==this.modules[t][6]&&(this.modules[t][6]=t%2==0);for(var e=8;e<this.moduleCount-8;e++)null==this.modules[6][e]&&(this.modules[6][e]=e%2==0)},t.prototype.setupPositionAdjustPattern=function(){for(var t=a.getPatternPosition(this.typeNumber),e=0;e<t.length;e++)for(var r=0;r<t.length;r++){var o=t[e],n=t[r];if(null==this.modules[o][n])for(var i=-2;i<=2;i++)for(var s=-2;s<=2;s++)this.modules[o+i][n+s]=-2==i||2==i||-2==s||2==s||0==i&&0==s}},t.prototype.setupTypeNumber=function(t){for(var e=a.getBCHTypeNumber(this.typeNumber),r=0;r<18;r++){var o=!t&&1==(e>>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=o}for(r=0;r<18;r++)o=!t&&1==(e>>r&1),this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=o},t.prototype.setupTypeInfo=function(t,e){for(var r=this.errorCorrectLevel<<3|e,o=a.getBCHTypeInfo(r),n=0;n<15;n++){var i=!t&&1==(o>>n&1);n<6?this.modules[n][8]=i:n<8?this.modules[n+1][8]=i:this.modules[this.moduleCount-15+n][8]=i}for(n=0;n<15;n++)i=!t&&1==(o>>n&1),n<8?this.modules[8][this.moduleCount-n-1]=i:n<9?this.modules[8][15-n-1+1]=i:this.modules[8][15-n-1]=i;this.modules[this.moduleCount-8][8]=!t},t.prototype.mapData=function(t,e){for(var r=-1,o=this.moduleCount-1,n=7,i=0,s=this.moduleCount-1;s>0;s-=2)for(6==s&&s--;;){for(var u=0;u<2;u++)if(null==this.modules[o][s-u]){var l=!1;i<t.length&&(l=1==(t[i]>>>n&1)),a.getMask(e,o,s-u)&&(l=!l),this.modules[o][s-u]=l,-1==--n&&(i++,n=7)}if((o+=r)<0||this.moduleCount<=o){o-=r,r=-r;break}}},t.createData=function(e,r,o){for(var n=l.getRSBlocks(e,r),i=new h,s=0;s<o.length;s++){var u=o[s];i.put(u.mode,4),i.put(u.getLength(),a.getLengthInBits(u.mode,e)),u.write(i)}var c=0;for(s=0;s<n.length;s++)c+=n[s].dataCount;if(i.getLengthInBits()>8*c)throw new Error("code length overflow. ("+i.getLengthInBits()+">"+8*c+")");for(i.getLengthInBits()+4<=8*c&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=8*c||(i.put(t.PAD0,8),i.getLengthInBits()>=8*c));)i.put(t.PAD1,8);return t.createBytes(i,n)},t.createBytes=function(t,e){for(var r=0,o=0,n=0,i=new Array(e.length),s=new Array(e.length),l=0;l<e.length;l++){var h=e[l].dataCount,c=e[l].totalCount-h;o=Math.max(o,h),n=Math.max(n,c),i[l]=new Array(h);for(var f=0;f<i[l].length;f++)i[l][f]=255&t.buffer[f+r];r+=h;var p=a.getErrorCorrectPolynomial(c),g=new u(i[l],p.getLength()-1).mod(p);for(s[l]=new Array(p.getLength()-1),f=0;f<s[l].length;f++){var d=f+g.getLength()-s[l].length;s[l][f]=d>=0?g.get(d):0}}var m=0;for(f=0;f<e.length;f++)m+=e[f].totalCount;var v=new Array(m),C=0;for(f=0;f<o;f++)for(l=0;l<e.length;l++)f<i[l].length&&(v[C++]=i[l][f]);for(f=0;f<n;f++)for(l=0;l<e.length;l++)f<s[l].length&&(v[C++]=s[l][f]);return v},t.PAD0=236,t.PAD1=17,t}();e.QRCodeModel=n,e.QRErrorCorrectLevel={L:1,M:0,Q:3,H:2};var i={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8};e.QRMaskPattern={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var a=function(){function t(){}return t.getBCHTypeInfo=function(e){for(var r=e<<10;t.getBCHDigit(r)-t.getBCHDigit(t.G15)>=0;)r^=t.G15<<t.getBCHDigit(r)-t.getBCHDigit(t.G15);return(e<<10|r)^t.G15_MASK},t.getBCHTypeNumber=function(e){for(var r=e<<12;t.getBCHDigit(r)-t.getBCHDigit(t.G18)>=0;)r^=t.G18<<t.getBCHDigit(r)-t.getBCHDigit(t.G18);return e<<12|r},t.getBCHDigit=function(t){for(var e=0;0!=t;)e++,t>>>=1;return e},t.getPatternPosition=function(e){return t.PATTERN_POSITION_TABLE[e-1]},t.getMask=function(t,r,o){switch(t){case e.QRMaskPattern.PATTERN000:return(r+o)%2==0;case e.QRMaskPattern.PATTERN001:return r%2==0;case e.QRMaskPattern.PATTERN010:return o%3==0;case e.QRMaskPattern.PATTERN011:return(r+o)%3==0;case e.QRMaskPattern.PATTERN100:return(Math.floor(r/2)+Math.floor(o/3))%2==0;case e.QRMaskPattern.PATTERN101:return r*o%2+r*o%3==0;case e.QRMaskPattern.PATTERN110:return(r*o%2+r*o%3)%2==0;case e.QRMaskPattern.PATTERN111:return(r*o%3+(r+o)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},t.getErrorCorrectPolynomial=function(t){for(var e=new u([1],0),r=0;r<t;r++)e=e.multiply(new u([1,s.gexp(r)],0));return e},t.getLengthInBits=function(t,e){if(1<=e&&e<10)switch(t){case i.MODE_NUMBER:return 10;case i.MODE_ALPHA_NUM:return 9;case i.MODE_8BIT_BYTE:case i.MODE_KANJI:return 8;default:throw new Error("mode:"+t)}else if(e<27)switch(t){case i.MODE_NUMBER:return 12;case i.MODE_ALPHA_NUM:return 11;case i.MODE_8BIT_BYTE:return 16;case i.MODE_KANJI:return 10;default:throw new Error("mode:"+t)}else{if(!(e<41))throw new Error("type:"+e);switch(t){case i.MODE_NUMBER:return 14;case i.MODE_ALPHA_NUM:return 13;case i.MODE_8BIT_BYTE:return 16;case i.MODE_KANJI:return 12;default:throw new Error("mode:"+t)}}},t.getLostPoint=function(t){for(var e=t.getModuleCount(),r=0,o=0;o<e;o++)for(var n=0;n<e;n++){for(var i=0,a=t.isDark(o,n),s=-1;s<=1;s++)if(!(o+s<0||e<=o+s))for(var u=-1;u<=1;u++)n+u<0||e<=n+u||0==s&&0==u||a==t.isDark(o+s,n+u)&&i++;i>5&&(r+=3+i-5)}for(o=0;o<e-1;o++)for(n=0;n<e-1;n++){var l=0;t.isDark(o,n)&&l++,t.isDark(o+1,n)&&l++,t.isDark(o,n+1)&&l++,t.isDark(o+1,n+1)&&l++,0!=l&&4!=l||(r+=3)}for(o=0;o<e;o++)for(n=0;n<e-6;n++)t.isDark(o,n)&&!t.isDark(o,n+1)&&t.isDark(o,n+2)&&t.isDark(o,n+3)&&t.isDark(o,n+4)&&!t.isDark(o,n+5)&&t.isDark(o,n+6)&&(r+=40);for(n=0;n<e;n++)for(o=0;o<e-6;o++)t.isDark(o,n)&&!t.isDark(o+1,n)&&t.isDark(o+2,n)&&t.isDark(o+3,n)&&t.isDark(o+4,n)&&!t.isDark(o+5,n)&&t.isDark(o+6,n)&&(r+=40);var h=0;for(n=0;n<e;n++)for(o=0;o<e;o++)t.isDark(o,n)&&h++;return r+Math.abs(100*h/e/e-50)/5*10},t.PATTERN_POSITION_TABLE=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],t.G15=1335,t.G18=7973,t.G15_MASK=21522,t}();e.QRUtil=a;var s=function(){function t(){}return t.glog=function(e){if(e<1)throw new Error("glog("+e+")");return t.LOG_TABLE[e]},t.gexp=function(e){for(;e<0;)e+=255;for(;e>=256;)e-=255;return t.EXP_TABLE[e]},t.EXP_TABLE=new Array(256),t.LOG_TABLE=new Array(256),t._constructor=function(){for(var e=0;e<8;e++)t.EXP_TABLE[e]=1<<e;for(e=8;e<256;e++)t.EXP_TABLE[e]=t.EXP_TABLE[e-4]^t.EXP_TABLE[e-5]^t.EXP_TABLE[e-6]^t.EXP_TABLE[e-8];for(e=0;e<255;e++)t.LOG_TABLE[t.EXP_TABLE[e]]=e}(),t}();e.QRMath=s;var u=function(){function t(t,e){if(null==t.length)throw new Error(t.length+"/"+e);for(var r=0;r<t.length&&0==t[r];)r++;this.num=new Array(t.length-r+e);for(var o=0;o<t.length-r;o++)this.num[o]=t[o+r]}return t.prototype.get=function(t){return this.num[t]},t.prototype.getLength=function(){return this.num.length},t.prototype.multiply=function(e){for(var r=new Array(this.getLength()+e.getLength()-1),o=0;o<this.getLength();o++)for(var n=0;n<e.getLength();n++)r[o+n]^=s.gexp(s.glog(this.get(o))+s.glog(e.get(n)));return new t(r,0)},t.prototype.mod=function(e){if(this.getLength()-e.getLength()<0)return this;for(var r=s.glog(this.get(0))-s.glog(e.get(0)),o=new Array(this.getLength()),n=0;n<this.getLength();n++)o[n]=this.get(n);for(n=0;n<e.getLength();n++)o[n]^=s.gexp(s.glog(e.get(n))+r);return new t(o,0).mod(e)},t}(),l=function(){function t(t,e){this.totalCount=t,this.dataCount=e}return t.getRSBlocks=function(e,r){var o=t.getRsBlockTable(e,r);if(null==o)throw new Error("bad rs block @ typeNumber:"+e+"/errorCorrectLevel:"+r);for(var n=o.length/3,i=[],a=0;a<n;a++)for(var s=o[3*a+0],u=o[3*a+1],l=o[3*a+2],h=0;h<s;h++)i.push(new t(u,l));return i},t.getRsBlockTable=function(r,o){switch(o){case e.QRErrorCorrectLevel.L:return t.RS_BLOCK_TABLE[4*(r-1)+0];case e.QRErrorCorrectLevel.M:return t.RS_BLOCK_TABLE[4*(r-1)+1];case e.QRErrorCorrectLevel.Q:return t.RS_BLOCK_TABLE[4*(r-1)+2];case e.QRErrorCorrectLevel.H:return t.RS_BLOCK_TABLE[4*(r-1)+3];default:return}},t.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],t}(),h=function(){function t(){this.buffer=[],this.length=0}return t.prototype.get=function(t){var e=Math.floor(t/8);return 1==(this.buffer[e]>>>7-t%8&1)},t.prototype.put=function(t,e){for(var r=0;r<e;r++)this.putBit(1==(t>>>e-r-1&1))},t.prototype.getLengthInBits=function(){return this.length},t.prototype.putBit=function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++},t}(),c=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]]}},e={};return function r(o){var n=e[o];if(void 0!==n)return n.exports;var i=e[o]={exports:{}};return t[o].call(i.exports,i,i.exports,r),i.exports}(607)})()));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.AwesomeQR=e():t.AwesomeQR=e()}(this,(()=>(()=>{"use strict";var t={207:function(t,e,r){var o=this&&this.__assign||function(){return o=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},o.apply(this,arguments)},n=this&&this.__awaiter||function(t,e,r,o){return new(r||(r=Promise))((function(n,i){function a(t){try{u(o.next(t))}catch(t){i(t)}}function s(t){try{u(o.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}u((o=o.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var r,o,n,i,a={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,o&&(n=2&i[0]?o.return:i[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,i[1])).done)return n;switch(o=0,n&&(i=[2&i[0],n.value]),i[0]){case 0:case 1:n=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((n=(n=a.trys).length>0&&n[n.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!n||i[1]>n[0]&&i[1]<n[3])){a.label=i[1];break}if(6===i[0]&&a.label<n[1]){a.label=n[1],n=i;break}if(n&&a.label<n[2]){a.label=n[2],a.ops.push(i);break}n[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],o=0}finally{r=n=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.AwesomeQR=void 0;var a=r(536),s=function(){function t(e,r,n,i){var s=Object.assign({},i);Object.keys(t.defaultOptions).forEach((function(e){e in s||Object.defineProperty(s,e,{value:t.defaultOptions[e],enumerable:!0,writable:!0})})),s.components?"object"==typeof s.components&&Object.keys(t.defaultComponentOptions).forEach((function(e){e in s.components?Object.defineProperty(s.components,e,{value:o(o({},t.defaultComponentOptions[e]),s.components[e]),enumerable:!0,writable:!0}):Object.defineProperty(s.components,e,{value:t.defaultComponentOptions[e],enumerable:!0,writable:!0})})):s.components=t.defaultComponentOptions,this.createCanvas=r,this.loadImage=n,this.options=s,this.canvas=e,this.canvas.width=this.options.size,this.canvas.height=this.options.size,this.canvasContext=this.canvas.getContext("2d"),this.qrCode=new a.QRCodeModel(-1,this.options.correctLevel),Number.isInteger(this.options.maskPattern)&&(this.qrCode.maskPattern=this.options.maskPattern),Number.isInteger(this.options.version)&&(this.qrCode.typeNumber=this.options.version),this.qrCode.addData(this.options.text),this.qrCode.make()}return t.prototype.draw=function(){var t=this;return new Promise((function(e){return t._draw().then(e)}))},t.prototype._clear=function(){this.canvasContext.clearRect(0,0,this.canvas.width,this.canvas.height)},t._removeColor=function(t){var e=t.globalCompositeOperation,r=t.fillStyle;t.globalCompositeOperation="destination-out",t.fillStyle="#FFFFFF",t.fill(),t.globalCompositeOperation=e,t.fillStyle=r},t._prepareRoundedCornerClip=function(t,e,r,o,n,i){t.beginPath(),t.moveTo(e,r),t.arcTo(e+o,r,e+o,r+n,i),t.arcTo(e+o,r+n,e,r+n,i),t.arcTo(e,r+n,e,r,i),t.arcTo(e,r,e+o,r,i),t.closePath()},t._getAverageRGB=function(t,e){var r,o,n={r:0,g:0,b:0},i=-4,a={r:0,g:0,b:0},s=0;o=e.naturalHeight||e.height;var u,l=t(r=e.naturalWidth||e.width,o).getContext("2d");if(!l)return n;l.drawImage(e,0,0);try{u=l.getImageData(0,0,r,o)}catch(t){return n}for(;(i+=20)<u.data.length;)u.data[i]>200||u.data[i+1]>200||u.data[i+2]>200||(++s,a.r+=u.data[i],a.g+=u.data[i+1],a.b+=u.data[i+2]);return a.r=~~(a.r/s),a.g=~~(a.g/s),a.b=~~(a.b/s),a},t._drawDot=function(e,r,o,n,i,a){t._prepareRoundedCornerClip(e,(r+(1-i)/2)*n,(o+(1-i)/2)*n,i*n,i*n,.5*i*a*n),e.fill()},t._drawTelegramDot=function(t,e,r,o,n,i){var a=e*o,s=r*o,u=n*o/2;t.beginPath(),t.moveTo(a,s),t.arcTo(a+o,s,a+o,s+o,i.top||i.right?0:u),t.arcTo(a+o,s+o,a,s+o,i.bottom||i.right?0:u),t.arcTo(a,s+o,a,s,i.bottom||i.left?0:u),t.arcTo(a,s,a+o,s,i.top||i.left?0:u),t.closePath(),t.fill()},t.prototype._drawPoint=function(e,r,o,n,i,a){var s,u,l,h,c=(null===(u=null===(s=this.options.components)||void 0===s?void 0:s.data)||void 0===u?void 0:u.scale)||.4,f=(null===(h=null===(l=this.options.components)||void 0===l?void 0:l.data)||void 0===h?void 0:h.round)||0,p=this.options.drawFunction;return void 0===p?t._drawDot(e,r,o,n,c,f):"telegram"==p?t._drawTelegramDot(e,r,o,n,f,a):"function"==typeof p?p(e,r,o,n,c,f,i,a):void 0},t.prototype._drawFinder=function(e,r,o,n){var i,a,s=Math.min(Math.max((null===(a=null===(i=this.options.components)||void 0===i?void 0:i.finder)||void 0===a?void 0:a.round)||0,0),1);t._prepareRoundedCornerClip(e,r*n,o*n,7*n,7*n,3.5*s*n),e.fill(),t._prepareRoundedCornerClip(e,(r+1)*n,(o+1)*n,5*n,5*n,2.5*s*n),t._removeColor(e),t._prepareRoundedCornerClip(e,(r+2)*n,(o+2)*n,3*n,3*n,1.5*s*n),e.fill()},t.prototype._draw=function(){return n(this,void 0,void 0,(function(){var e,r,o,n,s,u,l,h,c,f,p,g,d,m,v,C,b,y,E,w,P,L,T,_,R,D,k,M,A,B,O;return i(this,(function(i){switch(i.label){case 0:for(e=this.qrCode.moduleCount,r=this.options.size,((o=this.options.margin)<0||2*o>=r)&&(o=0),n=r-2*o,s=Math.ceil(o),u=Math.ceil(n/e),h=(l=u*e)+2*s,c=this.createCanvas(h,h),(f=c.getContext("2d")).fillStyle=this.options.colorDark,this._clear(),f.save(),f.translate(s,s),this.options.onEvent&&this.options.onEvent("before-data",f,{nCount:e,nSize:u}),p=a.QRUtil.getPatternPosition(this.qrCode.typeNumber),g=e/2,this.options.logoImage&&(L=Math.min(Math.max(this.options.logoScale,0),1),(T=this.options.logoMargin)<0&&(T=0),D=.5*(l-(R=l*L)),g=Math.floor(D/u)),d=function(t,r){return r>=g&&r<e-g&&t>=g&&t<e-g},m=0;m<e;m++)for(v=0;v<e;v++)if(!(v<8&&(m<8||m>=e-8)||v>=e-8&&m<8||d(m,v))){for(C=6==m&&v>=8&&v<=e-8||6==v&&m>=8&&m<=e-8,b=!1,y=0;y<p.length;y++)for(E=0;E<p.length;E++){if(m>=p[y]-2&&m<=p[y]+2&&v>=p[E]-2&&v<=p[E]+2){b=!0;break}if(m==p[y]&&v==p[E]){b=!0;break}}this.qrCode.isDark(m,v)&&this._drawPoint(f,v,m,u,{isTiming:C,isAlignment:b},{top:0!=m&&this.qrCode.isDark(m-1,v)&&!d(m-1,v)||!1,left:0!=v&&this.qrCode.isDark(m,v-1)&&!d(m,v-1)||!1,right:v!=e-1&&this.qrCode.isDark(m,v+1)&&!d(m,v+1)||!1,bottom:m!=e-1&&this.qrCode.isDark(m+1,v)&&!d(m+1,v)||!1})}return this._drawFinder(f,0,0,u),this._drawFinder(f,e-7,0,u),this._drawFinder(f,0,e-7,u),void 0!==this.options.gradient&&(w=this.options.gradient(f,l),f.fillStyle=w,f.globalCompositeOperation="source-in",f.fillRect(0,0,l,l),f.globalCompositeOperation="source-over"),this.options.whiteMargin&&(f.fillStyle="#FFFFFF",f.fillRect(-s,-s,h,s),f.fillRect(-s,l,h,s),f.fillRect(l,-s,s,h),f.fillRect(-s,-s,s,h)),this.options.logoImage?[4,this.loadImage(this.options.logoImage)]:[3,2];case 1:P=i.sent(),L=Math.min(Math.max(this.options.logoScale,0),1),T=this.options.logoMargin,_=Math.min(Math.max(this.options.logoCornerRadius,0),1),T<0&&(T=0),D=.5*(l-(R=l*L)),t._prepareRoundedCornerClip(f,D,D,R,R,_*R*.5),f.clip(),f.drawImage(P,D,D,R,R),i.label=2;case 2:return this.options.onEvent&&this.options.onEvent("before-background",f,{nCount:e,nSize:u}),k=this.createCanvas(h,h),M=k.getContext("2d"),this.options.backgroundImage?[4,this.loadImage(this.options.backgroundImage)]:[3,4];case 3:return A=i.sent(),B=this.options.backgroundDimming,this.options.autoColor&&(O=t._getAverageRGB(this.createCanvas,A),this.options.colorDark="rgb("+O.r+","+O.g+","+O.b+")"),M.drawImage(A,0,0,A.width,A.height,0,0,h,h),M.rect(0,0,h,h),M.fillStyle=B,M.fill(),[3,5];case 4:M.rect(0,0,h,h),M.fillStyle=this.options.colorLight,M.fill(),i.label=5;case 5:return M.drawImage(c,0,0,h,h),f.drawImage(k,-s,-s,h,h),this.canvasContext.drawImage(c,0,0,r,r),function(t){try{return t instanceof HTMLElement}catch(e){return"object"==typeof t&&1===t.nodeType&&"object"==typeof t.style&&"object"==typeof t.ownerDocument}}(this.canvas)?[2,Promise.resolve(this.canvas.toDataURL())]:[2,Promise.resolve(this.canvas.toBuffer())]}}))}))},t.CorrectLevel=a.QRErrorCorrectLevel,t.defaultComponentOptions={data:{scale:1,round:0},finder:{round:0}},t.defaultOptions={text:"",size:400,margin:20,colorDark:"#000000",colorLight:"#ffffff",correctLevel:a.QRErrorCorrectLevel.M,backgroundImage:void 0,backgroundDimming:"rgba(0,0,0,0)",logoImage:void 0,logoScale:.2,logoMargin:4,logoCornerRadius:8,whiteMargin:!0,components:t.defaultComponentOptions,autoColor:!0},t}();e.AwesomeQR=s},607:function(t,e,r){var o=this&&this.__createBinding||(Object.create?function(t,e,r,o){void 0===o&&(o=r),Object.defineProperty(t,o,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,o){void 0===o&&(o=r),t[o]=e[r]}),n=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||e.hasOwnProperty(r)||o(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(r(536),e);var i=r(207);Object.defineProperty(e,"AwesomeQR",{enumerable:!0,get:function(){return i.AwesomeQR}})},536:(t,e)=>{function r(t){var e=encodeURI(t).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return e.length+(e.length!=Number(t)?3:0)}Object.defineProperty(e,"__esModule",{value:!0}),e.QRMath=e.QRUtil=e.QRMaskPattern=e.QRErrorCorrectLevel=e.QRCodeModel=void 0;var o=function(){function t(t){this.mode=i.MODE_8BIT_BYTE,this.parsedData=[],this.data=t;for(var e=[],r=0,o=this.data.length;r<o;r++){var n=[],a=this.data.charCodeAt(r);a>65536?(n[0]=240|(1835008&a)>>>18,n[1]=128|(258048&a)>>>12,n[2]=128|(4032&a)>>>6,n[3]=128|63&a):a>2048?(n[0]=224|(61440&a)>>>12,n[1]=128|(4032&a)>>>6,n[2]=128|63&a):a>128?(n[0]=192|(1984&a)>>>6,n[1]=128|63&a):n[0]=a,e.push(n)}this.parsedData=Array.prototype.concat.apply([],e),this.parsedData.length!=this.data.length&&(this.parsedData.unshift(191),this.parsedData.unshift(187),this.parsedData.unshift(239))}return t.prototype.getLength=function(){return this.parsedData.length},t.prototype.write=function(t){for(var e=0,r=this.parsedData.length;e<r;e++)t.put(this.parsedData[e],8)},t}(),n=function(){function t(t,r){void 0===t&&(t=-1),void 0===r&&(r=e.QRErrorCorrectLevel.L),this.moduleCount=0,this.dataList=[],this.typeNumber=t,this.errorCorrectLevel=r,this.moduleCount=0,this.dataList=[]}return t.prototype.addData=function(t){if(this.typeNumber<=0)this.typeNumber=function(t,o){for(var n=1,i=r(t),a=0,s=c.length;a<s;a++){var u=0;switch(o){case e.QRErrorCorrectLevel.L:u=c[a][0];break;case e.QRErrorCorrectLevel.M:u=c[a][1];break;case e.QRErrorCorrectLevel.Q:u=c[a][2];break;case e.QRErrorCorrectLevel.H:u=c[a][3]}if(i<=u)break;n++}if(n>c.length)throw new Error("Too long data");return n}(t,this.errorCorrectLevel);else{if(this.typeNumber>40)throw new Error("Invalid QR version: "+this.typeNumber);if(!function(t,o,n){var i=r(o),a=t-1,s=0;switch(n){case e.QRErrorCorrectLevel.L:s=c[a][0];break;case e.QRErrorCorrectLevel.M:s=c[a][1];break;case e.QRErrorCorrectLevel.Q:s=c[a][2];break;case e.QRErrorCorrectLevel.H:s=c[a][3]}return i<=s}(this.typeNumber,t,this.errorCorrectLevel))throw new Error("Data is too long for QR version: "+this.typeNumber)}var n=new o(t);this.dataList.push(n),this.dataCache=void 0},t.prototype.isDark=function(t,e){if(t<0||this.moduleCount<=t||e<0||this.moduleCount<=e)throw new Error(t+","+e);return this.modules[t][e]},t.prototype.getModuleCount=function(){return this.moduleCount},t.prototype.make=function(){this.makeImpl(!1,this.getBestMaskPattern())},t.prototype.makeImpl=function(e,r){this.moduleCount=4*this.typeNumber+17,this.modules=new Array(this.moduleCount);for(var o=0;o<this.moduleCount;o++){this.modules[o]=new Array(this.moduleCount);for(var n=0;n<this.moduleCount;n++)this.modules[o][n]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(e,r),this.typeNumber>=7&&this.setupTypeNumber(e),null==this.dataCache&&(this.dataCache=t.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,r)},t.prototype.setupPositionProbePattern=function(t,e){for(var r=-1;r<=7;r++)if(!(t+r<=-1||this.moduleCount<=t+r))for(var o=-1;o<=7;o++)e+o<=-1||this.moduleCount<=e+o||(this.modules[t+r][e+o]=0<=r&&r<=6&&(0==o||6==o)||0<=o&&o<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=o&&o<=4)},t.prototype.getBestMaskPattern=function(){if(Number.isInteger(this.maskPattern)&&Object.values(e.QRMaskPattern).includes(this.maskPattern))return this.maskPattern;for(var t=0,r=0,o=0;o<8;o++){this.makeImpl(!0,o);var n=a.getLostPoint(this);(0==o||t>n)&&(t=n,r=o)}return r},t.prototype.setupTimingPattern=function(){for(var t=8;t<this.moduleCount-8;t++)null==this.modules[t][6]&&(this.modules[t][6]=t%2==0);for(var e=8;e<this.moduleCount-8;e++)null==this.modules[6][e]&&(this.modules[6][e]=e%2==0)},t.prototype.setupPositionAdjustPattern=function(){for(var t=a.getPatternPosition(this.typeNumber),e=0;e<t.length;e++)for(var r=0;r<t.length;r++){var o=t[e],n=t[r];if(null==this.modules[o][n])for(var i=-2;i<=2;i++)for(var s=-2;s<=2;s++)this.modules[o+i][n+s]=-2==i||2==i||-2==s||2==s||0==i&&0==s}},t.prototype.setupTypeNumber=function(t){for(var e=a.getBCHTypeNumber(this.typeNumber),r=0;r<18;r++){var o=!t&&1==(e>>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=o}for(r=0;r<18;r++)o=!t&&1==(e>>r&1),this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=o},t.prototype.setupTypeInfo=function(t,e){for(var r=this.errorCorrectLevel<<3|e,o=a.getBCHTypeInfo(r),n=0;n<15;n++){var i=!t&&1==(o>>n&1);n<6?this.modules[n][8]=i:n<8?this.modules[n+1][8]=i:this.modules[this.moduleCount-15+n][8]=i}for(n=0;n<15;n++)i=!t&&1==(o>>n&1),n<8?this.modules[8][this.moduleCount-n-1]=i:n<9?this.modules[8][15-n-1+1]=i:this.modules[8][15-n-1]=i;this.modules[this.moduleCount-8][8]=!t},t.prototype.mapData=function(t,e){for(var r=-1,o=this.moduleCount-1,n=7,i=0,s=this.moduleCount-1;s>0;s-=2)for(6==s&&s--;;){for(var u=0;u<2;u++)if(null==this.modules[o][s-u]){var l=!1;i<t.length&&(l=1==(t[i]>>>n&1)),a.getMask(e,o,s-u)&&(l=!l),this.modules[o][s-u]=l,-1==--n&&(i++,n=7)}if((o+=r)<0||this.moduleCount<=o){o-=r,r=-r;break}}},t.createData=function(e,r,o){for(var n=l.getRSBlocks(e,r),i=new h,s=0;s<o.length;s++){var u=o[s];i.put(u.mode,4),i.put(u.getLength(),a.getLengthInBits(u.mode,e)),u.write(i)}var c=0;for(s=0;s<n.length;s++)c+=n[s].dataCount;if(i.getLengthInBits()>8*c)throw new Error("code length overflow. ("+i.getLengthInBits()+">"+8*c+")");for(i.getLengthInBits()+4<=8*c&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=8*c||(i.put(t.PAD0,8),i.getLengthInBits()>=8*c));)i.put(t.PAD1,8);return t.createBytes(i,n)},t.createBytes=function(t,e){for(var r=0,o=0,n=0,i=new Array(e.length),s=new Array(e.length),l=0;l<e.length;l++){var h=e[l].dataCount,c=e[l].totalCount-h;o=Math.max(o,h),n=Math.max(n,c),i[l]=new Array(h);for(var f=0;f<i[l].length;f++)i[l][f]=255&t.buffer[f+r];r+=h;var p=a.getErrorCorrectPolynomial(c),g=new u(i[l],p.getLength()-1).mod(p);for(s[l]=new Array(p.getLength()-1),f=0;f<s[l].length;f++){var d=f+g.getLength()-s[l].length;s[l][f]=d>=0?g.get(d):0}}var m=0;for(f=0;f<e.length;f++)m+=e[f].totalCount;var v=new Array(m),C=0;for(f=0;f<o;f++)for(l=0;l<e.length;l++)f<i[l].length&&(v[C++]=i[l][f]);for(f=0;f<n;f++)for(l=0;l<e.length;l++)f<s[l].length&&(v[C++]=s[l][f]);return v},t.PAD0=236,t.PAD1=17,t}();e.QRCodeModel=n,e.QRErrorCorrectLevel={L:1,M:0,Q:3,H:2};var i={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8};e.QRMaskPattern={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var a=function(){function t(){}return t.getBCHTypeInfo=function(e){for(var r=e<<10;t.getBCHDigit(r)-t.getBCHDigit(t.G15)>=0;)r^=t.G15<<t.getBCHDigit(r)-t.getBCHDigit(t.G15);return(e<<10|r)^t.G15_MASK},t.getBCHTypeNumber=function(e){for(var r=e<<12;t.getBCHDigit(r)-t.getBCHDigit(t.G18)>=0;)r^=t.G18<<t.getBCHDigit(r)-t.getBCHDigit(t.G18);return e<<12|r},t.getBCHDigit=function(t){for(var e=0;0!=t;)e++,t>>>=1;return e},t.getPatternPosition=function(e){return t.PATTERN_POSITION_TABLE[e-1]},t.getMask=function(t,r,o){switch(t){case e.QRMaskPattern.PATTERN000:return(r+o)%2==0;case e.QRMaskPattern.PATTERN001:return r%2==0;case e.QRMaskPattern.PATTERN010:return o%3==0;case e.QRMaskPattern.PATTERN011:return(r+o)%3==0;case e.QRMaskPattern.PATTERN100:return(Math.floor(r/2)+Math.floor(o/3))%2==0;case e.QRMaskPattern.PATTERN101:return r*o%2+r*o%3==0;case e.QRMaskPattern.PATTERN110:return(r*o%2+r*o%3)%2==0;case e.QRMaskPattern.PATTERN111:return(r*o%3+(r+o)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},t.getErrorCorrectPolynomial=function(t){for(var e=new u([1],0),r=0;r<t;r++)e=e.multiply(new u([1,s.gexp(r)],0));return e},t.getLengthInBits=function(t,e){if(1<=e&&e<10)switch(t){case i.MODE_NUMBER:return 10;case i.MODE_ALPHA_NUM:return 9;case i.MODE_8BIT_BYTE:case i.MODE_KANJI:return 8;default:throw new Error("mode:"+t)}else if(e<27)switch(t){case i.MODE_NUMBER:return 12;case i.MODE_ALPHA_NUM:return 11;case i.MODE_8BIT_BYTE:return 16;case i.MODE_KANJI:return 10;default:throw new Error("mode:"+t)}else{if(!(e<41))throw new Error("type:"+e);switch(t){case i.MODE_NUMBER:return 14;case i.MODE_ALPHA_NUM:return 13;case i.MODE_8BIT_BYTE:return 16;case i.MODE_KANJI:return 12;default:throw new Error("mode:"+t)}}},t.getLostPoint=function(t){for(var e=t.getModuleCount(),r=0,o=0;o<e;o++)for(var n=0;n<e;n++){for(var i=0,a=t.isDark(o,n),s=-1;s<=1;s++)if(!(o+s<0||e<=o+s))for(var u=-1;u<=1;u++)n+u<0||e<=n+u||0==s&&0==u||a==t.isDark(o+s,n+u)&&i++;i>5&&(r+=3+i-5)}for(o=0;o<e-1;o++)for(n=0;n<e-1;n++){var l=0;t.isDark(o,n)&&l++,t.isDark(o+1,n)&&l++,t.isDark(o,n+1)&&l++,t.isDark(o+1,n+1)&&l++,0!=l&&4!=l||(r+=3)}for(o=0;o<e;o++)for(n=0;n<e-6;n++)t.isDark(o,n)&&!t.isDark(o,n+1)&&t.isDark(o,n+2)&&t.isDark(o,n+3)&&t.isDark(o,n+4)&&!t.isDark(o,n+5)&&t.isDark(o,n+6)&&(r+=40);for(n=0;n<e;n++)for(o=0;o<e-6;o++)t.isDark(o,n)&&!t.isDark(o+1,n)&&t.isDark(o+2,n)&&t.isDark(o+3,n)&&t.isDark(o+4,n)&&!t.isDark(o+5,n)&&t.isDark(o+6,n)&&(r+=40);var h=0;for(n=0;n<e;n++)for(o=0;o<e;o++)t.isDark(o,n)&&h++;return r+Math.abs(100*h/e/e-50)/5*10},t.PATTERN_POSITION_TABLE=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],t.G15=1335,t.G18=7973,t.G15_MASK=21522,t}();e.QRUtil=a;var s=function(){function t(){}return t.glog=function(e){if(e<1)throw new Error("glog("+e+")");return t.LOG_TABLE[e]},t.gexp=function(e){for(;e<0;)e+=255;for(;e>=256;)e-=255;return t.EXP_TABLE[e]},t.EXP_TABLE=new Array(256),t.LOG_TABLE=new Array(256),t._constructor=function(){for(var e=0;e<8;e++)t.EXP_TABLE[e]=1<<e;for(e=8;e<256;e++)t.EXP_TABLE[e]=t.EXP_TABLE[e-4]^t.EXP_TABLE[e-5]^t.EXP_TABLE[e-6]^t.EXP_TABLE[e-8];for(e=0;e<255;e++)t.LOG_TABLE[t.EXP_TABLE[e]]=e}(),t}();e.QRMath=s;var u=function(){function t(t,e){if(null==t.length)throw new Error(t.length+"/"+e);for(var r=0;r<t.length&&0==t[r];)r++;this.num=new Array(t.length-r+e);for(var o=0;o<t.length-r;o++)this.num[o]=t[o+r]}return t.prototype.get=function(t){return this.num[t]},t.prototype.getLength=function(){return this.num.length},t.prototype.multiply=function(e){for(var r=new Array(this.getLength()+e.getLength()-1),o=0;o<this.getLength();o++)for(var n=0;n<e.getLength();n++)r[o+n]^=s.gexp(s.glog(this.get(o))+s.glog(e.get(n)));return new t(r,0)},t.prototype.mod=function(e){if(this.getLength()-e.getLength()<0)return this;for(var r=s.glog(this.get(0))-s.glog(e.get(0)),o=new Array(this.getLength()),n=0;n<this.getLength();n++)o[n]=this.get(n);for(n=0;n<e.getLength();n++)o[n]^=s.gexp(s.glog(e.get(n))+r);return new t(o,0).mod(e)},t}(),l=function(){function t(t,e){this.totalCount=t,this.dataCount=e}return t.getRSBlocks=function(e,r){var o=t.getRsBlockTable(e,r);if(null==o)throw new Error("bad rs block @ typeNumber:"+e+"/errorCorrectLevel:"+r);for(var n=o.length/3,i=[],a=0;a<n;a++)for(var s=o[3*a+0],u=o[3*a+1],l=o[3*a+2],h=0;h<s;h++)i.push(new t(u,l));return i},t.getRsBlockTable=function(r,o){switch(o){case e.QRErrorCorrectLevel.L:return t.RS_BLOCK_TABLE[4*(r-1)+0];case e.QRErrorCorrectLevel.M:return t.RS_BLOCK_TABLE[4*(r-1)+1];case e.QRErrorCorrectLevel.Q:return t.RS_BLOCK_TABLE[4*(r-1)+2];case e.QRErrorCorrectLevel.H:return t.RS_BLOCK_TABLE[4*(r-1)+3];default:return}},t.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],t}(),h=function(){function t(){this.buffer=[],this.length=0}return t.prototype.get=function(t){var e=Math.floor(t/8);return 1==(this.buffer[e]>>>7-t%8&1)},t.prototype.put=function(t,e){for(var r=0;r<e;r++)this.putBit(1==(t>>>e-r-1&1))},t.prototype.getLengthInBits=function(){return this.length},t.prototype.putBit=function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++},t}(),c=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]]}},e={};return function r(o){var n=e[o];if(void 0!==n)return n.exports;var i=e[o]={exports:{}};return t[o].call(i.exports,i,i.exports,r),i.exports}(607)})()));

@@ -198,3 +198,3 @@ /// <reference types="node" />

static defaultOptions: Options;
constructor(createCanvas: Function, loadImage: Function, options: Partial<Options>);
constructor(canvas: any, createCanvas: Function, loadImage: Function, options: Partial<Options>);
draw(): Promise<Buffer | ArrayBuffer | string | undefined>;

@@ -201,0 +201,0 @@ private _clear;

@@ -54,5 +54,4 @@ "use strict";

var AwesomeQR = /** @class */ (function () {
function AwesomeQR(createCanvas, loadImage, options) {
function AwesomeQR(canvas, createCanvas, loadImage, options) {
var _options = Object.assign({}, options);
console.log("ciao");
Object.keys(AwesomeQR.defaultOptions).forEach(function (k) {

@@ -91,3 +90,5 @@ if (!(k in _options)) {

this.options = _options;
this.canvas = this.createCanvas(options.size, options.size);
this.canvas = canvas;
this.canvas.width = this.options.size;
this.canvas.height = this.options.size;
this.canvasContext = this.canvas.getContext("2d");

@@ -219,3 +220,3 @@ this.qrCode = new qrcode_1.QRCodeModel(-1, this.options.correctLevel);

return __awaiter(this, void 0, void 0, function () {
var nCount, rawSize, rawMargin, rawViewportSize, margin, nSize, viewportSize, size, mainCanvas, mainCanvasContext, alignmentPatternCenters, logoSide, logoScale, logoMargin, logoSize, logoX, isInLogoZone, row, col, isBlkPosCtr, isLogoZone, isTiming, isAlignment, i, j, bIsDark, gradient, logoImage, logoScale, logoMargin, logoCornerRadius, logoSize, logoX, backgroundCanvas, backgroundCanvasContext, backgroundImage, backgroundDimming, avgRGB, outCanvas, outCanvasContext;
var nCount, rawSize, rawMargin, rawViewportSize, margin, nSize, viewportSize, size, mainCanvas, mainCanvasContext, alignmentPatternCenters, logoSide, logoScale, logoMargin, logoSize, logoX, isInLogoZone, row, col, isBlkPosCtr, isLogoZone, isTiming, isAlignment, i, j, bIsDark, gradient, logoImage, logoScale, logoMargin, logoCornerRadius, logoSize, logoX, backgroundCanvas, backgroundCanvasContext, backgroundImage, backgroundDimming, avgRGB;
return __generator(this, function (_a) {

@@ -392,6 +393,4 @@ switch (_a.label) {

mainCanvasContext.drawImage(backgroundCanvas, -margin, -margin, size, size);
outCanvas = this.createCanvas(rawSize, rawSize);
outCanvasContext = outCanvas.getContext("2d");
outCanvasContext.drawImage(mainCanvas, 0, 0, rawSize, rawSize);
this.canvas = outCanvas;
// Scale the final image
this.canvasContext.drawImage(mainCanvas, 0, 0, rawSize, rawSize);
if (isElement(this.canvas)) {

@@ -398,0 +397,0 @@ return [2 /*return*/, Promise.resolve(this.canvas.toDataURL())];

{
"name": "@qrcode-js/core",
"version": "0.0.2",
"version": "0.0.3",
"description": "An awesome but simple QR code generator written in JavaScript.",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -1,427 +0,1 @@

# Awesome-qr.js <!-- omit in toc -->
![](https://img.shields.io/npm/v/@qrcode-js/core/latest) ![](https://img.shields.io/npm/v/@qrcode-js/core/beta) [![license](https://img.shields.io/github/license/qrcode-js/core)](https://www.apache.org/licenses/LICENSE-2.0)
An awesome but simple QR code generator written in JavaScript.
Most of the work is based on the work by @SumiMakito
## Gallery <!-- omit in toc -->
TODO
## Contents <!-- omit in toc -->
- [Getting Started](#getting-started)
- [Options](#options)
- [text](#text)
- [size](#size)
- [margin](#margin)
- [correctLevel](#correctlevel)
- [maskPattern](#maskpattern)
- [version](#version)
- [components](#components)
- [colorDark](#colordark)
- [colorLight](#colorlight)
- [autoColor](#autocolor)
- [backgroundImage](#backgroundimage)
- [backgroundDimming](#backgrounddimming)
- [whiteMargin](#whitemargin)
- [logoImage](#logoimage)
- [logoScale](#logoscale)
- [logoMargin](#logomargin)
- [logoCornerRadius](#logocornerradius)
- [gradient](#gradient)
- [drawFunction](#drawfunction)
- [onEvent](#onevent)
- [ComponentOptions](#componentoptions)
- [scale](#scale)
- [round](#round)
- [Sponsors](#sponsors)
- [Copyright &amp; License](#copyright--license)
## Getting Started
This project is divided in three projects.
The "core" project is a platform-agnostic implementation to draw a QR on a canvas
The "node" project is a wrapper around the "core" project using "node-canvas" as
backend
The "browser" project is a wrapper around the "core" project using the buil'in canvas in the browsers
**Please install one of "node" or "browser" package**
**Do not install the "core" package unless you know what you0re doing**
## Options
> _Options_ is an object that you can pass to the generator to customize your QR code.
```ts
type Options = {
text: string;
size?: number;
margin?: number;
correctLevel?: number;
maskPattern?: number;
version?: number;
components?: ComponentOptions;
colorDark?: string;
colorLight?: string;
autoColor?: boolean;
backgroundImage?: string | Buffer;
backgroundDimming?: string;
gifBackground?: ArrayBuffer;
whiteMargin?: boolean;
logoImage?: string | Buffer;
logoScale?: number;
logoMargin?: number;
logoCornerRadius?: number;
};
```
### text
**Type** `string`
Text to be encoded in the QR code.
<hr/>
### size
**Type** `number?`
**Default** `400`
Size of the QR code in pixel.
<hr/>
### margin
**Type** `number?`
**Default** `20`
Size of margins around the QR code body in pixel.
<hr/>
### correctLevel
**Type** `number?`
**Default** `QRErrorCorrectLevel.M` ~> `0`
> For more information, please refer to [Error correction feature | QRcode.com | DENSO WAVE](https://www.qrcode.com/en/about/error_correction.html).
Error correction level of the QR code.
<hr/>
### maskPattern
**Type** `number?`
**This is an advanced option.**
Leave untouched to let the code decide which mask pattern to use.
Specify the mask pattern to be used in QR code encoding.
Accepts a value provided by _QRMaskPattern_.
> To find out all eight mask patterns, please refer to [Wikipedia File:QR_Code_Mask_Patterns.svg](https://en.wikipedia.org/wiki/File:QR_Code_Mask_Patterns.svg)
> For more information, please refer to [Reed–Solomon codes for coders: Masking](https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders#Masking).
<hr/>
### version
**Type** `number?`
**This is an advanced option.**
Leave untouched to let the code decide which version to use.
Specify the version to be used in QR code encoding.
Accepts an integer in range [1, 40].
**⚠️ &nbsp; An error might occurs if the specified version does not have enough space for the input data.**
> For more information, please refer to [Information capacity and versions of QR Code | QRcode.com | DENSO WAVE](https://www.qrcode.com/en/about/version.html).
<hr/>
### components
**Type** [ComponentOptions](#componentoptions)
Controls the appearances of parts in the QR code.
Read section [ComponentOptions](#componentoptions) to learn more.
<hr/>
### colorDark
**Type** `string?, CSS <color>`
**Default** `"#000000"`
> For more information about CSS &lt;color&gt;, please refer to [&lt;color&gt; - CSS: Cascading Style Sheets | MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value)
Color of the blocks on the QR code.
<hr/>
### colorLight
**Type** `string?, CSS <color>`
**Default** `"#ffffff"`
Color of the empty areas on the QR code.
<hr/>
### autoColor
**Type** `boolean?`
**Default** `true`
Automatically calculate the _colorDark_ value from the QR code's background.
<hr/>
### backgroundImage
**Type** `(string|Buffer)?`
**Default** `undefined`
Background image to be used in the QR code.
Accepts a `data:` string in web browsers or a Buffer in Node.js.
<hr/>
### backgroundDimming
**Type** `string?, CSS <color>`
**Default** `"rgba(0, 0, 0, 0)"`
Color of the dimming mask above the background image.
<hr/>
### whiteMargin
**Type** `boolean?`
**Default** `true`
Use a white margin instead of a transparent one which reveals the background of the QR code on margins.
<hr/>
### logoImage
**Type** `(string|Buffer)?`
**Default** `undefined`
Logo image to be displayed at the center of the QR code.
Accepts a `data:` string in web browsers or a Buffer in Node.js.
When set to `undefined` or `null`, the logo is disabled.
<hr/>
### logoScale
**Type** `number?`
**Default** `0.2`
Ratio of the logo size to the QR code size.
<hr/>
### logoMargin
**Type** `number?`
**Default** `6`
Size of margins around the logo image in pixels.
<hr/>
### logoCornerRadius
**Type** `number?`
**Default** `0`
Ratio of the logo corner radius. 0 means no round. 1 means max round
<hr />
### gradient
**Type** `(ctx: CanvasRenderingContext2D, size: number) => CanvasGradient?`
Custom function to create a gradient as a foreground color (data blocks and finders). Inside the body you must create a gradient with the provided context, add stop colors and return it. Below is an example.
```typescript
new AwesomeQR({
gradient: (ctx: CanvasRenderingContext2D, size: number) => {
// This creates a horizontal gradient from left to right
const gradient = ctx.createLinearGradient(0, 0, size, 0);
gradient.addColorStop(0, "red");
gradient.addColorStop(1, "blue");
return gradient;
},
});
```
<hr />
### drawFunction
**Type** `"telegram" | (( canvasContext: CanvasRenderingContext2D, left: number, top: number, nSize: number, scale: number, round: number, parameters: { isTiming: boolean; isAlignment: boolean; }, otherCells: { top: boolean; left: boolean; right: boolean; bottom: boolean; } ) => undefined)`
Accepts either a string or a custom function.
As a string it currently accepts only "telegram" mode.
As a function here are the parameters:
- canvasContext: the current drawing context
- left: how many cells are from the left margin
- top: how many cells are from the top margin
- nSize: size in pixels of a single cell
- scale: scale of data blocks as provided in initial options
- round: round of data block as provided in initial options
- parameters: tell if the cell is special (timing or alignment) or regular
- otherCells: tell if the neighbour cells are empty or full
<hr />
### onEvent
**Type** `( type: string, canvasContext: CanvasRenderingContext2D, parameters: object ) => undefined`
Special function called in certain points when drawing the QR onto the canvas.
Might be useful if you have to manipulate the canvas manually.
Actually it's called before data is drawed and before the background is applied to the entire canvas
## ComponentOptions
> _ComponentOptions_ controls the appearances of parts in the QR code.
```ts
type ComponentOptions = {
data?: {
scale?: number;
round?: number;
};
finder?: {
round?: number;
};
};
```
```ts
// default ComponentOptions
{
data: {
scale: 1,
round: 0,
},
finder: {
round: 0,
}
}
```
### scale
**Type** `number?`
Scale factor for blocks in the specified area of the QR code.
<hr/>
### round
**Type** `number?`
Ratio of rounded corner for finders or data blocks. 0 means no round. 1 means max round (a circle)
## Sponsors
[Support me here](https://ko-fi.com/ruggio)
## Copyright &amp; License
qrcode-js code is licensed under MIT License.
```
Copyright (c) 2017-2020 Makito
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
```
jquery-qrcode
Copyright (c) 2011 Jerome Etienne, http://jetienne.com
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```
```
QRCode for JavaScript
Copyright (c) 2009 Kazuhiko Arase
URL: http://www.d-project.com/
Licensed under the MIT license:
http://www.opensource.org/licenses/mit-license.php
The word "QR Code" is registered trademark of
DENSO WAVE INCORPORATED
http://www.denso-wave.com/qrcode/faqpatent-e.html
```
# core
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc