@liquid-js/qr-code-styling 4.0.2 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- class t{constructor(){this.buffer=[],this.length=0}getBuffer(){return this.buffer}getLengthInBits(){return this.length}toString(){let t="";for(let e=0;e<this.getLengthInBits();e+=1)t+=this.getBit(e)?"1":"0";return t}getBit(t){return 1==(this.buffer[~~(t/8)]>>>7-t%8&1)}put(t,e){for(let i=0;i<e;i+=1)this.putBit(1==(t>>>e-i-1&1))}putBit(t){this.length==8*this.buffer.length&&this.buffer.push(0),t&&(this.buffer[~~(this.length/8)]|=128>>>this.length%8),this.length+=1}}var e,i=e||(e={});i[i.L=1]="L",i[i.M=0]="M",i[i.Q=3]="Q",i[i.H=2]="H";class s{constructor(){throw"error"}static glog(t){if(1>t)throw"log("+t+")";return s.LOG_TABLE[t]}static gexp(t){for(;0>t;)t+=255;for(;256<=t;)t-=255;return s.EXP_TABLE[t]}}s.EXP_TABLE=[],s.LOG_TABLE=[];for(let t=0;256>t;t+=1)s.EXP_TABLE.push(8>t?1<<t:s.EXP_TABLE[t-4]^s.EXP_TABLE[t-5]^s.EXP_TABLE[t-6]^s.EXP_TABLE[t-8]),s.LOG_TABLE.push(0);for(let t=0;255>t;t+=1)s.LOG_TABLE[s.EXP_TABLE[t]]=t;s.initialize=void 0;class r{constructor(t,e=0){let i=0;for(;i<t.length&&0==t[i];)i+=1;this.num=[];let s=t.length-i;for(let e=0;e<s;e+=1)this.num.push(t[i+e]);for(t=0;t<e;t+=1)this.num.push(0)}getAt(t){return this.num[t]}getLength(){return this.num.length}toString(){let t="";for(let e=0;e<this.getLength();e+=1)0<e&&(t+=","),t+=this.getAt(e);return t.toString()}toLogString(){let t="";for(let e=0;e<this.getLength();e+=1)0<e&&(t+=","),t+=s.glog(this.getAt(e));return t.toString()}multiply(t){let e=[];for(var i=this.getLength()+t.getLength()-1,o=0;o<i;o+=1)e.push(0);for(i=0;i<this.getLength();i+=1)for(o=0;o<t.getLength();o+=1)e[i+o]^=s.gexp(s.glog(this.getAt(i))+s.glog(t.getAt(o)));return new r(e)}mod(t){if(0>this.getLength()-t.getLength())return this;let e=s.glog(this.getAt(0))-s.glog(t.getAt(0)),i=[];for(var o=0;o<this.getLength();o+=1)i.push(this.getAt(o));for(o=0;o<t.getLength();o+=1)i[o]^=s.gexp(s.glog(t.getAt(o))+e);return new r(i).mod(t)}}var o,a=o||(o={});a[a.MODE_NUMBER=1]="MODE_NUMBER",a[a.MODE_ALPHA_NUM=2]="MODE_ALPHA_NUM",a[a.MODE_8BIT_BYTE=4]="MODE_8BIT_BYTE",a[a.MODE_KANJI=8]="MODE_KANJI";class n{constructor(t,e){this.mode=t,this.data=e}getMode(){return this.mode}getData(){return this.data}getLengthInBits(t){if(1<=t&&10>t)switch(this.mode){case o.MODE_NUMBER:return 10;case o.MODE_ALPHA_NUM:return 9;case o.MODE_8BIT_BYTE:case o.MODE_KANJI:return 8;default:throw"mode:"+this.mode}else if(27>t)switch(this.mode){case o.MODE_NUMBER:return 12;case o.MODE_ALPHA_NUM:return 11;case o.MODE_8BIT_BYTE:return 16;case o.MODE_KANJI:return 10;default:throw"mode:"+this.mode}else{if(!(41>t))throw"typeNumber:"+t;switch(this.mode){case o.MODE_NUMBER:return 14;case o.MODE_ALPHA_NUM:return 13;case o.MODE_8BIT_BYTE:return 16;case o.MODE_KANJI:return 12;default:throw"mode:"+this.mode}}}}class h extends n{constructor(t,e){super(o.MODE_8BIT_BYTE,t),this.stringToBytes=e}write(t){let e=this.stringToBytes(this.getData());for(let i=0;i<e.length;i+=1)t.put(e[i],8)}getLength(){return this.stringToBytes(this.getData()).length}}class l extends n{constructor(t){super(o.MODE_ALPHA_NUM,t)}write(t){let e=this.getData(),i=0;for(;i+1<e.length;)t.put(45*l.getCode(e.charAt(i))+l.getCode(e.charAt(i+1)),11),i+=2;i<e.length&&t.put(l.getCode(e.charAt(i)),6)}getLength(){return this.getData().length}static getCode(t){if("0"<=t&&"9">=t)return t.charCodeAt(0)-48;if("A"<=t&&"Z">=t)return t.charCodeAt(0)-65+10;switch(t){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+t}}}class d extends n{constructor(t,e){super(o.MODE_KANJI,t),this.stringToBytes=e}write(t){let e=this.stringToBytes(this.getData()),i=0;for(;i+1<e.length;){let s=(255&e[i])<<8|255&e[i+1];if(33088<=s&&40956>=s)s-=33088;else{if(!(57408<=s&&60351>=s))throw"illegal char at "+(i+1)+"/"+s;s-=49472}s=192*(s>>>8&255)+(255&s),t.put(s,13),i+=2}if(i<e.length)throw"illegal char at "+(i+1)}getLength(){return this.stringToBytes(this.getData()).length/2}}class u extends n{constructor(t){super(o.MODE_NUMBER,t)}write(t){let e=this.getData(),i=0;for(;i+2<e.length;)t.put(u.strToNum(e.substring(i,i+3)),10),i+=3;i<e.length&&(1==e.length-i?t.put(u.strToNum(e.substring(i,i+1)),4):2==e.length-i&&t.put(u.strToNum(e.substring(i,i+2)),7))}getLength(){return this.getData().length}static strToNum(t){let e=0;for(let i=0;i<t.length;i+=1)e=10*e+u.chatToNum(t.charAt(i));return e}static chatToNum(t){if("0"<=t&&"9">=t)return t.charCodeAt(0)-48;throw"illegal char :"+t}}var g,c=g||(g={});c[c.PATTERN000=0]="PATTERN000",c[c.PATTERN001=1]="PATTERN001",c[c.PATTERN010=2]="PATTERN010",c[c.PATTERN011=3]="PATTERN011",c[c.PATTERN100=4]="PATTERN100",c[c.PATTERN101=5]="PATTERN101",c[c.PATTERN110=6]="PATTERN110",c[c.PATTERN111=7]="PATTERN111";class p{constructor(){throw"error"}static getPatternPosition(t){return p.PATTERN_POSITION_TABLE[t-1]}static getMaxLength(t,i,s){switch(s){case e.L:s=0;break;case e.M:s=1;break;case e.Q:s=2;break;case e.H:s=3;break;default:throw"e:"+s}switch(i){case o.MODE_NUMBER:i=0;break;case o.MODE_ALPHA_NUM:i=1;break;case o.MODE_8BIT_BYTE:i=2;break;case o.MODE_KANJI:i=3;break;default:throw"m:"+i}return p.MAX_LENGTH[t-1][s][i]}static getErrorCorrectPolynomial(t){let e=new r([1]);for(let i=0;i<t;i+=1)e=e.multiply(new r([1,s.gexp(i)]));return e}static getMaskFunc(t){switch(t){case g.PATTERN000:return(t,e)=>0==(t+e)%2;case g.PATTERN001:return t=>0==t%2;case g.PATTERN010:return(t,e)=>0==e%3;case g.PATTERN011:return(t,e)=>0==(t+e)%3;case g.PATTERN100:return(t,e)=>0==(~~(t/2)+~~(e/3))%2;case g.PATTERN101:return(t,e)=>0==t*e%2+t*e%3;case g.PATTERN110:return(t,e)=>0==(t*e%2+t*e%3)%2;case g.PATTERN111:return(t,e)=>0==(t*e%3+(t+e)%2)%2;default:throw"mask:"+t}}static getLostPoint(t){let e=t.getModuleCount(),i=0;for(var s=0;s<e;s+=1)for(var r=0;r<e;r+=1){var o=0;let a=t.isDark(s,r);for(let i=-1;1>=i;i+=1)if(!(0>s+i||e<=s+i))for(let n=-1;1>=n;n+=1)0>r+n||e<=r+n||(0!=i||0!=n)&&a==t.isDark(s+i,r+n)&&(o+=1);5<o&&(i+=3+o-5)}for(s=0;s<e-1;s+=1)for(r=0;r<e-1;r+=1)o=0,t.isDark(s,r)&&(o+=1),t.isDark(s+1,r)&&(o+=1),t.isDark(s,r+1)&&(o+=1),t.isDark(s+1,r+1)&&(o+=1),(0==o||4==o)&&(i+=3);for(s=0;s<e;s+=1)for(r=0;r<e-6;r+=1)t.isDark(s,r)&&!t.isDark(s,r+1)&&t.isDark(s,r+2)&&t.isDark(s,r+3)&&t.isDark(s,r+4)&&!t.isDark(s,r+5)&&t.isDark(s,r+6)&&(i+=40);for(s=0;s<e;s+=1)for(r=0;r<e-6;r+=1)t.isDark(r,s)&&!t.isDark(r+1,s)&&t.isDark(r+2,s)&&t.isDark(r+3,s)&&t.isDark(r+4,s)&&!t.isDark(r+5,s)&&t.isDark(r+6,s)&&(i+=40);for(s=0,r=0;r<e;r+=1)for(o=0;o<e;o+=1)t.isDark(o,r)&&(s+=1);return i+Math.abs(100*s/e/e-50)/5*10}static getBCHTypeInfo(t){let e=t<<10;for(;0<=p.getBCHDigit(e)-p.getBCHDigit(p.G15);)e^=p.G15<<p.getBCHDigit(e)-p.getBCHDigit(p.G15);return(t<<10|e)^p.G15_MASK}static getBCHTypeNumber(t){let e=t<<12;for(;0<=p.getBCHDigit(e)-p.getBCHDigit(p.G18);)e^=p.G18<<p.getBCHDigit(e)-p.getBCHDigit(p.G18);return t<<12|e}static getBCHDigit(t){let e=0;for(;0!=t;)e+=1,t>>>=1;return e}}p.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]],p.MAX_LENGTH=[[[41,25,17,10],[34,20,14,8],[27,16,11,7],[17,10,7,4]],[[77,47,32,20],[63,38,26,16],[48,29,20,12],[34,20,14,8]],[[127,77,53,32],[101,61,42,26],[77,47,32,20],[58,35,24,15]],[[187,114,78,48],[149,90,62,38],[111,67,46,28],[82,50,34,21]],[[255,154,106,65],[202,122,84,52],[144,87,60,37],[106,64,44,27]],[[322,195,134,82],[255,154,106,65],[178,108,74,45],[139,84,58,36]],[[370,224,154,95],[293,178,122,75],[207,125,86,53],[154,93,64,39]],[[461,279,192,118],[365,221,152,93],[259,157,108,66],[202,122,84,52]],[[552,335,230,141],[432,262,180,111],[312,189,130,80],[235,143,98,60]],[[652,395,271,167],[513,311,213,131],[364,221,151,93],[288,174,119,74]]],p.G15=1335,p.G18=7973,p.G15_MASK=21522;class m{constructor(t,e){this.totalCount=t,this.dataCount=e}getDataCount(){return this.dataCount}getTotalCount(){return this.totalCount}static getRSBlocks(t,e){e=(t=m.getRsBlockTable(t,e)).length/3;let i=[];for(let s=0;s<e;s+=1){let e=t[3*s],r=t[3*s+1],o=t[3*s+2];for(let t=0;t<e;t+=1)i.push(new m(r,o))}return i}static getRsBlockTable(t,i){switch(i){case e.L:return m.RS_BLOCK_TABLE[4*(t-1)];case e.M:return m.RS_BLOCK_TABLE[4*(t-1)+1];case e.Q:return m.RS_BLOCK_TABLE[4*(t-1)+2];case e.H:return m.RS_BLOCK_TABLE[4*(t-1)+3]}throw"tn:"+t+"/ecl:"+i}}m.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,7,37,13],[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]];let w=Array(41).fill(0).map(((t,e)=>e));var b,$=b||(b={});$.L="L",$.M="M",$.Q="Q",$.H="H";var f,y=f||(f={});y.numeric="numeric",y.alphanumeric="alphanumeric",y.byte="byte",y.kanji="kanji",y.unicode="unicode";class M{constructor(t=0,i=b.L){this.modules=[],this.moduleCount=0,this.typeNumber=t,this.errorCorrectLevel=e[i],this.qrDataList=[]}getTypeNumber(){return this.typeNumber}setTypeNumber(t){this.typeNumber=t}getErrorCorrectLevel(){return this.errorCorrectLevel}setErrorCorrectLevel(t){this.errorCorrectLevel=t}clearData(){this.qrDataList=[]}addData(t,e=f.byte){if(t instanceof n)this.qrDataList.push(t);else{if("string"!=typeof t)throw typeof t;switch(e){case f.numeric:this.qrDataList.push(new u(t));break;case f.alphanumeric:this.qrDataList.push(new l(t));break;case f.byte:this.qrDataList.push(new h(t,M.stringToBytesFuncs.default));break;case f.unicode:this.qrDataList.push(new h(t,M.stringToBytesFuncs.UTF8));break;case f.kanji:this.qrDataList.push(new d(t,M.stringToBytesFuncs.SJIS));break;default:throw"mode:"+e}}}isDark(t,e){return null!=this.modules[t][e]&&this.modules[t][e]}getModuleCount(){return this.moduleCount}make(){if(1>this.typeNumber){let s=1;for(;40>s;s++){let r=m.getRSBlocks(s,this.errorCorrectLevel),o=new t;for(var e=0;e<this.qrDataList.length;e++){var i=this.qrDataList[e];o.put(i.getMode(),4),o.put(i.getLength(),i.getLengthInBits(s)),i.write(o)}for(e=0,i=0;i<r.length;i++)e+=r[i].getDataCount();if(o.getLengthInBits()<=8*e)break}this.typeNumber=s}this.makeImpl(!1,this.getBestMaskPattern())}getBestMaskPattern(){let t=0,e=0;for(let i=0;8>i;i+=1){this.makeImpl(!0,i);let s=p.getLostPoint(this);(0==i||t>s)&&(t=s,e=i)}return e}makeImpl(t,e){this.moduleCount=4*this.typeNumber+17,this.modules=[];for(let t=0;t<this.moduleCount;t+=1){this.modules.push([]);for(let e=0;e<this.moduleCount;e+=1)this.modules[t].push(null)}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(t,e),7<=this.typeNumber&&this.setupTypeNumber(t),t=M.createData(this.typeNumber,this.errorCorrectLevel,this.qrDataList),this.mapData(t,e)}mapData(t,e){let i=-1,s=this.moduleCount-1,r=7,o=0;e=p.getMaskFunc(e);for(let a=this.moduleCount-1;0<a;a-=2)for(6==a&&--a;;){for(let i=0;2>i;i+=1)if(null==this.modules[s][a-i]){let n=!1;o<t.length&&(n=1==(t[o]>>>r&1)),e(s,a-i)&&(n=!n),this.modules[s][a-i]=n,--r,-1==r&&(o+=1,r=7)}if(s+=i,0>s||this.moduleCount<=s){s-=i,i=-i;break}}}setupPositionAdjustPattern(){let t=p.getPatternPosition(this.typeNumber);for(let e=0;e<t.length;e+=1)for(let i=0;i<t.length;i+=1){let s=t[e],r=t[i];if(null==this.modules[s][r])for(let t=-2;2>=t;t+=1)for(let e=-2;2>=e;e+=1)this.modules[s+t][r+e]=-2==t||2==t||-2==e||2==e||0==t&&0==e}}setupPositionProbePattern(t,e){for(let i=-1;7>=i;i+=1)for(let s=-1;7>=s;s+=1)-1>=t+i||this.moduleCount<=t+i||-1>=e+s||this.moduleCount<=e+s||(this.modules[t+i][e+s]=0<=i&&6>=i&&(0==s||6==s)||0<=s&&6>=s&&(0==i||6==i)||2<=i&&4>=i&&2<=s&&4>=s)}setupTimingPattern(){for(var t=8;t<this.moduleCount-8;t+=1)null==this.modules[t][6]&&(this.modules[t][6]=0==t%2);for(t=8;t<this.moduleCount-8;t+=1)null==this.modules[6][t]&&(this.modules[6][t]=0==t%2)}setupTypeNumber(t){let e=p.getBCHTypeNumber(this.typeNumber);for(var i=0;18>i;i+=1)this.modules[~~(i/3)][i%3+this.moduleCount-8-3]=!t&&1==(e>>i&1);for(i=0;18>i;i+=1)this.modules[i%3+this.moduleCount-8-3][~~(i/3)]=!t&&1==(e>>i&1)}setupTypeInfo(t,e){e=p.getBCHTypeInfo(this.errorCorrectLevel<<3|e);for(var i=0;15>i;i+=1){var s=!t&&1==(e>>i&1);6>i?this.modules[i][8]=s:8>i?this.modules[i+1][8]=s:this.modules[this.moduleCount-15+i][8]=s}for(i=0;15>i;i+=1)s=!t&&1==(e>>i&1),8>i?this.modules[8][this.moduleCount-i-1]=s:9>i?this.modules[8][15-i-1+1]=s:this.modules[8][15-i-1]=s;this.modules[this.moduleCount-8][8]=!t}static createData(e,i,s){i=m.getRSBlocks(e,i);let r=new t;for(let t=0;t<s.length;t+=1){let i=s[t];r.put(i.getMode(),4),r.put(i.getLength(),i.getLengthInBits(e)),i.write(r)}for(e=0,s=0;s<i.length;s+=1)e+=i[s].getDataCount();if(r.getLengthInBits()>8*e)throw"code length overflow. ("+r.getLengthInBits()+">"+8*e+")";for(r.getLengthInBits()+4<=8*e&&r.put(0,4);0!=r.getLengthInBits()%8;)r.putBit(!1);for(;!(r.getLengthInBits()>=8*e)&&(r.put(M.PAD0,8),!(r.getLengthInBits()>=8*e));)r.put(M.PAD1,8);return M.createBytes(r,i)}static createBytes(t,e){function i(t){let e=[];for(let i=0;i<t;i+=1)e.push(0);return e}var s=0,o=0;let a=0;var n=[];let h=[];for(var l=0;l<e.length;l+=1)n.push([]),h.push([]);for(l=0;l<e.length;l+=1){var d=e[l].getDataCount(),u=e[l].getTotalCount()-d;o=Math.max(o,d),a=Math.max(a,u),n[l]=i(d);for(var g=0;g<n[l].length;g+=1)n[l][g]=255&t.getBuffer()[g+s];for(s+=d,u=p.getErrorCorrectPolynomial(u),d=new r(n[l],u.getLength()-1).mod(u),h[l]=i(u.getLength()-1),u=0;u<h[l].length;u+=1)g=u+d.getLength()-h[l].length,h[l][u]=0<=g?d.getAt(g):0}for(t=0,s=0;s<e.length;s+=1)t+=e[s].getTotalCount();for(t=i(t),s=0,l=0;l<o;l+=1)for(d=0;d<e.length;d+=1)l<n[d].length&&(t[s]=n[d][l],s+=1);for(o=0;o<a;o+=1)for(n=0;n<e.length;n+=1)o<h[n].length&&(t[s]=h[n][o],s+=1);return t}}M.PAD0=236,M.PAD1=17,M.stringToBytesFuncs={default:function(t){let e=[];for(let i=0;i<t.length;i+=1){let s=t.charCodeAt(i);e.push(255&s)}return e}};let A=t=>!!t&&"object"==typeof t&&!Array.isArray(t);function v(t,...e){if(!e.length)return t;let i=e.shift();return void 0!==i&&A(t)&&A(i)?(t={...t},Object.keys(i).forEach((e=>{let s=t[e],r=i[e];Array.isArray(s)&&Array.isArray(r)?t[e]=r:A(s)&&A(r)?t[e]=v(Object.assign({},s),r):t[e]=r})),v(t,...e)):t}var x,D=x||(x={});function _(t){if(!(t={...t}).colorStops||!t.colorStops.length)throw"Field 'colorStops' is required in gradient";return t.rotation=t.rotation?Number(t.rotation):0,t.colorStops=t.colorStops.map((t=>({...t,offset:Number(t.offset)}))),t}D.radial="radial",D.linear="linear";var k,E=k||(k={});E.dot="dot",E.randomDot="random-dot",E.rounded="rounded",E.extraRounded="extra-rounded",E.verticalLine="vertical-line",E.horizontalLine="horizontal-line",E.classy="classy",E.classyRounded="classy-rounded",E.square="square",E.smallSquare="small-square",E.tinySquare="tiny-square",E.diamond="diamond";var S,z=S||(S={});z.dot="dot",z.square="square",z.heart="heart",z.extraRounded="extra-rounded",z.classy="classy",z.outpoint="outpoint",z.inpoint="inpoint";var C,O=C||(C={});O.dot="dot",O.square="square",O.extraRounded="extra-rounded",O.classy="classy",O.outpoint="outpoint",O.inpoint="inpoint";var T,P=T||(T={});P.square="square",P.circle="circle";var N,L=N||(N={});L.center="center",L.overlay="overlay",L.background="background";let I={document:void 0,shape:T.square,width:void 0,height:void 0,data:"",qrOptions:{typeNumber:w[0],mode:void 0,errorCorrectionLevel:b.Q},imageOptions:{mode:N.center,imageSize:.4,crossOrigin:void 0,margin:0,fill:{color:"rgba(255,255,255,1)"}},dotsOptions:{type:k.square,color:"#000",size:10}};function R(t){return(t={...t}).imageOptions={...t.imageOptions,imageSize:Math.min(1,Number(t.imageOptions.imageSize))||1,margin:Number(t.imageOptions.margin),fill:{...t.imageOptions.fill}},t.imageOptions.mode==N.overlay&&(t.imageOptions.margin=0),t.imageOptions.fill.gradient&&(t.imageOptions.fill.gradient=_(t.imageOptions.fill.gradient)),t.dotsOptions={...t.dotsOptions},t.dotsOptions.gradient&&(t.dotsOptions.gradient=_(t.dotsOptions.gradient)),t.dotsOptions.size=Math.round(Math.max(0,t.dotsOptions.size)||10),t.cornersSquareOptions&&(t.cornersSquareOptions={...t.cornersSquareOptions},t.cornersSquareOptions.gradient&&(t.cornersSquareOptions.gradient=_(t.cornersSquareOptions.gradient))),t.cornersDotOptions&&(t.cornersDotOptions={...t.cornersDotOptions},t.cornersDotOptions.gradient&&(t.cornersDotOptions.gradient=_(t.cornersDotOptions.gradient))),t.backgroundOptions&&(t.backgroundOptions={...t.backgroundOptions},t.backgroundOptions.gradient&&(t.backgroundOptions.gradient=_(t.backgroundOptions.gradient))),t.document||(t.document=document),t}let q={[b.L]:.07,[b.M]:.15,[b.Q]:.25,[b.H]:.3};let B=/\.?0+$/;function G(t){return t.toFixed(7).replace(B,"")}function H(t,...e){return t.reduce(((t,i,s)=>{let r="";return s&&(r=e[s-1]),"number"==typeof r&&(r=G(r)),`${t}${r}${i}`}),"").trim().replace(/[\s\n\r]+/gim," ")}class F{get element(){return this._element}constructor(t,e){this.type=t,this.document=e}draw(t){let e;switch(this.type){case S.square:e=this.drawSquare;break;case S.heart:e=this.drawHeart;break;case S.extraRounded:e=this.drawRounded;break;case S.classy:e=this.drawClassy;break;case S.inpoint:e=this.drawInpoint;break;case S.outpoint:e=this.drawOutpoint;break;default:e=this.drawDot}e.call(this,t)}rotateFigure({x:t,y:e,size:i,rotation:s=0,draw:r}){t+=i/2,e+=i/2,r(),this._element?.setAttribute("transform",`rotate(${G(180*s/Math.PI)},${t},${e})`)}basicDot(t){let{size:e,x:i,y:s}=t;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","circle"),this._element.setAttribute("cx",G(i+e/2)),this._element.setAttribute("cy",G(s+e/2)),this._element.setAttribute("r",G(e/2))}})}basicSquare(t){let{size:e,x:i,y:s}=t;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","rect"),this._element.setAttribute("x",G(i)),this._element.setAttribute("y",G(s)),this._element.setAttribute("width",G(e)),this._element.setAttribute("height",G(e))}})}basicHeart(t){let{size:e,x:i,y:s}=t;this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path");let r=!1,o=0;this._element.setAttribute("d",["M",1,.3262506,"c",0,.0383376,-.0064626,.0758377,-.0193751,.1125001,"s",-.0356247,.076875,-.0681248,.1206252,"c",-.0325,.0437499,-.0762503,.0931247,-.1312501,.1481249,"C",.7262502,.7625008,.6566626,.8279132,.5724999,.9037505,"L",.5,.9687506,"L",.4275001,.9037505,"C",.3433374,.8279132,.2737499,.7625005,.21875,.7075007,"C",.1637501,.6525008,.1199999,.6031258,.0874999,.5593758,"S",.0322876,.4754133,.0193751,.4387506,"S",0,.3645881,0,.3262506,"c",0,-.0783374,.0262499,-.1437498,.07875,-.1962499,"s",.1179124,-.07875,.1962499,-.07875,"c",.0433376,0,.0845875,.0091625,.12375,.0274999,"S",.4716623,.1229131,.5,.1562506,"c",.0283374,-.0333375,.0620874,-.0591625,.1012502,-.0775,"c",.0391627,-.0183375,.0804126,-.0274999,.12375,-.0274999,"c",.0783374,0,.1437497,.0262499,.1962501,.07875,"S",1,.2479131,1,.3262506,"z"].map((t=>"string"==typeof t?(o=0,r=t.toUpperCase()==t,t):(o++,t*=e,r&&(t+=1==o%2?i:s),G(t)))).join(" "))}basicRounded(t){let{size:e,x:i,y:s}=t;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","rect"),this._element.setAttribute("x",G(i)),this._element.setAttribute("y",G(s)),this._element.setAttribute("width",G(e)),this._element.setAttribute("height",G(e)),this._element.setAttribute("rx",G(e/4)),this._element.setAttribute("ry",G(e/4))}})}basicClassy(t){let{size:e,x:i,y:s}=t,r=e/7;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",H`M ${i} ${s+2.5*r} v ${2*r} a ${2.5*r} ${2.5*r}, 0, 0, 0, ${2.5*r} ${2.5*r} h ${4.5*r} v ${-4.5*r} a ${2.5*r} ${2.5*r}, 0, 0, 0, ${2.5*-r} ${2.5*-r} h ${-2*r} H ${i} z`)}})}basicInpoint(t){let{size:e,x:i,y:s}=t;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",H`M ${i} ${s+e/2} v ${e/4} a ${e/4}, ${e/4} 0 0 0 ${e/4}, ${e/4} h ${e/4*3} v ${-e/4*3} a ${e/4}, ${e/4} 0 0 0 ${-e/4}, ${-e/4} h ${-e/2} a ${e/4}, ${e/4} 0 0 0 ${-e/4}, ${e/4} z`)}})}drawDot({x:t,y:e,size:i,rotation:s}){this.basicDot({x:t,y:e,size:i,rotation:s})}drawSquare({x:t,y:e,size:i,rotation:s}){this.basicSquare({x:t,y:e,size:i,rotation:s})}drawHeart({x:t,y:e,size:i,rotation:s}){this.basicHeart({x:t,y:e,size:i,rotation:s})}drawRounded({x:t,y:e,size:i,rotation:s}){this.basicRounded({x:t,y:e,size:i,rotation:s})}drawClassy({x:t,y:e,size:i,rotation:s}){this.basicClassy({x:t,y:e,size:i,rotation:s})}drawInpoint({x:t,y:e,size:i,rotation:s}){this.basicInpoint({x:t,y:e,size:i,rotation:s})}drawOutpoint({x:t,y:e,size:i,rotation:s}){this.basicInpoint({x:t,y:e,size:i,rotation:(s||0)+Math.PI})}}class U{get element(){return this._element}get fill(){return this._fill}constructor(t,e){this.type=t,this.document=e}draw(t){let e;switch(this.type){case C.square:e=this.drawSquare;break;case C.extraRounded:e=this.drawExtraRounded;break;case C.classy:e=this.drawClassy;break;case C.outpoint:e=this.drawOutpoint;break;case C.inpoint:e=this.drawInpoint;break;default:e=this.drawDot}e.call(this,t)}rotateFigure({x:t,y:e,size:i,rotation:s=0,draw:r}){t+=i/2,e+=i/2,r(),this._element?.setAttribute("transform",`rotate(${G(180*s/Math.PI)},${t},${e})`),this._fill?.setAttribute("transform",`rotate(${G(180*s/Math.PI)},${t},${e})`)}basicDot(t){let{size:e,x:i,y:s}=t,r=e/7;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",H`M ${i+e/2} ${s} a ${e/2} ${e/2} 0 1 0 0.1 0 z m 0 ${r} a ${e/2-r} ${e/2-r} 0 1 1 -0.1 0 Z`),this._fill=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._fill.setAttribute("clip-rule","evenodd"),this._fill.setAttribute("d",H`M ${i+e/2} ${s-r} a ${e/2+r} ${e/2+r} 0 1 0 0.1 0 z`)}})}basicSquare(t){let{size:e,x:i,y:s}=t,r=e/7;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",H`M ${i} ${s} v ${e} h ${e} v ${-e} z M ${i+r} ${s+r} h ${e-2*r} v ${e-2*r} h ${2*r-e} z`),this._fill=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._fill.setAttribute("clip-rule","evenodd"),this._fill.setAttribute("d",H`M ${i-r} ${s-r} h ${e+2*r} v ${e+2*r} h ${-e-2*r} z`)}})}basicExtraRounded(t){let{size:e,x:i,y:s}=t,r=e/7;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",H`M ${i} ${s+2.5*r} v ${2*r} a ${2.5*r} ${2.5*r}, 0, 0, 0, ${2.5*r} ${2.5*r} h ${2*r} a ${2.5*r} ${2.5*r}, 0, 0, 0, ${2.5*r} ${2.5*-r} v ${-2*r} a ${2.5*r} ${2.5*r}, 0, 0, 0, ${2.5*-r} ${2.5*-r} h ${-2*r} a ${2.5*r} ${2.5*r}, 0, 0, 0, ${2.5*-r} ${2.5*r} z M ${i+2.5*r} ${s+r} h ${2*r} a ${1.5*r} ${1.5*r}, 0, 0, 1, ${1.5*r} ${1.5*r} v ${2*r} a ${1.5*r} ${1.5*r}, 0, 0, 1, ${1.5*-r} ${1.5*r} h ${-2*r} a ${1.5*r} ${1.5*r}, 0, 0, 1, ${1.5*-r} ${1.5*-r} v ${-2*r} a ${1.5*r} ${1.5*r}, 0, 0, 1, ${1.5*r} ${1.5*-r} z`),this._fill=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._fill.setAttribute("clip-rule","evenodd"),this._fill.setAttribute("d",H`M ${i+2.5*r} ${s+r} h ${2*r} a ${1.5*r} ${1.5*r}, 0, 0, 1, ${1.5*r} ${1.5*r} v ${2*r} a ${1.5*r} ${1.5*r}, 0, 0, 1, ${1.5*-r} ${1.5*r} h ${-2*r} a ${1.5*r} ${1.5*r}, 0, 0, 1, ${1.5*-r} ${1.5*-r} v ${-2*r} a ${1.5*r} ${1.5*r}, 0, 0, 1, ${1.5*r} ${1.5*-r} z`)}})}basicClassy(t){let{size:e,x:i,y:s}=t,r=e/7;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",H`M ${i} ${s+2.5*r} v ${2*r} a ${2.5*r} ${2.5*r}, 0, 0, 0, ${2.5*r} ${2.5*r} h ${4.5*r} v ${-4.5*r} a ${2.5*r} ${2.5*r}, 0, 0, 0, ${2.5*-r} ${2.5*-r} h ${-2*r} H ${i} z M ${i+2.5*r} ${s+r} h ${2*r} a ${1.5*r} ${1.5*r}, 0, 0, 1, ${1.5*r} ${1.5*r} v ${3.5*r} h ${-3.5*r} a ${1.5*r} ${1.5*r}, 0, 0, 1, ${1.5*-r} ${1.5*-r} v ${-3.5*r} z`),this._fill=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._fill.setAttribute("clip-rule","evenodd"),this._fill.setAttribute("d",H`M ${i+.5*r} ${s-r} h ${4*r} a ${3.5*r} ${3.5*r}, 0, 0, 1, ${3.5*r} ${3.5*r} v ${5.5*r} h ${-5.5*r} a ${3.5*r} ${3.5*r}, 0, 0, 1, ${3.5*-r} ${3.5*-r} v ${-5.5*r} z`)}})}basicInpoint(t){let{size:e,x:i,y:s}=t,r=e/7;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",H`M ${i} ${s+2.5*r} v ${2*r} a ${2.5*r} ${2.5*r}, 0, 0, 0, ${2.5*r} ${2.5*r} h ${4.5*r} v ${-4.5*r} a ${2.5*r} ${2.5*r}, 0, 0, 0, ${2.5*-r} ${2.5*-r} h ${-2*r} a ${2.5*r} ${2.5*r}, 0, 0, 0, ${2.5*-r} ${2.5*r} z M ${i+2.5*r} ${s+r} h ${2*r} a ${1.5*r} ${1.5*r}, 0, 0, 1, ${1.5*r} ${1.5*r} v ${3.5*r} h ${-3.5*r} a ${1.5*r} ${1.5*r}, 0, 0, 1, ${1.5*-r} ${1.5*-r} v ${-2*r} a ${1.5*r} ${1.5*r}, 0, 0, 1, ${1.5*r} ${1.5*-r} z`),this._fill=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._fill.setAttribute("clip-rule","evenodd"),this._fill.setAttribute("d",H`M ${i+.5*r} ${s-r} h ${4*r} a ${3.5*r} ${3.5*r}, 0, 0, 1, ${3.5*r} ${3.5*r} v ${5.5*r} h ${-5.5*r} a ${3.5*r} ${3.5*r}, 0, 0, 1, ${3.5*-r} ${3.5*-r} v ${-2*r} a ${3.5*r} ${3.5*r}, 0, 0, 1, ${3.5*r} ${3.5*-r} z`)}})}drawDot({x:t,y:e,size:i,rotation:s}){this.basicDot({x:t,y:e,size:i,rotation:s})}drawSquare({x:t,y:e,size:i,rotation:s}){this.basicSquare({x:t,y:e,size:i,rotation:s})}drawExtraRounded({x:t,y:e,size:i,rotation:s}){this.basicExtraRounded({x:t,y:e,size:i,rotation:s})}drawClassy({x:t,y:e,size:i,rotation:s}){this.basicClassy({x:t,y:e,size:i,rotation:s})}drawInpoint({x:t,y:e,size:i,rotation:s}){this.basicInpoint({x:t,y:e,size:i,rotation:s})}drawOutpoint({x:t,y:e,size:i,rotation:s}){this.basicInpoint({x:t,y:e,size:i,rotation:(s||0)+Math.PI})}}class X{get element(){return this._element}constructor(t,e){this.type=t,this.document=e}draw(t){let e;switch(this.type){case k.dot:e=this.drawDot;break;case k.randomDot:e=this.drawRandomDot;break;case k.classy:e=this.drawClassy;break;case k.classyRounded:e=this.drawClassyRounded;break;case k.rounded:e=this.drawRounded;break;case k.verticalLine:e=this.drawVerticalLine;break;case k.horizontalLine:e=this.drawHorizontalLine;break;case k.extraRounded:e=this.drawExtraRounded;break;case k.diamond:e=this.drawDiamond;break;case k.smallSquare:e=this.drawSmallSquare;break;case k.tinySquare:e=this.drawTinySquare;break;default:e=this.drawSquare}e.call(this,t)}rotateFigure({x:t,y:e,size:i,rotation:s=0,draw:r}){t+=i/2,e+=i/2,r(),this._element?.setAttribute("transform",`rotate(${G(180*s/Math.PI)},${t},${e})`)}basicDot(t){let{size:e,x:i,y:s}=t;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","circle"),this._element.setAttribute("cx",G(i+e/2)),this._element.setAttribute("cy",G(s+e/2)),this._element.setAttribute("r",G(e/2))}})}basicSquare(t){let{size:e,x:i,y:s}=t;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","rect"),this._element.setAttribute("x",G(i)),this._element.setAttribute("y",G(s)),this._element.setAttribute("width",G(e)),this._element.setAttribute("height",G(e))}})}basicSideRounded(t){let{size:e,x:i,y:s}=t;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",H`M ${i} ${s} v ${e} h ${e/2} a ${e/2} ${e/2}, 0, 0, 0, 0 ${-e} z`)}})}basicCornerRounded(t){let{size:e,x:i,y:s}=t;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",H`M ${i} ${s} v ${e} h ${e} v ${-e/2} a ${e/2} ${e/2}, 0, 0, 0, ${-e/2} ${-e/2} z`)}})}basicCornerExtraRounded(t){let{size:e,x:i,y:s}=t;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",H`M ${i} ${s} v ${e} h ${e} a ${e} ${e}, 0, 0, 0, ${-e} ${-e} z`)}})}basicCornersRounded(t){let{size:e,x:i,y:s}=t;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",H`M ${i} ${s} v ${e/2} a ${e/2} ${e/2}, 0, 0, 0, ${e/2} ${e/2} h ${e/2} v ${-e/2} a ${e/2} ${e/2}, 0, 0, 0, ${-e/2} ${-e/2} z`)}})}drawDot({x:t,y:e,size:i}){this.basicDot({x:t,y:e,size:i,rotation:0})}drawRandomDot({x:t,y:e,size:i}){this.basicDot({x:t,y:e,size:i*(.25*Math.random()+.75),rotation:0})}drawSquare({x:t,y:e,size:i}){this.basicSquare({x:t,y:e,size:i,rotation:0})}drawSmallSquare({x:t,y:e,size:i}){this.basicSquare({x:t+.15*i,y:e+.15*i,size:.7*i,rotation:0})}drawTinySquare({x:t,y:e,size:i}){this.basicSquare({x:t+.35*i,y:e+.35*i,size:.3*i,rotation:0})}drawDiamond({x:t,y:e,size:i}){this.basicSquare({x:t,y:e,size:i,rotation:Math.PI/4})}drawRounded({x:t,y:e,size:i,getNeighbor:s}){var r=s?+s(-1,0):0;let o=s?+s(1,0):0,a=s?+s(0,-1):0;var n=r+o+a+(s=s?+s(0,1):0);0===n?this.basicDot({x:t,y:e,size:i,rotation:0}):2<n||r&&o||a&&s?this.basicSquare({x:t,y:e,size:i,rotation:0}):2===n?(n=0,r&&a?n=Math.PI/2:a&&o?n=Math.PI:o&&s&&(n=-Math.PI/2),this.basicCornerRounded({x:t,y:e,size:i,rotation:n})):1===n&&(r=0,a?r=Math.PI/2:o?r=Math.PI:s&&(r=-Math.PI/2),this.basicSideRounded({x:t,y:e,size:i,rotation:r}))}drawVerticalLine({x:t,y:e,size:i,getNeighbor:s}){let r=s?+s(-1,0):0,o=s?+s(1,0):0,a=s?+s(0,-1):0;0===r+o+a+(s=s?+s(0,1):0)||r&&!a&&!s||o&&!a&&!s?this.basicDot({x:t,y:e,size:i,rotation:0}):a&&s?this.basicSquare({x:t,y:e,size:i,rotation:0}):a&&!s?this.basicSideRounded({x:t,y:e,size:i,rotation:Math.PI/2}):s&&!a&&this.basicSideRounded({x:t,y:e,size:i,rotation:-Math.PI/2})}drawHorizontalLine({x:t,y:e,size:i,getNeighbor:s}){let r=s?+s(-1,0):0,o=s?+s(1,0):0,a=s?+s(0,-1):0;0===r+o+a+(s=s?+s(0,1):0)||a&&!r&&!o||s&&!r&&!o?this.basicDot({x:t,y:e,size:i,rotation:0}):r&&o?this.basicSquare({x:t,y:e,size:i,rotation:0}):r&&!o?this.basicSideRounded({x:t,y:e,size:i,rotation:0}):o&&!r&&this.basicSideRounded({x:t,y:e,size:i,rotation:Math.PI})}drawExtraRounded({x:t,y:e,size:i,getNeighbor:s}){var r=s?+s(-1,0):0;let o=s?+s(1,0):0,a=s?+s(0,-1):0;var n=r+o+a+(s=s?+s(0,1):0);0===n?this.basicDot({x:t,y:e,size:i,rotation:0}):2<n||r&&o||a&&s?this.basicSquare({x:t,y:e,size:i,rotation:0}):2===n?(n=0,r&&a?n=Math.PI/2:a&&o?n=Math.PI:o&&s&&(n=-Math.PI/2),this.basicCornerExtraRounded({x:t,y:e,size:i,rotation:n})):1===n&&(r=0,a?r=Math.PI/2:o?r=Math.PI:s&&(r=-Math.PI/2),this.basicSideRounded({x:t,y:e,size:i,rotation:r}))}drawClassy({x:t,y:e,size:i,getNeighbor:s}){let r=s?+s(-1,0):0,o=s?+s(1,0):0,a=s?+s(0,-1):0;0===r+o+a+(s=s?+s(0,1):0)?this.basicCornersRounded({x:t,y:e,size:i,rotation:Math.PI/2}):r||a?o||s?this.basicSquare({x:t,y:e,size:i,rotation:0}):this.basicCornerRounded({x:t,y:e,size:i,rotation:Math.PI/2}):this.basicCornerRounded({x:t,y:e,size:i,rotation:-Math.PI/2})}drawClassyRounded({x:t,y:e,size:i,getNeighbor:s}){let r=s?+s(-1,0):0,o=s?+s(1,0):0,a=s?+s(0,-1):0;0===r+o+a+(s=s?+s(0,1):0)?this.basicCornersRounded({x:t,y:e,size:i,rotation:Math.PI/2}):r||a?o||s?this.basicSquare({x:t,y:e,size:i,rotation:0}):this.basicCornerExtraRounded({x:t,y:e,size:i,rotation:Math.PI/2}):this.basicCornerExtraRounded({x:t,y:e,size:i,rotation:-Math.PI/2})}}let j={toDataURL:t=>"string"==typeof t&&t.startsWith("data:")?Promise.resolve(t):new Promise(((e,i)=>{if("string"==typeof t){const s=new XMLHttpRequest;s.onload=function(){const t=new FileReader;t.onloadend=function(){e(t.result)},t.readAsDataURL(s.response)},s.onerror=s.onabort=s.ontimeout=i,s.open("GET",t,!0),s.responseType="blob",s.send()}else{const i=new FileReader;i.onloadend=function(){e(i.result)},i.readAsDataURL(t)}})),getSize:(t,e)=>new Promise(((i,s)=>{const r=new Image;"string"===e&&(r.crossOrigin=e),r.onload=()=>{i({width:r.width,height:r.height})},r.onerror=r.onabort=s,"string"==typeof t?r.src=t:j.toDataURL(t).then((t=>r.src=t)).catch(s)}))};function K(t){var e=[];let i=1;if("#"===(t=t.toLowerCase())[0]){let s=(t=t.slice(1)).length;4>=s?(e=[parseInt(t[0]+t[0],16),parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16)],4===s&&(i=parseInt(t[3]+t[3],16)/255)):(e=[parseInt(t[0]+t[1],16),parseInt(t[2]+t[3],16),parseInt(t[4]+t[5],16)],8===s&&(i=parseInt(t[6]+t[7],16)/255)),e[0]||(e[0]=0),e[1]||(e[1]=0),e[2]||(e[2]=0)}else{if(!(e=/^((?:rgba?))\s*\(([^)]*)\)/.exec(t)))return{value:t,alpha:i};i=3<(e=(e=e[2].trim().split(/\s*[,/]\s*|\s+/)).map(((t,e)=>"%"===t[t.length-1]?(t=parseFloat(t)/100,3===e?t:255*t):"none"===t?0:parseFloat(t)))).length?e.pop():1}return{value:"#"+e.map((t=>Math.max(0,Math.min(255,t)).toString(16).padStart(2,"0"))).join(""),alpha:Math.max(0,Math.min(1,i))}}let Q=[[1,1,1,1,1,1,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,1,1,1,1,1,1]],V=[[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,1,1,1,0,0],[0,0,1,1,1,0,0],[0,0,1,1,1,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]];class Y{get element(){return this._element}constructor(t){this.options=t,this.document=t.document,this._element=this.document.createElementNS("http://www.w3.org/2000/svg","svg");let e=G(t.width),i=G(t.height);this._element.setAttribute("width",e),this._element.setAttribute("height",i),this._element.setAttribute("viewBox",`0 0 ${e} ${i}`),this.defs=this.document.createElementNS("http://www.w3.org/2000/svg","defs"),this._element.appendChild(this.defs),this.imageTools=t.imageTools||j}get width(){return this.options.width}get height(){return this.options.height}async drawQR(t){let e=t.getModuleCount();var i=parseInt(((e-17)/4).toFixed(0),10);let s=this.options.dotsOptions.size,r={hideXDots:0,hideYDots:0,width:0,height:0};if(this.qr=t,this.options.image){t=await this.imageTools.getSize(this.options.image,this.options.imageOptions.crossOrigin);let{imageOptions:a,errorCorrectionPercent:n}=this.options;if(a.mode==N.background){var o=this.options.backgroundOptions&&this.options.backgroundOptions.margin||0;i=(this.options.width-2*o*s)*a.imageSize,o=(this.options.height-2*o*s)*a.imageSize;let{width:e,height:n}=t;n=n/e*i,e=i,n>o&&(e=e/n*o,n=o),r={hideXDots:0,hideYDots:0,width:e,height:n}}else o=a.imageSize*n,i=p.getPatternPosition(i),r=function({originalHeight:t,originalWidth:e,maxHiddenDots:i,maxHiddenAxisDots:s,dotSize:r,margin:o}){if(0>=t||0>=e||0>=i||0>=r||4*o**2>i)return{height:0,width:0,hideYDots:0,hideXDots:0};s&&0==s%2&&(s=Math.max(1,s-1));var a=Math.max(e,t),n=Math.min(e,t),h=0;s=(s||i)-2*o;do{let t=h+(s-h)/2,e=Math.max(1,Math.ceil(t+2*o));0==e%2&&e++;let r=Math.max(1,Math.ceil(t*n/a+2*o));0==r%2&&r++,e*r>i?s=t:h=t}while(.001<Math.abs(h-s));return 0==(i=Math.max(1,Math.ceil(h+2*o)))%2&&i++,0==(n=Math.max(1,Math.ceil(h*n/a+2*o)))%2&&n++,e>t?a=i:(a=n,n=i),i=s=(a-2*o)*r,(s=s*t/e)>(h=(n-2*o)*r)&&(s=h,i=h*e/t),{height:Math.round(s+2*o*r),width:Math.round(i+2*o*r),hideYDots:n,hideXDots:a}}({originalWidth:t.width,originalHeight:t.height,maxHiddenDots:Math.floor(o*(e*e-192-2*(e-16)-25*i.length**2)),maxHiddenAxisDots:e-14,dotSize:s,margin:a.margin})}this.drawBackground(),this.options.imageOptions.mode!=N.overlay&&this.options.image&&0<r.width&&0<r.height&&await this.drawImage({width:r.width,height:r.height,count:e,dotSize:s}),this.drawDots(((t,i)=>!(this.options.imageOptions.mode==N.center&&t>=(e-r.hideXDots)/2&&t<(e+r.hideXDots)/2&&i>=(e-r.hideYDots)/2&&i<(e+r.hideYDots)/2||8>t&&8>i||t>=e-8&&8>i||i>=e-8&&8>t))),this.options.imageOptions.mode==N.overlay&&this.options.image&&0<r.width&&0<r.height&&await this.drawImage({width:r.width,height:r.height,count:e,dotSize:s}),this.drawCorners()}drawBackground(){let t=this.options;if(this._element&&t.backgroundOptions){this.createColor({options:t.backgroundOptions.gradient,color:t.backgroundOptions.color,additionalRotation:0,x:0,y:0,height:t.height,width:t.width,name:"background-color"});let e=Math.min(t.width,t.height),i=this.document.createElementNS("http://www.w3.org/2000/svg","rect");[this.backgroundMask,this.backgroundMaskGroup]=this.createMask("mask-background-color"),this.defs.appendChild(this.backgroundMask),i.setAttribute("x",G((t.width-e)/2)),i.setAttribute("y",G((t.height-e)/2)),i.setAttribute("width",G(e)),i.setAttribute("height",G(e)),i.setAttribute("rx",G(e/2*(t.backgroundOptions.round||0))),this.backgroundMaskGroup.appendChild(i)}}drawDots(t){if(!this.qr)throw"QR code is not defined";let e=this.options;var i=this.qr.getModuleCount();if(i>e.width||i>e.height)throw"The canvas is too small.";let s=this.options.dotsOptions.size;var r=Math.min(e.width,e.height);e.imageOptions.mode==N.background&&(r-=2*s*(e.imageOptions.margin||0));var o=Math.floor((e.width-i*s)/2),a=Math.floor((e.height-i*s)/2);let n=new X(e.dotsOptions.type,this.document),h=new X(k.tinySquare,this.document),l=new X(k.square,this.document);[this.dotsMask,this.dotsMaskGroup]=this.createMask("mask-dot-color"),this.defs.appendChild(this.dotsMask),e.imageOptions.mode==N.background&&([this.lightDotsMask,this.lightDotsMaskGroup]=this.createMask("mask-light-dot-color"),this.defs.appendChild(this.lightDotsMask));var d=0;let u=0;d=i,e.shape===T.circle?(d=this.options.backgroundOptions&&this.options.backgroundOptions.margin||0,u=Math.floor((r/s-i-2*d)/2),d=i+2*u):e.imageOptions.mode==N.background&&(u=1,d=i+2*u),r=o-u*s,a-=u*s,o=i+2*u;let g=Array(d);var c=Math.floor(d/2);for(let s=0;s<d;s++){g[s]=Array(d);for(let r=0;r<d;r++)if(s>u-1&&s<d-u&&r>u-1&&r<d-u){let e=s-u,i=r-u;t&&!t(e,i)?g[s][r]=void 0:g[s][r]=!!this.qr.isDark(i,e)}else g[s][r]=e.shape===T.circle&&Math.sqrt((s-c)*(s-c)+(r-c)*(r-c))>c?void 0:s==u-1||s==d-u||r==u-1||r==d-u?(r==u-1&&(s<u+8||s>d-u-9)||r==d-u&&s<u+8||s==u-1&&(r<u+8||r>d-u-9)||s==d-u&&r<u+8)&&void 0:this.qr.isDark(0>r-2*u?r:r>=i?r-2*u:r-u,0>s-2*u?s:s>=i?s-2*u:s-u)}t=p.getPatternPosition((i-17)/4);for(let e=0;e<d;e++){i=t.find((t=>e-u>t-3&&e-u<t+3));for(let o=0;o<d;o++)c=t.find((t=>o-u>t-3&&o-u<t+3)),null!=g[e][o]&&(this.lightDotsMask&&(n=i&&c&&(i!=t[0]&&c!=t[0]||c!=t[0]&&c!=t[t.length-1]||i!=t[0]&&i!=t[t.length-1])?l:h),g[e][o]?(n.draw({x:r+e*s,y:a+o*s,size:s,getNeighbor:(t,i)=>!0===g[e+t]?.[o+i]}),n.element&&this.dotsMaskGroup&&this.dotsMaskGroup.appendChild(n.element)):this.lightDotsMask&&(n.draw({x:r+e*s,y:a+o*s,size:s,getNeighbor:(t,i)=>!1===g[e+t]?.[o+i]}),n.element&&this.lightDotsMaskGroup&&this.lightDotsMaskGroup.appendChild(n.element)))}this.lightDotsMask&&this.createColor({options:e.imageOptions.fill.gradient,color:e.imageOptions.fill.color,additionalRotation:0,x:r,y:a,height:o*s,width:o*s,name:"light-dot-color"}),this.createColor({options:e.dotsOptions?.gradient,color:e.dotsOptions.color,additionalRotation:0,x:r,y:a,height:o*s,width:o*s,name:"dot-color"})}drawCorners(){if(!this.qr)throw"QR code is not defined";let t=this.options;if(!this._element)throw"Element code is not defined";let e=this.qr.getModuleCount(),i=this.options.dotsOptions.size,s=7*i,r=3*i,o=Math.floor((t.width-e*i)/2),a=Math.floor((t.height-e*i)/2);[[0,0,0],[1,0,Math.PI/2],[0,1,-Math.PI/2]].forEach((([n,h,l])=>{let d=o+n*i*(e-7),u=a+h*i*(e-7);var g=this.dotsMask;let c=this.dotsMaskGroup;var p=this.dotsMask;if(g=this.dotsMaskGroup,(t.cornersSquareOptions?.gradient||t.cornersSquareOptions?.color)&&([g,c]=this.createMask(`mask-corners-square-color-${n}-${h}`),this.defs.appendChild(g),p=g,g=c,this.createColor({options:t.cornersSquareOptions?.gradient,color:t.cornersSquareOptions?.color,additionalRotation:l,x:d,y:u,height:s,width:s,name:`corners-square-color-${n}-${h}`})),t.cornersSquareOptions?.type)(p=new U(t.cornersSquareOptions.type,this.document)).draw({x:d,y:u,size:s,rotation:l}),p.element&&c&&c.appendChild(p.element),p.fill&&this.lightDotsMaskGroup&&this.lightDotsMaskGroup.appendChild(p.fill);else{p=new X(t.dotsOptions.type,this.document);for(let t=0;t<Q.length;t++)for(let e=0;e<Q[t].length;e++)Q[t]?.[e]?(p.draw({x:d+t*i,y:u+e*i,size:i,getNeighbor:(i,s)=>!!Q[t+i]?.[e+s]}),p.element&&c&&c.appendChild(p.element)):this.lightDotsMask&&!V[t]?.[e]&&(p.draw({x:d+t*i,y:u+e*i,size:i,getNeighbor:(i,s)=>!Q[t+i]?.[e+s]&&!V[t+i]?.[e+s]}),p.element&&this.lightDotsMaskGroup&&this.lightDotsMaskGroup.appendChild(p.element));if(this.lightDotsMask)for(let t=-1;8>t;t++)for(let e=-1;8>e;e++)-1!=t&&7!=t&&-1!=e&&7!=e||(p.draw({x:d+t*i,y:u+e*i,size:i,getNeighbor:(i,s)=>(s=e+s,-1<=(i=t+i)&&7>=i&&-1<=s&&7>=s&&(-1==i||7==i||-1==s||7==s))}),p.element&&this.lightDotsMaskGroup&&this.lightDotsMaskGroup.appendChild(p.element))}if((t.cornersDotOptions?.gradient||t.cornersDotOptions?.color)&&([p,g]=this.createMask(`mask-corners-dot-color-${n}-${h}`),this.defs.appendChild(p),this.createColor({options:t.cornersDotOptions?.gradient,color:t.cornersDotOptions?.color,additionalRotation:l,x:d+2*i,y:u+2*i,height:r,width:r,name:`corners-dot-color-${n}-${h}`})),t.cornersDotOptions?.type)(n=new F(t.cornersDotOptions.type,this.document)).draw({x:d+2*i,y:u+2*i,size:r,rotation:l}),n.element&&g&&g.appendChild(n.element);else{l=new X(t.dotsOptions.type,this.document);for(let t=0;t<V.length;t++)for(let e=0;e<V[t].length;e++)V[t]?.[e]&&(l.draw({x:d+t*i,y:u+e*i,size:i,getNeighbor:(i,s)=>!!V[t+i]?.[e+s]}),l.element&&g&&g.appendChild(l.element))}}))}async drawImage({width:t,height:e,count:i,dotSize:s}){var r=this.options,o=Math.floor((r.width-i*s)/2),a=Math.floor((r.height-i*s)/2),n=r.imageOptions.margin*s;if(r.imageOptions.mode==N.background&&(n=0),o=o+n+(i*s-t)/2,i=a+n+(i*s-e)/2,t-=2*n,e-=2*n,n=await this.imageTools.toDataURL(r.image||""),(r=this.document.createElementNS("http://www.w3.org/2000/svg","image")).setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n||""),n.startsWith("data:image/svg+xml;")){if(s=(n=n.substring(19)).indexOf(","),a=n.substring(0,s),n=n.substring(s+1),"base64"===a)n="function"==typeof atob?atob(n):Buffer.from(n,"base64").toString("utf8");else n="";n&&(n=(new DOMParser).parseFromString(n,"text/xml"),(n=Array.from(n.getElementsByTagName("svg"))).length&&(r=n[0]).setAttribute("overflow","visible"))}r.setAttribute("x",G(o)),r.setAttribute("y",G(i)),r.setAttribute("width",`${G(t)}px`),r.setAttribute("height",`${G(e)}px`),this._element.appendChild(r)}createColor({options:t,color:e,additionalRotation:i,x:s,y:r,height:o,width:a,name:n}){var h=a>o?a:o;let l=this.document.createElementNS("http://www.w3.org/2000/svg","rect");if(l.setAttribute("x",G(s)),l.setAttribute("y",G(r)),l.setAttribute("height",G(o)),l.setAttribute("width",G(a)),l.setAttribute("style",`mask:url(#mask-${n})`),t){let d;if(t.type===x.radial)d=this.document.createElementNS("http://www.w3.org/2000/svg","radialGradient"),d.setAttribute("id",n),d.setAttribute("gradientUnits","userSpaceOnUse"),d.setAttribute("fx",G(s+a/2)),d.setAttribute("fy",G(r+o/2)),d.setAttribute("cx",G(s+a/2)),d.setAttribute("cy",G(r+o/2)),d.setAttribute("r",G(h/2));else{h=s+a/2;let l=r+o/2;s+=a/2,r+=o/2,0<=(i=((e=((t.rotation||0)+i)%(2*Math.PI))+2*Math.PI)%(2*Math.PI))&&i<=.25*Math.PI||i>1.75*Math.PI&&i<=2*Math.PI?(h-=a/2,l-=o/2*Math.tan(e),s+=a/2,r+=o/2*Math.tan(e)):i>.25*Math.PI&&i<=.75*Math.PI?(l-=o/2,h-=a/2/Math.tan(e),r+=o/2,s+=a/2/Math.tan(e)):i>.75*Math.PI&&i<=1.25*Math.PI?(h+=a/2,l+=o/2*Math.tan(e),s-=a/2,r-=o/2*Math.tan(e)):i>1.25*Math.PI&&i<=1.75*Math.PI&&(l+=o/2,h+=a/2/Math.tan(e),r-=o/2,s-=a/2/Math.tan(e)),d=this.document.createElementNS("http://www.w3.org/2000/svg","linearGradient"),d.setAttribute("id",n),d.setAttribute("gradientUnits","userSpaceOnUse"),d.setAttribute("x1",G(h)),d.setAttribute("y1",G(l)),d.setAttribute("x2",G(s)),d.setAttribute("y2",G(r))}t.colorStops.forEach((({offset:t,color:e})=>{let i=this.document.createElementNS("http://www.w3.org/2000/svg","stop");i.setAttribute("offset",`${G(100*t)}%`),t=K(e),i.setAttribute("stop-color",t.value),1>t.alpha&&i.setAttribute("stop-opacity",t.alpha.toFixed(7)),d.appendChild(i)})),l.setAttribute("fill",`url(#${n})`),this.defs.appendChild(d)}else e&&(t=K(e),l.setAttribute("fill",t.value),1>t.alpha&&l.setAttribute("opacity",t.alpha.toFixed(7)));this._element.appendChild(l)}createMask(t){let e=this.options,i=this.document.createElementNS("http://www.w3.org/2000/svg","mask");return i.setAttribute("id",t),i.setAttribute("maskUnits","userSpaceOnUse"),i.setAttribute("x","0"),i.setAttribute("y","0"),i.setAttribute("width",G(e.width)),i.setAttribute("height",G(e.height)),(t=this.document.createElementNS("http://www.w3.org/2000/svg","g")).setAttribute("fill","#fff"),i.appendChild(t),[i,t]}}Object.assign(M.stringToBytesFuncs,{UTF8:function(t){const e=[];for(let i=0;i<t.length;i++){let s=t.charCodeAt(i);128>s?e.push(s):2048>s?e.push(192|s>>6,128|63&s):55296>s||57344<=s?e.push(224|s>>12,128|s>>6&63,128|63&s):(i++,s=65536+((1023&s)<<10|1023&t.charCodeAt(i)),e.push(240|s>>18,128|s>>12&63,128|s>>6&63,128|63&s))}return e}});class J{get size(){if(this.qrSVG)return{width:this.qrSVG.width,height:this.qrSVG.height}}constructor(t){this.options=t?R(v(I,t)):I,this.update()}update(t){this.container&&(this.container.innerHTML=""),this.options=t?R(v(this.options,t)):this.options,this.options.data&&(this.options.stringToBytesFuncs&&(Object.assign(M.stringToBytesFuncs,this.options.stringToBytesFuncs),delete this.options.stringToBytesFuncs),this.qr=new M(this.options.qrOptions.typeNumber,this.options.qrOptions.errorCorrectionLevel),t=this.options.qrOptions.mode||function(t){switch(!0){case/^[0-9]*$/.test(t):return f.numeric;case/^[0-9A-Z $%*+\-./:]*$/.test(t):return f.alphanumeric;case/[^\u0000-\u00ff]/.test(t):return f.unicode;default:return f.byte}}(this.options.data),this.qr.addData(this.options.data,t),this.qr.make(),this.setupSvg(),this.append(this.container))}append(t){t&&(this.qrSVG?.element&&t.appendChild(this.qrSVG.element),this.container=t)}applyExtension(t){if(!t)throw"Extension function should be defined.";this.extension=t,this.update()}deleteExtension(){this.extension=void 0,this.update()}async serialize(){if(!this.qr)throw"QR code is empty";if(this.qrSVG?.element&&this.svgDrawingPromise||this.setupSvg(),await this.svgDrawingPromise,this.qrSVG?.element)return'<?xml version="1.0" standalone="no"?>\r\n'+(new XMLSerializer).serializeToString(this.qrSVG.element)}setupSvg(){if(this.qr){var t=this.qr.getModuleCount();this.options.imageOptions.mode==N.background&&this.options.shape!=T.circle&&(t+=2),0==(t=Math.ceil((this.options.shape==T.circle?Math.sqrt(2):1)*t))%2&&--t;var e=this.options.backgroundOptions&&this.options.backgroundOptions.margin||0;this.options.imageOptions.mode==N.background&&(e+=this.options.imageOptions.margin||0),t=Math.ceil(this.options.dotsOptions.size*(t+2*e)),this.qrSVG=new Y({...this.options,width:t,height:t,errorCorrectionPercent:q[this.options.qrOptions.errorCorrectionLevel]}),this.svgDrawingPromise=this.qrSVG.drawQR(this.qr).then((()=>{this.qrSVG?.element&&this.extension?.(this.qrSVG.element,this.options)}))}}}let W={width:300,height:300,margin:0};var Z,tt=Z||(Z={});function et(t,e){let{width:i,height:s,margin:r}=e?function(t){return(t={...t}).width=Number(t.width),t.height=Number(t.height),t.margin=Number(t.margin),t.margin>Math.min(t.width,t.height)&&(t.margin=Math.min(t.width,t.height)),t}(v(W,e)):W,o=document.createElement("canvas");o.width=i,o.height=s;let a=Math.min(i,s)-2*r;return t=t.serialize().then((t=>{if(t){var e="data:image/svg+xml;base64,"+btoa(t),r=new Image;return new Promise(((t,n)=>{r.onload=()=>{const e=Math.ceil(2*a/Math.min(r.width,r.height));let n;try{n=new OffscreenCanvas(r.width*e,r.height*e)}catch(t){n=document.createElement("canvas"),n.width=r.width*e,n.height=r.height*e}n.getContext("2d")?.drawImage(r,0,0,n.width,n.height),o?.getContext("2d")?.drawImage(n,(i-a)/2,(s-a)/2,a,a),t()},r.onerror=r.onabort=n,r.src=e}))}})),{canvas:o,canvasDrawingPromise:t}}function it(t,e){let i=document.createElement("a");i.download=e,i.href=t,document.body.appendChild(i),i.click(),document.body.removeChild(i)}tt.svg="svg",tt.png="png",tt.jpeg="jpeg",tt.webp="webp";let st=Object.freeze({__proto__:null,get FileExtension(){return Z},download:async function(t,e,i){var s=Z.png;let r="qr";if(e&&(e.name&&(r=e.name),e.extension&&(s=e.extension)),"svg"===s.toLowerCase())(s=await t.serialize())&&it(s="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(s),`${r}.svg`);else if(t=et(t,i)){var{canvas:o,canvasDrawingPromise:a}=t;await a,it(t=o.toDataURL(`image/${s}`),`${r}.${s}`)}},downloadURI:it,drawToCanvas:et});export{S as CornerDotType,C as CornerSquareType,k as DotType,b as ErrorCorrectionLevel,q as ErrorCorrectionPercents,Z as FileExtension,x as GradientType,N as ImageMode,f as Mode,J as QRCodeStyling,T as ShapeType,w as TypeNumber,st as browserUtils};
1
+ class t{constructor(){this.buffer=[],this.length=0}getBuffer(){return this.buffer}getLengthInBits(){return this.length}toString(){let t="";for(let e=0;e<this.getLengthInBits();e+=1)t+=this.getBit(e)?"1":"0";return t}getBit(t){return 1==(this.buffer[~~(t/8)]>>>7-t%8&1)}put(t,e){for(let i=0;i<e;i+=1)this.putBit(1==(t>>>e-i-1&1))}putBit(t){this.length==8*this.buffer.length&&this.buffer.push(0),t&&(this.buffer[~~(this.length/8)]|=128>>>this.length%8),this.length+=1}}var e,i=e||(e={});i[i.L=1]="L",i[i.M=0]="M",i[i.Q=3]="Q",i[i.H=2]="H";class s{constructor(){throw"error"}static glog(t){if(1>t)throw"log("+t+")";return s.LOG_TABLE[t]}static gexp(t){for(;0>t;)t+=255;for(;256<=t;)t-=255;return s.EXP_TABLE[t]}}s.EXP_TABLE=[],s.LOG_TABLE=[];for(let t=0;256>t;t+=1)s.EXP_TABLE.push(8>t?1<<t:s.EXP_TABLE[t-4]^s.EXP_TABLE[t-5]^s.EXP_TABLE[t-6]^s.EXP_TABLE[t-8]),s.LOG_TABLE.push(0);for(let t=0;255>t;t+=1)s.LOG_TABLE[s.EXP_TABLE[t]]=t;s.initialize=void 0;class r{constructor(t,e=0){let i=0;for(;i<t.length&&0==t[i];)i+=1;this.num=[];let s=t.length-i;for(let e=0;e<s;e+=1)this.num.push(t[i+e]);for(t=0;t<e;t+=1)this.num.push(0)}getAt(t){return this.num[t]}getLength(){return this.num.length}toString(){let t="";for(let e=0;e<this.getLength();e+=1)0<e&&(t+=","),t+=this.getAt(e);return t.toString()}toLogString(){let t="";for(let e=0;e<this.getLength();e+=1)0<e&&(t+=","),t+=s.glog(this.getAt(e));return t.toString()}multiply(t){let e=[];for(var i=this.getLength()+t.getLength()-1,o=0;o<i;o+=1)e.push(0);for(i=0;i<this.getLength();i+=1)for(o=0;o<t.getLength();o+=1)e[i+o]^=s.gexp(s.glog(this.getAt(i))+s.glog(t.getAt(o)));return new r(e)}mod(t){if(0>this.getLength()-t.getLength())return this;let e=s.glog(this.getAt(0))-s.glog(t.getAt(0)),i=[];for(var o=0;o<this.getLength();o+=1)i.push(this.getAt(o));for(o=0;o<t.getLength();o+=1)i[o]^=s.gexp(s.glog(t.getAt(o))+e);return new r(i).mod(t)}}var o,a=o||(o={});a[a.MODE_NUMBER=1]="MODE_NUMBER",a[a.MODE_ALPHA_NUM=2]="MODE_ALPHA_NUM",a[a.MODE_8BIT_BYTE=4]="MODE_8BIT_BYTE",a[a.MODE_KANJI=8]="MODE_KANJI";class n{constructor(t,e){this.mode=t,this.data=e}getMode(){return this.mode}getData(){return this.data}getLengthInBits(t){if(1<=t&&10>t)switch(this.mode){case o.MODE_NUMBER:return 10;case o.MODE_ALPHA_NUM:return 9;case o.MODE_8BIT_BYTE:case o.MODE_KANJI:return 8;default:throw"mode:"+this.mode}else if(27>t)switch(this.mode){case o.MODE_NUMBER:return 12;case o.MODE_ALPHA_NUM:return 11;case o.MODE_8BIT_BYTE:return 16;case o.MODE_KANJI:return 10;default:throw"mode:"+this.mode}else{if(!(41>t))throw"typeNumber:"+t;switch(this.mode){case o.MODE_NUMBER:return 14;case o.MODE_ALPHA_NUM:return 13;case o.MODE_8BIT_BYTE:return 16;case o.MODE_KANJI:return 12;default:throw"mode:"+this.mode}}}}class h extends n{constructor(t,e){super(o.MODE_8BIT_BYTE,t),this.stringToBytes=e}write(t){let e=this.stringToBytes(this.getData());for(let i=0;i<e.length;i+=1)t.put(e[i],8)}getLength(){return this.stringToBytes(this.getData()).length}}class l extends n{constructor(t){super(o.MODE_ALPHA_NUM,t)}write(t){let e=this.getData(),i=0;for(;i+1<e.length;)t.put(45*l.getCode(e.charAt(i))+l.getCode(e.charAt(i+1)),11),i+=2;i<e.length&&t.put(l.getCode(e.charAt(i)),6)}getLength(){return this.getData().length}static getCode(t){if("0"<=t&&"9">=t)return t.charCodeAt(0)-48;if("A"<=t&&"Z">=t)return t.charCodeAt(0)-65+10;switch(t){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+t}}}class d extends n{constructor(t,e){super(o.MODE_KANJI,t),this.stringToBytes=e}write(t){let e=this.stringToBytes(this.getData()),i=0;for(;i+1<e.length;){let s=(255&e[i])<<8|255&e[i+1];if(33088<=s&&40956>=s)s-=33088;else{if(!(57408<=s&&60351>=s))throw"illegal char at "+(i+1)+"/"+s;s-=49472}s=192*(s>>>8&255)+(255&s),t.put(s,13),i+=2}if(i<e.length)throw"illegal char at "+(i+1)}getLength(){return this.stringToBytes(this.getData()).length/2}}class u extends n{constructor(t){super(o.MODE_NUMBER,t)}write(t){let e=this.getData(),i=0;for(;i+2<e.length;)t.put(u.strToNum(e.substring(i,i+3)),10),i+=3;i<e.length&&(1==e.length-i?t.put(u.strToNum(e.substring(i,i+1)),4):2==e.length-i&&t.put(u.strToNum(e.substring(i,i+2)),7))}getLength(){return this.getData().length}static strToNum(t){let e=0;for(let i=0;i<t.length;i+=1)e=10*e+u.chatToNum(t.charAt(i));return e}static chatToNum(t){if("0"<=t&&"9">=t)return t.charCodeAt(0)-48;throw"illegal char :"+t}}var g,c=g||(g={});c[c.PATTERN000=0]="PATTERN000",c[c.PATTERN001=1]="PATTERN001",c[c.PATTERN010=2]="PATTERN010",c[c.PATTERN011=3]="PATTERN011",c[c.PATTERN100=4]="PATTERN100",c[c.PATTERN101=5]="PATTERN101",c[c.PATTERN110=6]="PATTERN110",c[c.PATTERN111=7]="PATTERN111";class p{constructor(){throw"error"}static getPatternPosition(t){return p.PATTERN_POSITION_TABLE[t-1]}static getMaxLength(t,i,s){switch(s){case e.L:s=0;break;case e.M:s=1;break;case e.Q:s=2;break;case e.H:s=3;break;default:throw"e:"+s}switch(i){case o.MODE_NUMBER:i=0;break;case o.MODE_ALPHA_NUM:i=1;break;case o.MODE_8BIT_BYTE:i=2;break;case o.MODE_KANJI:i=3;break;default:throw"m:"+i}return p.MAX_LENGTH[t-1][s][i]}static getErrorCorrectPolynomial(t){let e=new r([1]);for(let i=0;i<t;i+=1)e=e.multiply(new r([1,s.gexp(i)]));return e}static getMaskFunc(t){switch(t){case g.PATTERN000:return(t,e)=>0==(t+e)%2;case g.PATTERN001:return t=>0==t%2;case g.PATTERN010:return(t,e)=>0==e%3;case g.PATTERN011:return(t,e)=>0==(t+e)%3;case g.PATTERN100:return(t,e)=>0==(~~(t/2)+~~(e/3))%2;case g.PATTERN101:return(t,e)=>0==t*e%2+t*e%3;case g.PATTERN110:return(t,e)=>0==(t*e%2+t*e%3)%2;case g.PATTERN111:return(t,e)=>0==(t*e%3+(t+e)%2)%2;default:throw"mask:"+t}}static getLostPoint(t){let e=t.getModuleCount(),i=0;for(var s=0;s<e;s+=1)for(var r=0;r<e;r+=1){var o=0;let a=t.isDark(s,r);for(let i=-1;1>=i;i+=1)if(!(0>s+i||e<=s+i))for(let n=-1;1>=n;n+=1)0>r+n||e<=r+n||(0!=i||0!=n)&&a==t.isDark(s+i,r+n)&&(o+=1);5<o&&(i+=3+o-5)}for(s=0;s<e-1;s+=1)for(r=0;r<e-1;r+=1)o=0,t.isDark(s,r)&&(o+=1),t.isDark(s+1,r)&&(o+=1),t.isDark(s,r+1)&&(o+=1),t.isDark(s+1,r+1)&&(o+=1),(0==o||4==o)&&(i+=3);for(s=0;s<e;s+=1)for(r=0;r<e-6;r+=1)t.isDark(s,r)&&!t.isDark(s,r+1)&&t.isDark(s,r+2)&&t.isDark(s,r+3)&&t.isDark(s,r+4)&&!t.isDark(s,r+5)&&t.isDark(s,r+6)&&(i+=40);for(s=0;s<e;s+=1)for(r=0;r<e-6;r+=1)t.isDark(r,s)&&!t.isDark(r+1,s)&&t.isDark(r+2,s)&&t.isDark(r+3,s)&&t.isDark(r+4,s)&&!t.isDark(r+5,s)&&t.isDark(r+6,s)&&(i+=40);for(s=0,r=0;r<e;r+=1)for(o=0;o<e;o+=1)t.isDark(o,r)&&(s+=1);return i+Math.abs(100*s/e/e-50)/5*10}static getBCHTypeInfo(t){let e=t<<10;for(;0<=p.getBCHDigit(e)-p.getBCHDigit(p.G15);)e^=p.G15<<p.getBCHDigit(e)-p.getBCHDigit(p.G15);return(t<<10|e)^p.G15_MASK}static getBCHTypeNumber(t){let e=t<<12;for(;0<=p.getBCHDigit(e)-p.getBCHDigit(p.G18);)e^=p.G18<<p.getBCHDigit(e)-p.getBCHDigit(p.G18);return t<<12|e}static getBCHDigit(t){let e=0;for(;0!=t;)e+=1,t>>>=1;return e}}p.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]],p.MAX_LENGTH=[[[41,25,17,10],[34,20,14,8],[27,16,11,7],[17,10,7,4]],[[77,47,32,20],[63,38,26,16],[48,29,20,12],[34,20,14,8]],[[127,77,53,32],[101,61,42,26],[77,47,32,20],[58,35,24,15]],[[187,114,78,48],[149,90,62,38],[111,67,46,28],[82,50,34,21]],[[255,154,106,65],[202,122,84,52],[144,87,60,37],[106,64,44,27]],[[322,195,134,82],[255,154,106,65],[178,108,74,45],[139,84,58,36]],[[370,224,154,95],[293,178,122,75],[207,125,86,53],[154,93,64,39]],[[461,279,192,118],[365,221,152,93],[259,157,108,66],[202,122,84,52]],[[552,335,230,141],[432,262,180,111],[312,189,130,80],[235,143,98,60]],[[652,395,271,167],[513,311,213,131],[364,221,151,93],[288,174,119,74]]],p.G15=1335,p.G18=7973,p.G15_MASK=21522;class m{constructor(t,e){this.totalCount=t,this.dataCount=e}getDataCount(){return this.dataCount}getTotalCount(){return this.totalCount}static getRSBlocks(t,e){e=(t=m.getRsBlockTable(t,e)).length/3;let i=[];for(let s=0;s<e;s+=1){let e=t[3*s],r=t[3*s+1],o=t[3*s+2];for(let t=0;t<e;t+=1)i.push(new m(r,o))}return i}static getRsBlockTable(t,i){switch(i){case e.L:return m.RS_BLOCK_TABLE[4*(t-1)];case e.M:return m.RS_BLOCK_TABLE[4*(t-1)+1];case e.Q:return m.RS_BLOCK_TABLE[4*(t-1)+2];case e.H:return m.RS_BLOCK_TABLE[4*(t-1)+3]}throw"tn:"+t+"/ecl:"+i}}m.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,7,37,13],[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]];let w=Array(41).fill(0).map(((t,e)=>e));var b,$=b||(b={});$.L="L",$.M="M",$.Q="Q",$.H="H";var f,y=f||(f={});y.numeric="numeric",y.alphanumeric="alphanumeric",y.byte="byte",y.kanji="kanji",y.unicode="unicode";class M{constructor(t=0,i=b.L){this.modules=[],this.moduleCount=0,this.typeNumber=t,this.errorCorrectLevel=e[i],this.qrDataList=[]}getTypeNumber(){return this.typeNumber}setTypeNumber(t){this.typeNumber=t}getErrorCorrectLevel(){return this.errorCorrectLevel}setErrorCorrectLevel(t){this.errorCorrectLevel=t}clearData(){this.qrDataList=[]}addData(t,e=f.byte){if(t instanceof n)this.qrDataList.push(t);else{if("string"!=typeof t)throw typeof t;switch(e){case f.numeric:this.qrDataList.push(new u(t));break;case f.alphanumeric:this.qrDataList.push(new l(t));break;case f.byte:this.qrDataList.push(new h(t,M.stringToBytesFuncs.default));break;case f.unicode:this.qrDataList.push(new h(t,M.stringToBytesFuncs.UTF8));break;case f.kanji:this.qrDataList.push(new d(t,M.stringToBytesFuncs.SJIS));break;default:throw"mode:"+e}}}isDark(t,e){return null!=this.modules[t][e]&&this.modules[t][e]}getModuleCount(){return this.moduleCount}make(){if(1>this.typeNumber){let s=1;for(;40>s;s++){let r=m.getRSBlocks(s,this.errorCorrectLevel),o=new t;for(var e=0;e<this.qrDataList.length;e++){var i=this.qrDataList[e];o.put(i.getMode(),4),o.put(i.getLength(),i.getLengthInBits(s)),i.write(o)}for(e=0,i=0;i<r.length;i++)e+=r[i].getDataCount();if(o.getLengthInBits()<=8*e)break}this.typeNumber=s}this.makeImpl(!1,this.getBestMaskPattern())}getBestMaskPattern(){let t=0,e=0;for(let i=0;8>i;i+=1){this.makeImpl(!0,i);let s=p.getLostPoint(this);(0==i||t>s)&&(t=s,e=i)}return e}makeImpl(t,e){this.moduleCount=4*this.typeNumber+17,this.modules=[];for(let t=0;t<this.moduleCount;t+=1){this.modules.push([]);for(let e=0;e<this.moduleCount;e+=1)this.modules[t].push(null)}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(t,e),7<=this.typeNumber&&this.setupTypeNumber(t),t=M.createData(this.typeNumber,this.errorCorrectLevel,this.qrDataList),this.mapData(t,e)}mapData(t,e){let i=-1,s=this.moduleCount-1,r=7,o=0;e=p.getMaskFunc(e);for(let a=this.moduleCount-1;0<a;a-=2)for(6==a&&--a;;){for(let i=0;2>i;i+=1)if(null==this.modules[s][a-i]){let n=!1;o<t.length&&(n=1==(t[o]>>>r&1)),e(s,a-i)&&(n=!n),this.modules[s][a-i]=n,--r,-1==r&&(o+=1,r=7)}if(s+=i,0>s||this.moduleCount<=s){s-=i,i=-i;break}}}setupPositionAdjustPattern(){let t=p.getPatternPosition(this.typeNumber);for(let e=0;e<t.length;e+=1)for(let i=0;i<t.length;i+=1){let s=t[e],r=t[i];if(null==this.modules[s][r])for(let t=-2;2>=t;t+=1)for(let e=-2;2>=e;e+=1)this.modules[s+t][r+e]=-2==t||2==t||-2==e||2==e||0==t&&0==e}}setupPositionProbePattern(t,e){for(let i=-1;7>=i;i+=1)for(let s=-1;7>=s;s+=1)-1>=t+i||this.moduleCount<=t+i||-1>=e+s||this.moduleCount<=e+s||(this.modules[t+i][e+s]=0<=i&&6>=i&&(0==s||6==s)||0<=s&&6>=s&&(0==i||6==i)||2<=i&&4>=i&&2<=s&&4>=s)}setupTimingPattern(){for(var t=8;t<this.moduleCount-8;t+=1)null==this.modules[t][6]&&(this.modules[t][6]=0==t%2);for(t=8;t<this.moduleCount-8;t+=1)null==this.modules[6][t]&&(this.modules[6][t]=0==t%2)}setupTypeNumber(t){let e=p.getBCHTypeNumber(this.typeNumber);for(var i=0;18>i;i+=1)this.modules[~~(i/3)][i%3+this.moduleCount-8-3]=!t&&1==(e>>i&1);for(i=0;18>i;i+=1)this.modules[i%3+this.moduleCount-8-3][~~(i/3)]=!t&&1==(e>>i&1)}setupTypeInfo(t,e){e=p.getBCHTypeInfo(this.errorCorrectLevel<<3|e);for(var i=0;15>i;i+=1){var s=!t&&1==(e>>i&1);6>i?this.modules[i][8]=s:8>i?this.modules[i+1][8]=s:this.modules[this.moduleCount-15+i][8]=s}for(i=0;15>i;i+=1)s=!t&&1==(e>>i&1),8>i?this.modules[8][this.moduleCount-i-1]=s:9>i?this.modules[8][15-i-1+1]=s:this.modules[8][15-i-1]=s;this.modules[this.moduleCount-8][8]=!t}static createData(e,i,s){i=m.getRSBlocks(e,i);let r=new t;for(let t=0;t<s.length;t+=1){let i=s[t];r.put(i.getMode(),4),r.put(i.getLength(),i.getLengthInBits(e)),i.write(r)}for(e=0,s=0;s<i.length;s+=1)e+=i[s].getDataCount();if(r.getLengthInBits()>8*e)throw"code length overflow. ("+r.getLengthInBits()+">"+8*e+")";for(r.getLengthInBits()+4<=8*e&&r.put(0,4);0!=r.getLengthInBits()%8;)r.putBit(!1);for(;!(r.getLengthInBits()>=8*e)&&(r.put(M.PAD0,8),!(r.getLengthInBits()>=8*e));)r.put(M.PAD1,8);return M.createBytes(r,i)}static createBytes(t,e){function i(t){let e=[];for(let i=0;i<t;i+=1)e.push(0);return e}var s=0,o=0;let a=0;var n=[];let h=[];for(var l=0;l<e.length;l+=1)n.push([]),h.push([]);for(l=0;l<e.length;l+=1){var d=e[l].getDataCount(),u=e[l].getTotalCount()-d;o=Math.max(o,d),a=Math.max(a,u),n[l]=i(d);for(var g=0;g<n[l].length;g+=1)n[l][g]=255&t.getBuffer()[g+s];for(s+=d,u=p.getErrorCorrectPolynomial(u),d=new r(n[l],u.getLength()-1).mod(u),h[l]=i(u.getLength()-1),u=0;u<h[l].length;u+=1)g=u+d.getLength()-h[l].length,h[l][u]=0<=g?d.getAt(g):0}for(t=0,s=0;s<e.length;s+=1)t+=e[s].getTotalCount();for(t=i(t),s=0,l=0;l<o;l+=1)for(d=0;d<e.length;d+=1)l<n[d].length&&(t[s]=n[d][l],s+=1);for(o=0;o<a;o+=1)for(n=0;n<e.length;n+=1)o<h[n].length&&(t[s]=h[n][o],s+=1);return t}}M.PAD0=236,M.PAD1=17,M.stringToBytesFuncs={default:function(t){let e=[];for(let i=0;i<t.length;i+=1){let s=t.charCodeAt(i);e.push(255&s)}return e}};let A=t=>!!t&&"object"==typeof t&&!Array.isArray(t);function v(t,...e){if(!e.length)return t;let i=e.shift();return void 0!==i&&A(t)&&A(i)?(t={...t},Object.keys(i).forEach((e=>{let s=t[e],r=i[e];Array.isArray(s)&&Array.isArray(r)?t[e]=r:A(s)&&A(r)?t[e]=v(Object.assign({},s),r):t[e]=r})),v(t,...e)):t}var x,D=x||(x={});function _(t){if(!(t={...t}).colorStops||!t.colorStops.length)throw"Field 'colorStops' is required in gradient";return t.rotation=t.rotation?Number(t.rotation):0,t.colorStops=t.colorStops.map((t=>({...t,offset:Number(t.offset)}))),t}D.radial="radial",D.linear="linear";var k,E=k||(k={});E.dot="dot",E.randomDot="random-dot",E.rounded="rounded",E.extraRounded="extra-rounded",E.verticalLine="vertical-line",E.horizontalLine="horizontal-line",E.classy="classy",E.classyRounded="classy-rounded",E.square="square",E.smallSquare="small-square",E.tinySquare="tiny-square",E.diamond="diamond";var S,z=S||(S={});z.dot="dot",z.square="square",z.heart="heart",z.extraRounded="extra-rounded",z.classy="classy",z.outpoint="outpoint",z.inpoint="inpoint";var C,O=C||(C={});O.dot="dot",O.square="square",O.extraRounded="extra-rounded",O.classy="classy",O.outpoint="outpoint",O.inpoint="inpoint";var T,P=T||(T={});P.square="square",P.circle="circle";var N,L=N||(N={});L.center="center",L.overlay="overlay",L.background="background";let I={document:void 0,shape:T.square,width:void 0,height:void 0,data:"",qrOptions:{typeNumber:w[0],mode:void 0,errorCorrectionLevel:b.Q},imageOptions:{mode:N.center,imageSize:.4,crossOrigin:void 0,margin:0,fill:{color:"rgba(255,255,255,1)"}},dotsOptions:{type:k.square,color:"#000",size:10}};function R(t){return(t={...t}).imageOptions={...t.imageOptions,imageSize:Math.min(1,Number(t.imageOptions.imageSize))||1,margin:Number(t.imageOptions.margin),fill:{...t.imageOptions.fill}},t.imageOptions.mode==N.overlay&&(t.imageOptions.margin=0),t.imageOptions.fill.gradient&&(t.imageOptions.fill.gradient=_(t.imageOptions.fill.gradient)),t.dotsOptions={...t.dotsOptions},t.dotsOptions.gradient&&(t.dotsOptions.gradient=_(t.dotsOptions.gradient)),t.dotsOptions.size=Math.round(Math.max(0,t.dotsOptions.size)||10),t.cornersSquareOptions&&(t.cornersSquareOptions={...t.cornersSquareOptions},t.cornersSquareOptions.gradient&&(t.cornersSquareOptions.gradient=_(t.cornersSquareOptions.gradient))),t.cornersDotOptions&&(t.cornersDotOptions={...t.cornersDotOptions},t.cornersDotOptions.gradient&&(t.cornersDotOptions.gradient=_(t.cornersDotOptions.gradient))),t.backgroundOptions&&(t.backgroundOptions={...t.backgroundOptions},t.backgroundOptions.gradient&&(t.backgroundOptions.gradient=_(t.backgroundOptions.gradient))),t.document||(t.document=document),t}let q={[b.L]:.07,[b.M]:.15,[b.Q]:.25,[b.H]:.3};let B=/\.?0+$/;function G(t){return t.toFixed(7).replace(B,"")}function H(t,...e){return t.reduce(((t,i,s)=>{let r="";return s&&(r=e[s-1]),"number"==typeof r&&(r=G(r)),`${t}${r}${i}`}),"").trim().replace(/[\s\n\r]+/gim," ")}class F{get element(){return this._element}constructor(t,e){this.type=t,this.document=e}draw(t){let e;switch(this.type){case S.square:e=this.drawSquare;break;case S.heart:e=this.drawHeart;break;case S.extraRounded:e=this.drawRounded;break;case S.classy:e=this.drawClassy;break;case S.inpoint:e=this.drawInpoint;break;case S.outpoint:e=this.drawOutpoint;break;default:e=this.drawDot}e.call(this,t)}rotateFigure({x:t,y:e,size:i,rotation:s=0,draw:r}){t+=i/2,e+=i/2,r(),this._element?.setAttribute("transform",`rotate(${G(180*s/Math.PI)},${t},${e})`)}basicDot(t){let{size:e,x:i,y:s}=t;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","circle"),this._element.setAttribute("cx",G(i+e/2)),this._element.setAttribute("cy",G(s+e/2)),this._element.setAttribute("r",G(e/2))}})}basicSquare(t){let{size:e,x:i,y:s}=t;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","rect"),this._element.setAttribute("x",G(i)),this._element.setAttribute("y",G(s)),this._element.setAttribute("width",G(e)),this._element.setAttribute("height",G(e))}})}basicHeart(t){let{size:e,x:i,y:s}=t;this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path");let r=!1,o=0;this._element.setAttribute("d",["M",1,.3262506,"c",0,.0383376,-.0064626,.0758377,-.0193751,.1125001,"s",-.0356247,.076875,-.0681248,.1206252,"c",-.0325,.0437499,-.0762503,.0931247,-.1312501,.1481249,"C",.7262502,.7625008,.6566626,.8279132,.5724999,.9037505,"L",.5,.9687506,"L",.4275001,.9037505,"C",.3433374,.8279132,.2737499,.7625005,.21875,.7075007,"C",.1637501,.6525008,.1199999,.6031258,.0874999,.5593758,"S",.0322876,.4754133,.0193751,.4387506,"S",0,.3645881,0,.3262506,"c",0,-.0783374,.0262499,-.1437498,.07875,-.1962499,"s",.1179124,-.07875,.1962499,-.07875,"c",.0433376,0,.0845875,.0091625,.12375,.0274999,"S",.4716623,.1229131,.5,.1562506,"c",.0283374,-.0333375,.0620874,-.0591625,.1012502,-.0775,"c",.0391627,-.0183375,.0804126,-.0274999,.12375,-.0274999,"c",.0783374,0,.1437497,.0262499,.1962501,.07875,"S",1,.2479131,1,.3262506,"z"].map((t=>"string"==typeof t?(o=0,r=t.toUpperCase()==t,t):(o++,t*=e,r&&(t+=1==o%2?i:s),G(t)))).join(" "))}basicRounded(t){let{size:e,x:i,y:s}=t;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","rect"),this._element.setAttribute("x",G(i)),this._element.setAttribute("y",G(s)),this._element.setAttribute("width",G(e)),this._element.setAttribute("height",G(e)),this._element.setAttribute("rx",G(e/4)),this._element.setAttribute("ry",G(e/4))}})}basicClassy(t){let{size:e,x:i,y:s}=t,r=e/7;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",H`M ${i} ${s+2.5*r} v ${2*r} a ${2.5*r} ${2.5*r}, 0, 0, 0, ${2.5*r} ${2.5*r} h ${4.5*r} v ${-4.5*r} a ${2.5*r} ${2.5*r}, 0, 0, 0, ${2.5*-r} ${2.5*-r} h ${-2*r} H ${i} z`)}})}basicInpoint(t){let{size:e,x:i,y:s}=t;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",H`M ${i} ${s+e/2} v ${e/4} a ${e/4}, ${e/4} 0 0 0 ${e/4}, ${e/4} h ${e/4*3} v ${-e/4*3} a ${e/4}, ${e/4} 0 0 0 ${-e/4}, ${-e/4} h ${-e/2} a ${e/4}, ${e/4} 0 0 0 ${-e/4}, ${e/4} z`)}})}drawDot({x:t,y:e,size:i,rotation:s}){this.basicDot({x:t,y:e,size:i,rotation:s})}drawSquare({x:t,y:e,size:i,rotation:s}){this.basicSquare({x:t,y:e,size:i,rotation:s})}drawHeart({x:t,y:e,size:i,rotation:s}){this.basicHeart({x:t,y:e,size:i,rotation:s})}drawRounded({x:t,y:e,size:i,rotation:s}){this.basicRounded({x:t,y:e,size:i,rotation:s})}drawClassy({x:t,y:e,size:i,rotation:s}){this.basicClassy({x:t,y:e,size:i,rotation:s})}drawInpoint({x:t,y:e,size:i,rotation:s}){this.basicInpoint({x:t,y:e,size:i,rotation:s})}drawOutpoint({x:t,y:e,size:i,rotation:s}){this.basicInpoint({x:t,y:e,size:i,rotation:(s||0)+Math.PI})}}class U{get element(){return this._element}get fill(){return this._fill}constructor(t,e){this.type=t,this.document=e}draw(t){let e;switch(this.type){case C.square:e=this.drawSquare;break;case C.extraRounded:e=this.drawExtraRounded;break;case C.classy:e=this.drawClassy;break;case C.outpoint:e=this.drawOutpoint;break;case C.inpoint:e=this.drawInpoint;break;default:e=this.drawDot}e.call(this,t)}rotateFigure({x:t,y:e,size:i,rotation:s=0,draw:r}){t+=i/2,e+=i/2,r(),this._element?.setAttribute("transform",`rotate(${G(180*s/Math.PI)},${t},${e})`),this._fill?.setAttribute("transform",`rotate(${G(180*s/Math.PI)},${t},${e})`)}basicDot(t){let{size:e,x:i,y:s}=t,r=e/7;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",H`M ${i+e/2} ${s} a ${e/2} ${e/2} 0 1 0 0.1 0 z m 0 ${r} a ${e/2-r} ${e/2-r} 0 1 1 -0.1 0 Z`),this._fill=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._fill.setAttribute("clip-rule","evenodd"),this._fill.setAttribute("d",H`M ${i+e/2} ${s-r} a ${e/2+r} ${e/2+r} 0 1 0 0.1 0 z`)}})}basicSquare(t){let{size:e,x:i,y:s}=t,r=e/7;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",H`M ${i} ${s} v ${e} h ${e} v ${-e} z M ${i+r} ${s+r} h ${e-2*r} v ${e-2*r} h ${2*r-e} z`),this._fill=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._fill.setAttribute("clip-rule","evenodd"),this._fill.setAttribute("d",H`M ${i-r} ${s-r} h ${e+2*r} v ${e+2*r} h ${-e-2*r} z`)}})}basicExtraRounded(t){let{size:e,x:i,y:s}=t,r=e/7;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",H`M ${i} ${s+2.5*r} v ${2*r} a ${2.5*r} ${2.5*r}, 0, 0, 0, ${2.5*r} ${2.5*r} h ${2*r} a ${2.5*r} ${2.5*r}, 0, 0, 0, ${2.5*r} ${2.5*-r} v ${-2*r} a ${2.5*r} ${2.5*r}, 0, 0, 0, ${2.5*-r} ${2.5*-r} h ${-2*r} a ${2.5*r} ${2.5*r}, 0, 0, 0, ${2.5*-r} ${2.5*r} z M ${i+2.5*r} ${s+r} h ${2*r} a ${1.5*r} ${1.5*r}, 0, 0, 1, ${1.5*r} ${1.5*r} v ${2*r} a ${1.5*r} ${1.5*r}, 0, 0, 1, ${1.5*-r} ${1.5*r} h ${-2*r} a ${1.5*r} ${1.5*r}, 0, 0, 1, ${1.5*-r} ${1.5*-r} v ${-2*r} a ${1.5*r} ${1.5*r}, 0, 0, 1, ${1.5*r} ${1.5*-r} z`),this._fill=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._fill.setAttribute("clip-rule","evenodd"),this._fill.setAttribute("d",H`M ${i-r} ${s+2.5*r} v ${2*r} a ${3.5*r} ${3.5*r}, 0, 0, 0, ${3.5*r} ${3.5*r} h ${2*r} a ${3.5*r} ${3.5*r}, 0, 0, 0, ${3.5*r} ${3.5*-r} v ${-2*r} a ${3.5*r} ${3.5*r}, 0, 0, 0, ${3.5*-r} ${3.5*-r} h ${-2*r} a ${3.5*r} ${3.5*r}, 0, 0, 0, ${3.5*-r} ${3.5*r} z`)}})}basicClassy(t){let{size:e,x:i,y:s}=t,r=e/7;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",H`M ${i} ${s+2.5*r} v ${2*r} a ${2.5*r} ${2.5*r}, 0, 0, 0, ${2.5*r} ${2.5*r} h ${4.5*r} v ${-4.5*r} a ${2.5*r} ${2.5*r}, 0, 0, 0, ${2.5*-r} ${2.5*-r} h ${-2*r} H ${i} z M ${i+2.5*r} ${s+r} h ${2*r} a ${1.5*r} ${1.5*r}, 0, 0, 1, ${1.5*r} ${1.5*r} v ${3.5*r} h ${-3.5*r} a ${1.5*r} ${1.5*r}, 0, 0, 1, ${1.5*-r} ${1.5*-r} v ${-3.5*r} z`),this._fill=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._fill.setAttribute("clip-rule","evenodd"),this._fill.setAttribute("d",H`M ${i+.5*r} ${s-r} h ${4*r} a ${3.5*r} ${3.5*r}, 0, 0, 1, ${3.5*r} ${3.5*r} v ${5.5*r} h ${-5.5*r} a ${3.5*r} ${3.5*r}, 0, 0, 1, ${3.5*-r} ${3.5*-r} v ${-5.5*r} z`)}})}basicInpoint(t){let{size:e,x:i,y:s}=t,r=e/7;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",H`M ${i} ${s+2.5*r} v ${2*r} a ${2.5*r} ${2.5*r}, 0, 0, 0, ${2.5*r} ${2.5*r} h ${4.5*r} v ${-4.5*r} a ${2.5*r} ${2.5*r}, 0, 0, 0, ${2.5*-r} ${2.5*-r} h ${-2*r} a ${2.5*r} ${2.5*r}, 0, 0, 0, ${2.5*-r} ${2.5*r} z M ${i+2.5*r} ${s+r} h ${2*r} a ${1.5*r} ${1.5*r}, 0, 0, 1, ${1.5*r} ${1.5*r} v ${3.5*r} h ${-3.5*r} a ${1.5*r} ${1.5*r}, 0, 0, 1, ${1.5*-r} ${1.5*-r} v ${-2*r} a ${1.5*r} ${1.5*r}, 0, 0, 1, ${1.5*r} ${1.5*-r} z`),this._fill=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._fill.setAttribute("clip-rule","evenodd"),this._fill.setAttribute("d",H`M ${i+.5*r} ${s-r} h ${4*r} a ${3.5*r} ${3.5*r}, 0, 0, 1, ${3.5*r} ${3.5*r} v ${5.5*r} h ${-5.5*r} a ${3.5*r} ${3.5*r}, 0, 0, 1, ${3.5*-r} ${3.5*-r} v ${-2*r} a ${3.5*r} ${3.5*r}, 0, 0, 1, ${3.5*r} ${3.5*-r} z`)}})}drawDot({x:t,y:e,size:i,rotation:s}){this.basicDot({x:t,y:e,size:i,rotation:s})}drawSquare({x:t,y:e,size:i,rotation:s}){this.basicSquare({x:t,y:e,size:i,rotation:s})}drawExtraRounded({x:t,y:e,size:i,rotation:s}){this.basicExtraRounded({x:t,y:e,size:i,rotation:s})}drawClassy({x:t,y:e,size:i,rotation:s}){this.basicClassy({x:t,y:e,size:i,rotation:s})}drawInpoint({x:t,y:e,size:i,rotation:s}){this.basicInpoint({x:t,y:e,size:i,rotation:s})}drawOutpoint({x:t,y:e,size:i,rotation:s}){this.basicInpoint({x:t,y:e,size:i,rotation:(s||0)+Math.PI})}}class X{get element(){return this._element}constructor(t,e){this.type=t,this.document=e}draw(t){let e;switch(this.type){case k.dot:e=this.drawDot;break;case k.randomDot:e=this.drawRandomDot;break;case k.classy:e=this.drawClassy;break;case k.classyRounded:e=this.drawClassyRounded;break;case k.rounded:e=this.drawRounded;break;case k.verticalLine:e=this.drawVerticalLine;break;case k.horizontalLine:e=this.drawHorizontalLine;break;case k.extraRounded:e=this.drawExtraRounded;break;case k.diamond:e=this.drawDiamond;break;case k.smallSquare:e=this.drawSmallSquare;break;case k.tinySquare:e=this.drawTinySquare;break;default:e=this.drawSquare}e.call(this,t)}rotateFigure({x:t,y:e,size:i,rotation:s=0,draw:r}){t+=i/2,e+=i/2,r(),this._element?.setAttribute("transform",`rotate(${G(180*s/Math.PI)},${t},${e})`)}basicDot(t){let{size:e,x:i,y:s}=t;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","circle"),this._element.setAttribute("cx",G(i+e/2)),this._element.setAttribute("cy",G(s+e/2)),this._element.setAttribute("r",G(e/2))}})}basicSquare(t){let{size:e,x:i,y:s}=t;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","rect"),this._element.setAttribute("x",G(i)),this._element.setAttribute("y",G(s)),this._element.setAttribute("width",G(e)),this._element.setAttribute("height",G(e))}})}basicSideRounded(t){let{size:e,x:i,y:s}=t;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",H`M ${i} ${s} v ${e} h ${e/2} a ${e/2} ${e/2}, 0, 0, 0, 0 ${-e} z`)}})}basicCornerRounded(t){let{size:e,x:i,y:s}=t;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",H`M ${i} ${s} v ${e} h ${e} v ${-e/2} a ${e/2} ${e/2}, 0, 0, 0, ${-e/2} ${-e/2} z`)}})}basicCornerExtraRounded(t){let{size:e,x:i,y:s}=t;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",H`M ${i} ${s} v ${e} h ${e} a ${e} ${e}, 0, 0, 0, ${-e} ${-e} z`)}})}basicCornersRounded(t){let{size:e,x:i,y:s}=t;this.rotateFigure({...t,draw:()=>{this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",H`M ${i} ${s} v ${e/2} a ${e/2} ${e/2}, 0, 0, 0, ${e/2} ${e/2} h ${e/2} v ${-e/2} a ${e/2} ${e/2}, 0, 0, 0, ${-e/2} ${-e/2} z`)}})}drawDot({x:t,y:e,size:i}){this.basicDot({x:t,y:e,size:i,rotation:0})}drawRandomDot({x:t,y:e,size:i}){this.basicDot({x:t,y:e,size:i*(.25*Math.random()+.75),rotation:0})}drawSquare({x:t,y:e,size:i}){this.basicSquare({x:t,y:e,size:i,rotation:0})}drawSmallSquare({x:t,y:e,size:i}){this.basicSquare({x:t+.15*i,y:e+.15*i,size:.7*i,rotation:0})}drawTinySquare({x:t,y:e,size:i}){this.basicSquare({x:t+.35*i,y:e+.35*i,size:.3*i,rotation:0})}drawDiamond({x:t,y:e,size:i}){this.basicSquare({x:t,y:e,size:i,rotation:Math.PI/4})}drawRounded({x:t,y:e,size:i,getNeighbor:s}){var r=s?+s(-1,0):0;let o=s?+s(1,0):0,a=s?+s(0,-1):0;var n=r+o+a+(s=s?+s(0,1):0);0===n?this.basicDot({x:t,y:e,size:i,rotation:0}):2<n||r&&o||a&&s?this.basicSquare({x:t,y:e,size:i,rotation:0}):2===n?(n=0,r&&a?n=Math.PI/2:a&&o?n=Math.PI:o&&s&&(n=-Math.PI/2),this.basicCornerRounded({x:t,y:e,size:i,rotation:n})):1===n&&(r=0,a?r=Math.PI/2:o?r=Math.PI:s&&(r=-Math.PI/2),this.basicSideRounded({x:t,y:e,size:i,rotation:r}))}drawVerticalLine({x:t,y:e,size:i,getNeighbor:s}){let r=s?+s(-1,0):0,o=s?+s(1,0):0,a=s?+s(0,-1):0;0===r+o+a+(s=s?+s(0,1):0)||r&&!a&&!s||o&&!a&&!s?this.basicDot({x:t,y:e,size:i,rotation:0}):a&&s?this.basicSquare({x:t,y:e,size:i,rotation:0}):a&&!s?this.basicSideRounded({x:t,y:e,size:i,rotation:Math.PI/2}):s&&!a&&this.basicSideRounded({x:t,y:e,size:i,rotation:-Math.PI/2})}drawHorizontalLine({x:t,y:e,size:i,getNeighbor:s}){let r=s?+s(-1,0):0,o=s?+s(1,0):0,a=s?+s(0,-1):0;0===r+o+a+(s=s?+s(0,1):0)||a&&!r&&!o||s&&!r&&!o?this.basicDot({x:t,y:e,size:i,rotation:0}):r&&o?this.basicSquare({x:t,y:e,size:i,rotation:0}):r&&!o?this.basicSideRounded({x:t,y:e,size:i,rotation:0}):o&&!r&&this.basicSideRounded({x:t,y:e,size:i,rotation:Math.PI})}drawExtraRounded({x:t,y:e,size:i,getNeighbor:s}){var r=s?+s(-1,0):0;let o=s?+s(1,0):0,a=s?+s(0,-1):0;var n=r+o+a+(s=s?+s(0,1):0);0===n?this.basicDot({x:t,y:e,size:i,rotation:0}):2<n||r&&o||a&&s?this.basicSquare({x:t,y:e,size:i,rotation:0}):2===n?(n=0,r&&a?n=Math.PI/2:a&&o?n=Math.PI:o&&s&&(n=-Math.PI/2),this.basicCornerExtraRounded({x:t,y:e,size:i,rotation:n})):1===n&&(r=0,a?r=Math.PI/2:o?r=Math.PI:s&&(r=-Math.PI/2),this.basicSideRounded({x:t,y:e,size:i,rotation:r}))}drawClassy({x:t,y:e,size:i,getNeighbor:s}){let r=s?+s(-1,0):0,o=s?+s(1,0):0,a=s?+s(0,-1):0;0===r+o+a+(s=s?+s(0,1):0)?this.basicCornersRounded({x:t,y:e,size:i,rotation:Math.PI/2}):r||a?o||s?this.basicSquare({x:t,y:e,size:i,rotation:0}):this.basicCornerRounded({x:t,y:e,size:i,rotation:Math.PI/2}):this.basicCornerRounded({x:t,y:e,size:i,rotation:-Math.PI/2})}drawClassyRounded({x:t,y:e,size:i,getNeighbor:s}){let r=s?+s(-1,0):0,o=s?+s(1,0):0,a=s?+s(0,-1):0;0===r+o+a+(s=s?+s(0,1):0)?this.basicCornersRounded({x:t,y:e,size:i,rotation:Math.PI/2}):r||a?o||s?this.basicSquare({x:t,y:e,size:i,rotation:0}):this.basicCornerExtraRounded({x:t,y:e,size:i,rotation:Math.PI/2}):this.basicCornerExtraRounded({x:t,y:e,size:i,rotation:-Math.PI/2})}}let j={toDataURL:t=>"string"==typeof t&&t.startsWith("data:")?Promise.resolve(t):new Promise(((e,i)=>{if("string"==typeof t){const s=new XMLHttpRequest;s.onload=function(){const t=new FileReader;t.onloadend=function(){e(t.result)},t.readAsDataURL(s.response)},s.onerror=s.onabort=s.ontimeout=i,s.open("GET",t,!0),s.responseType="blob",s.send()}else{const i=new FileReader;i.onloadend=function(){e(i.result)},i.readAsDataURL(t)}})),getSize:(t,e)=>new Promise(((i,s)=>{const r=new Image;"string"===e&&(r.crossOrigin=e),r.onload=()=>{i({width:r.width,height:r.height})},r.onerror=r.onabort=s,"string"==typeof t?r.src=t:j.toDataURL(t).then((t=>r.src=t)).catch(s)}))};function K(t){var e=[];let i=1;if("#"===(t=t.toLowerCase())[0]){let s=(t=t.slice(1)).length;4>=s?(e=[parseInt(t[0]+t[0],16),parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16)],4===s&&(i=parseInt(t[3]+t[3],16)/255)):(e=[parseInt(t[0]+t[1],16),parseInt(t[2]+t[3],16),parseInt(t[4]+t[5],16)],8===s&&(i=parseInt(t[6]+t[7],16)/255)),e[0]||(e[0]=0),e[1]||(e[1]=0),e[2]||(e[2]=0)}else{if(!(e=/^((?:rgba?))\s*\(([^)]*)\)/.exec(t)))return{value:t,alpha:i};i=3<(e=(e=e[2].trim().split(/\s*[,/]\s*|\s+/)).map(((t,e)=>"%"===t[t.length-1]?(t=parseFloat(t)/100,3===e?t:255*t):"none"===t?0:parseFloat(t)))).length?e.pop():1}return{value:"#"+e.map((t=>Math.max(0,Math.min(255,t)).toString(16).padStart(2,"0"))).join(""),alpha:Math.max(0,Math.min(1,i))}}let Q=[[1,1,1,1,1,1,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,1,1,1,1,1,1]],V=[[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,1,1,1,0,0],[0,0,1,1,1,0,0],[0,0,1,1,1,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]];class Y{get element(){return this._element}constructor(t){this.options=t,this.document=t.document,this._element=this.document.createElementNS("http://www.w3.org/2000/svg","svg");let e=G(t.width),i=G(t.height);this._element.setAttribute("width",e),this._element.setAttribute("height",i),this._element.setAttribute("viewBox",`0 0 ${e} ${i}`),this.defs=this.document.createElementNS("http://www.w3.org/2000/svg","defs"),this._element.appendChild(this.defs),this.imageTools=t.imageTools||j}get width(){return this.options.width}get height(){return this.options.height}async drawQR(t){let e=t.getModuleCount();var i=parseInt(((e-17)/4).toFixed(0),10);let s=this.options.dotsOptions.size,r={hideXDots:0,hideYDots:0,width:0,height:0};if(this.qr=t,this.options.image){t=await this.imageTools.getSize(this.options.image,this.options.imageOptions.crossOrigin);let{imageOptions:a,errorCorrectionPercent:n}=this.options;if(a.mode==N.background){var o=this.options.backgroundOptions&&this.options.backgroundOptions.margin||0;i=(this.options.width-2*o*s)*a.imageSize,o=(this.options.height-2*o*s)*a.imageSize;let{width:e,height:n}=t;n=n/e*i,e=i,n>o&&(e=e/n*o,n=o),r={hideXDots:0,hideYDots:0,width:e,height:n}}else o=a.imageSize*n,i=p.getPatternPosition(i),r=function({originalHeight:t,originalWidth:e,maxHiddenDots:i,maxHiddenAxisDots:s,dotSize:r,margin:o}){if(0>=t||0>=e||0>=i||0>=r||4*o**2>i)return{height:0,width:0,hideYDots:0,hideXDots:0};s&&0==s%2&&(s=Math.max(1,s-1));var a=Math.max(e,t),n=Math.min(e,t),h=0;s=(s||i)-2*o;do{let t=h+(s-h)/2,e=Math.max(1,Math.ceil(t+2*o));0==e%2&&e++;let r=Math.max(1,Math.ceil(t*n/a+2*o));0==r%2&&r++,e*r>i?s=t:h=t}while(.001<Math.abs(h-s));return 0==(i=Math.max(1,Math.ceil(h+2*o)))%2&&i++,0==(n=Math.max(1,Math.ceil(h*n/a+2*o)))%2&&n++,e>t?a=i:(a=n,n=i),i=s=(a-2*o)*r,(s=s*t/e)>(h=(n-2*o)*r)&&(s=h,i=h*e/t),{height:Math.round(s+2*o*r),width:Math.round(i+2*o*r),hideYDots:n,hideXDots:a}}({originalWidth:t.width,originalHeight:t.height,maxHiddenDots:Math.floor(o*(e*e-192-2*(e-16)-25*i.length**2)),maxHiddenAxisDots:e-14,dotSize:s,margin:a.margin})}this.drawBackground(),this.options.imageOptions.mode!=N.overlay&&this.options.image&&0<r.width&&0<r.height&&await this.drawImage({width:r.width,height:r.height,count:e,dotSize:s}),this.drawDots(((t,i)=>!(this.options.imageOptions.mode==N.center&&t>=(e-r.hideXDots)/2&&t<(e+r.hideXDots)/2&&i>=(e-r.hideYDots)/2&&i<(e+r.hideYDots)/2||8>t&&8>i||t>=e-8&&8>i||i>=e-8&&8>t))),this.options.imageOptions.mode==N.overlay&&this.options.image&&0<r.width&&0<r.height&&await this.drawImage({width:r.width,height:r.height,count:e,dotSize:s}),this.drawCorners()}drawBackground(){let t=this.options;if(this._element&&t.backgroundOptions){this.createColor({options:t.backgroundOptions.gradient,color:t.backgroundOptions.color,additionalRotation:0,x:0,y:0,height:t.height,width:t.width,name:"background-color"});let e=Math.min(t.width,t.height),i=this.document.createElementNS("http://www.w3.org/2000/svg","rect");[this.backgroundMask,this.backgroundMaskGroup]=this.createMask("mask-background-color"),this.defs.appendChild(this.backgroundMask),i.setAttribute("x",G((t.width-e)/2)),i.setAttribute("y",G((t.height-e)/2)),i.setAttribute("width",G(e)),i.setAttribute("height",G(e)),i.setAttribute("rx",G(e/2*(t.backgroundOptions.round||0))),this.backgroundMaskGroup.appendChild(i)}}drawDots(t){if(!this.qr)throw"QR code is not defined";let e=this.options;var i=this.qr.getModuleCount();if(i>e.width||i>e.height)throw"The canvas is too small.";let s=this.options.dotsOptions.size;var r=Math.min(e.width,e.height);e.imageOptions.mode==N.background&&(r-=2*s*(e.imageOptions.margin||0));var o=Math.floor((e.width-i*s)/2),a=Math.floor((e.height-i*s)/2);let n=new X(e.dotsOptions.type,this.document),h=new X(k.tinySquare,this.document),l=new X(k.square,this.document);[this.dotsMask,this.dotsMaskGroup]=this.createMask("mask-dot-color"),this.defs.appendChild(this.dotsMask),e.imageOptions.mode==N.background&&([this.lightDotsMask,this.lightDotsMaskGroup]=this.createMask("mask-light-dot-color"),this.defs.appendChild(this.lightDotsMask));var d=0;let u=0;d=i,e.shape===T.circle?(d=this.options.backgroundOptions&&this.options.backgroundOptions.margin||0,u=Math.floor((r/s-i-2*d)/2),d=i+2*u):e.imageOptions.mode==N.background&&(u=1,d=i+2*u),r=o-u*s,a-=u*s,o=i+2*u;let g=Array(d);var c=Math.floor(d/2);for(let s=0;s<d;s++){g[s]=Array(d);for(let r=0;r<d;r++)if(s>u-1&&s<d-u&&r>u-1&&r<d-u){let e=s-u,i=r-u;t&&!t(e,i)?g[s][r]=void 0:g[s][r]=!!this.qr.isDark(i,e)}else g[s][r]=e.shape===T.circle&&Math.sqrt((s-c)*(s-c)+(r-c)*(r-c))>c?void 0:s==u-1||s==d-u||r==u-1||r==d-u?(r==u-1&&(s<u+8||s>d-u-9)||r==d-u&&s<u+8||s==u-1&&(r<u+8||r>d-u-9)||s==d-u&&r<u+8)&&void 0:this.qr.isDark(0>r-2*u?r:r>=i?r-2*u:r-u,0>s-2*u?s:s>=i?s-2*u:s-u)}t=p.getPatternPosition((i-17)/4);for(let e=0;e<d;e++){i=t.find((t=>e-u>t-3&&e-u<t+3));for(let o=0;o<d;o++)c=t.find((t=>o-u>t-3&&o-u<t+3)),null!=g[e][o]&&(this.lightDotsMask&&(n=i&&c&&(i!=t[0]&&c!=t[0]||c!=t[0]&&c!=t[t.length-1]||i!=t[0]&&i!=t[t.length-1])?l:h),g[e][o]?(n.draw({x:r+e*s,y:a+o*s,size:s,getNeighbor:(t,i)=>!0===g[e+t]?.[o+i]}),n.element&&this.dotsMaskGroup&&this.dotsMaskGroup.appendChild(n.element)):this.lightDotsMask&&(n.draw({x:r+e*s,y:a+o*s,size:s,getNeighbor:(t,i)=>!1===g[e+t]?.[o+i]}),n.element&&this.lightDotsMaskGroup&&this.lightDotsMaskGroup.appendChild(n.element)))}this.lightDotsMask&&this.createColor({options:e.imageOptions.fill.gradient,color:e.imageOptions.fill.color,additionalRotation:0,x:r,y:a,height:o*s,width:o*s,name:"light-dot-color"}),this.createColor({options:e.dotsOptions?.gradient,color:e.dotsOptions.color,additionalRotation:0,x:r,y:a,height:o*s,width:o*s,name:"dot-color"})}drawCorners(){if(!this.qr)throw"QR code is not defined";let t=this.options;if(!this._element)throw"Element code is not defined";let e=this.qr.getModuleCount(),i=this.options.dotsOptions.size,s=7*i,r=3*i,o=Math.floor((t.width-e*i)/2),a=Math.floor((t.height-e*i)/2);[[0,0,0],[1,0,Math.PI/2],[0,1,-Math.PI/2]].forEach((([n,h,l])=>{let d=o+n*i*(e-7),u=a+h*i*(e-7);var g=this.dotsMask;let c=this.dotsMaskGroup;var p=this.dotsMask;if(g=this.dotsMaskGroup,(t.cornersSquareOptions?.gradient||t.cornersSquareOptions?.color)&&([g,c]=this.createMask(`mask-corners-square-color-${n}-${h}`),this.defs.appendChild(g),p=g,g=c,this.createColor({options:t.cornersSquareOptions?.gradient,color:t.cornersSquareOptions?.color,additionalRotation:l,x:d,y:u,height:s,width:s,name:`corners-square-color-${n}-${h}`})),t.cornersSquareOptions?.type)(p=new U(t.cornersSquareOptions.type,this.document)).draw({x:d,y:u,size:s,rotation:l}),p.element&&c&&c.appendChild(p.element),p.fill&&this.lightDotsMaskGroup&&this.lightDotsMaskGroup.appendChild(p.fill);else{p=new X(t.dotsOptions.type,this.document);for(let t=0;t<Q.length;t++)for(let e=0;e<Q[t].length;e++)Q[t]?.[e]?(p.draw({x:d+t*i,y:u+e*i,size:i,getNeighbor:(i,s)=>!!Q[t+i]?.[e+s]}),p.element&&c&&c.appendChild(p.element)):this.lightDotsMask&&!V[t]?.[e]&&(p.draw({x:d+t*i,y:u+e*i,size:i,getNeighbor:(i,s)=>!Q[t+i]?.[e+s]&&!V[t+i]?.[e+s]}),p.element&&this.lightDotsMaskGroup&&this.lightDotsMaskGroup.appendChild(p.element));if(this.lightDotsMask)for(let t=-1;8>t;t++)for(let e=-1;8>e;e++)-1!=t&&7!=t&&-1!=e&&7!=e||(p.draw({x:d+t*i,y:u+e*i,size:i,getNeighbor:(i,s)=>(s=e+s,-1<=(i=t+i)&&7>=i&&-1<=s&&7>=s&&(-1==i||7==i||-1==s||7==s))}),p.element&&this.lightDotsMaskGroup&&this.lightDotsMaskGroup.appendChild(p.element))}if((t.cornersDotOptions?.gradient||t.cornersDotOptions?.color)&&([p,g]=this.createMask(`mask-corners-dot-color-${n}-${h}`),this.defs.appendChild(p),this.createColor({options:t.cornersDotOptions?.gradient,color:t.cornersDotOptions?.color,additionalRotation:l,x:d+2*i,y:u+2*i,height:r,width:r,name:`corners-dot-color-${n}-${h}`})),t.cornersDotOptions?.type)(n=new F(t.cornersDotOptions.type,this.document)).draw({x:d+2*i,y:u+2*i,size:r,rotation:l}),n.element&&g&&g.appendChild(n.element);else{l=new X(t.dotsOptions.type,this.document);for(let t=0;t<V.length;t++)for(let e=0;e<V[t].length;e++)V[t]?.[e]&&(l.draw({x:d+t*i,y:u+e*i,size:i,getNeighbor:(i,s)=>!!V[t+i]?.[e+s]}),l.element&&g&&g.appendChild(l.element))}}))}async drawImage({width:t,height:e,count:i,dotSize:s}){var r=this.options,o=Math.floor((r.width-i*s)/2),a=Math.floor((r.height-i*s)/2),n=r.imageOptions.margin*s;if(r.imageOptions.mode==N.background&&(n=0),o=o+n+(i*s-t)/2,i=a+n+(i*s-e)/2,t-=2*n,e-=2*n,n=await this.imageTools.toDataURL(r.image||""),(r=this.document.createElementNS("http://www.w3.org/2000/svg","image")).setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n||""),n.startsWith("data:image/svg+xml;")){if(s=(n=n.substring(19)).indexOf(","),a=n.substring(0,s),n=n.substring(s+1),"base64"===a)n="function"==typeof atob?atob(n):Buffer.from(n,"base64").toString("utf8");else n="";n&&(n=(new DOMParser).parseFromString(n,"text/xml"),(n=Array.from(n.getElementsByTagName("svg"))).length&&(r=n[0]).setAttribute("overflow","visible"))}r.setAttribute("x",G(o)),r.setAttribute("y",G(i)),r.setAttribute("width",`${G(t)}px`),r.setAttribute("height",`${G(e)}px`),this._element.appendChild(r)}createColor({options:t,color:e,additionalRotation:i,x:s,y:r,height:o,width:a,name:n}){var h=a>o?a:o;let l=this.document.createElementNS("http://www.w3.org/2000/svg","rect");if(l.setAttribute("x",G(s)),l.setAttribute("y",G(r)),l.setAttribute("height",G(o)),l.setAttribute("width",G(a)),l.setAttribute("style",`mask:url(#mask-${n})`),t){let d;if(t.type===x.radial)d=this.document.createElementNS("http://www.w3.org/2000/svg","radialGradient"),d.setAttribute("id",n),d.setAttribute("gradientUnits","userSpaceOnUse"),d.setAttribute("fx",G(s+a/2)),d.setAttribute("fy",G(r+o/2)),d.setAttribute("cx",G(s+a/2)),d.setAttribute("cy",G(r+o/2)),d.setAttribute("r",G(h/2));else{h=s+a/2;let l=r+o/2;s+=a/2,r+=o/2,0<=(i=((e=((t.rotation||0)+i)%(2*Math.PI))+2*Math.PI)%(2*Math.PI))&&i<=.25*Math.PI||i>1.75*Math.PI&&i<=2*Math.PI?(h-=a/2,l-=o/2*Math.tan(e),s+=a/2,r+=o/2*Math.tan(e)):i>.25*Math.PI&&i<=.75*Math.PI?(l-=o/2,h-=a/2/Math.tan(e),r+=o/2,s+=a/2/Math.tan(e)):i>.75*Math.PI&&i<=1.25*Math.PI?(h+=a/2,l+=o/2*Math.tan(e),s-=a/2,r-=o/2*Math.tan(e)):i>1.25*Math.PI&&i<=1.75*Math.PI&&(l+=o/2,h+=a/2/Math.tan(e),r-=o/2,s-=a/2/Math.tan(e)),d=this.document.createElementNS("http://www.w3.org/2000/svg","linearGradient"),d.setAttribute("id",n),d.setAttribute("gradientUnits","userSpaceOnUse"),d.setAttribute("x1",G(h)),d.setAttribute("y1",G(l)),d.setAttribute("x2",G(s)),d.setAttribute("y2",G(r))}t.colorStops.forEach((({offset:t,color:e})=>{let i=this.document.createElementNS("http://www.w3.org/2000/svg","stop");i.setAttribute("offset",`${G(100*t)}%`),t=K(e),i.setAttribute("stop-color",t.value),1>t.alpha&&i.setAttribute("stop-opacity",t.alpha.toFixed(7)),d.appendChild(i)})),l.setAttribute("fill",`url(#${n})`),this.defs.appendChild(d)}else e&&(t=K(e),l.setAttribute("fill",t.value),1>t.alpha&&l.setAttribute("opacity",t.alpha.toFixed(7)));this._element.appendChild(l)}createMask(t){let e=this.options,i=this.document.createElementNS("http://www.w3.org/2000/svg","mask");return i.setAttribute("id",t),i.setAttribute("maskUnits","userSpaceOnUse"),i.setAttribute("x","0"),i.setAttribute("y","0"),i.setAttribute("width",G(e.width)),i.setAttribute("height",G(e.height)),(t=this.document.createElementNS("http://www.w3.org/2000/svg","g")).setAttribute("fill","#fff"),i.appendChild(t),[i,t]}}Object.assign(M.stringToBytesFuncs,{UTF8:function(t){const e=[];for(let i=0;i<t.length;i++){let s=t.charCodeAt(i);128>s?e.push(s):2048>s?e.push(192|s>>6,128|63&s):55296>s||57344<=s?e.push(224|s>>12,128|s>>6&63,128|63&s):(i++,s=65536+((1023&s)<<10|1023&t.charCodeAt(i)),e.push(240|s>>18,128|s>>12&63,128|s>>6&63,128|63&s))}return e}});class J{get size(){if(this.qrSVG)return{width:this.qrSVG.width,height:this.qrSVG.height}}constructor(t){this.options=t?R(v(I,t)):I,this.update()}update(t){this.container&&(this.container.innerHTML=""),this.options=t?R(v(this.options,t)):this.options,this.options.data&&(this.options.stringToBytesFuncs&&(Object.assign(M.stringToBytesFuncs,this.options.stringToBytesFuncs),delete this.options.stringToBytesFuncs),this.qr=new M(this.options.qrOptions.typeNumber,this.options.qrOptions.errorCorrectionLevel),t=this.options.qrOptions.mode||function(t){switch(!0){case/^[0-9]*$/.test(t):return f.numeric;case/^[0-9A-Z $%*+\-./:]*$/.test(t):return f.alphanumeric;case/[^\u0000-\u00ff]/.test(t):return f.unicode;default:return f.byte}}(this.options.data),this.qr.addData(this.options.data,t),this.qr.make(),this.setupSvg(),this.append(this.container))}append(t){t&&(this.qrSVG?.element&&t.appendChild(this.qrSVG.element),this.container=t)}applyExtension(t){if(!t)throw"Extension function should be defined.";this.extension=t,this.update()}deleteExtension(){this.extension=void 0,this.update()}async serialize(){if(!this.qr)throw"QR code is empty";if(this.qrSVG?.element&&this.svgDrawingPromise||this.setupSvg(),await this.svgDrawingPromise,this.qrSVG?.element)return'<?xml version="1.0" standalone="no"?>\r\n'+(new XMLSerializer).serializeToString(this.qrSVG.element)}setupSvg(){if(this.qr){var t=this.qr.getModuleCount();this.options.imageOptions.mode==N.background&&this.options.shape!=T.circle&&(t+=2),0==(t=Math.ceil((this.options.shape==T.circle?Math.sqrt(2):1)*t))%2&&--t;var e=this.options.backgroundOptions&&this.options.backgroundOptions.margin||0;this.options.imageOptions.mode==N.background&&(e+=this.options.imageOptions.margin||0),t=Math.ceil(this.options.dotsOptions.size*(t+2*e)),this.qrSVG=new Y({...this.options,width:t,height:t,errorCorrectionPercent:q[this.options.qrOptions.errorCorrectionLevel]}),this.svgDrawingPromise=this.qrSVG.drawQR(this.qr).then((()=>{this.qrSVG?.element&&this.extension?.(this.qrSVG.element,this.options)}))}}}let W={width:300,height:300,margin:0};var Z,tt=Z||(Z={});function et(t,e){let{width:i,height:s,margin:r}=e?function(t){return(t={...t}).width=Number(t.width),t.height=Number(t.height),t.margin=Number(t.margin),t.margin>Math.min(t.width,t.height)&&(t.margin=Math.min(t.width,t.height)),t}(v(W,e)):W,o=document.createElement("canvas");o.width=i,o.height=s;let a=Math.min(i,s)-2*r;return t=t.serialize().then((t=>{if(t){var e="data:image/svg+xml;base64,"+btoa(t),r=new Image;return new Promise(((t,n)=>{r.onload=()=>{const e=Math.ceil(2*a/Math.min(r.width,r.height));let n;try{n=new OffscreenCanvas(r.width*e,r.height*e)}catch(t){n=document.createElement("canvas"),n.width=r.width*e,n.height=r.height*e}n.getContext("2d")?.drawImage(r,0,0,n.width,n.height),o?.getContext("2d")?.drawImage(n,(i-a)/2,(s-a)/2,a,a),t()},r.onerror=r.onabort=n,r.src=e}))}})),{canvas:o,canvasDrawingPromise:t}}function it(t,e){let i=document.createElement("a");i.download=e,i.href=t,document.body.appendChild(i),i.click(),document.body.removeChild(i)}tt.svg="svg",tt.png="png",tt.jpeg="jpeg",tt.webp="webp";let st=Object.freeze({__proto__:null,get FileExtension(){return Z},download:async function(t,e,i){var s=Z.png;let r="qr";if(e&&(e.name&&(r=e.name),e.extension&&(s=e.extension)),"svg"===s.toLowerCase())(s=await t.serialize())&&it(s="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(s),`${r}.svg`);else if(t=et(t,i)){var{canvas:o,canvasDrawingPromise:a}=t;await a,it(t=o.toDataURL(`image/${s}`),`${r}.${s}`)}},downloadURI:it,drawToCanvas:et});export{S as CornerDotType,C as CornerSquareType,k as DotType,b as ErrorCorrectionLevel,q as ErrorCorrectionPercents,Z as FileExtension,x as GradientType,N as ImageMode,f as Mode,J as QRCodeStyling,T as ShapeType,w as TypeNumber,st as browserUtils};
2
2
  //# sourceMappingURL=qr-code-styling.js.map