@liquid-js/qr-code-styling 5.4.3 → 5.4.5

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
- import{svgPath as t,numToAttr as e,scalePath as r,rotateFigure as i}from"./plugin-utils.js";import{s,c as o}from"./color-dXYWdVDW.js";export{G as GradientType}from"./color-dXYWdVDW.js";class a{buffer;length;constructor(){this.buffer=[],this.length=0}getBuffer(){return this.buffer}getLengthInBits(){return this.length}toString(){var 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 r=0;r<e;r+=1)this.putBit(1==(t>>>e-r-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 n,h=n||={};h[h.L=1]="L",h[h.M=0]="M",h[h.Q=3]="Q",h[h.H=2]="H";class u{constructor(){throw Error("error")}static initialize;static EXP_TABLE;static LOG_TABLE;static glog(t){if(u.LOG_TABLE||u.initialize(),t<1)throw Error("log("+t+")");return u.LOG_TABLE[t]}static gexp(t){for(u.EXP_TABLE||u.initialize();t<0;)t+=255;for(;t>=256;)t-=255;return u.EXP_TABLE[t]}}u.initialize=()=>{u.EXP_TABLE=[],u.LOG_TABLE=[];for(var t=0;t<256;t+=1)u.EXP_TABLE.push(t<8?1<<t:u.EXP_TABLE[t-4]^u.EXP_TABLE[t-5]^u.EXP_TABLE[t-6]^u.EXP_TABLE[t-8]),u.LOG_TABLE.push(0);for(t=0;t<255;t+=1)u.LOG_TABLE[u.EXP_TABLE[t]]=t};class d{num;constructor(t,e=0){for(var r=0;r<t.length&&0==t[r];)r+=1;this.num=[];var i=t.length-r;for(let e=0;e<i;e+=1)this.num.push(t[r+e]);for(t=0;t<e;t+=1)this.num.push(0)}getAt(t){return this.num[t]}getLength(){return this.num.length}toString(){var t="";for(let e=0;e<this.getLength();e+=1)e>0&&(t+=","),t+=this.getAt(e);return t.toString()}toLogString(){var t="";for(let e=0;e<this.getLength();e+=1)e>0&&(t+=","),t+=u.glog(this.getAt(e));return t.toString()}multiply(t){for(var e=[],r=this.getLength()+t.getLength()-1,i=0;i<r;i+=1)e.push(0);for(r=0;r<this.getLength();r+=1)for(i=0;i<t.getLength();i+=1)e[r+i]^=u.gexp(u.glog(this.getAt(r))+u.glog(t.getAt(i)));return new d(e)}mod(t){if(this.getLength()-t.getLength()<0)return this;for(var e=u.glog(this.getAt(0))-u.glog(t.getAt(0)),r=[],i=0;i<this.getLength();i+=1)r.push(this.getAt(i));for(i=0;i<t.getLength();i+=1)r[i]^=u.gexp(u.glog(t.getAt(i))+e);return new d(r).mod(t)}}var l,g=l||={};g[g.MODE_NUMBER=1]="MODE_NUMBER",g[g.MODE_ALPHA_NUM=2]="MODE_ALPHA_NUM",g[g.MODE_8BIT_BYTE=4]="MODE_8BIT_BYTE",g[g.MODE_KANJI=8]="MODE_KANJI";class c{mode;data;constructor(t,e){this.mode=t,this.data=e}getMode(){return this.mode}getData(){return this.data}getLengthInBits(t){if(1<=t&&t<10)switch(this.mode){case l.MODE_NUMBER:return 10;case l.MODE_ALPHA_NUM:return 9;case l.MODE_8BIT_BYTE:case l.MODE_KANJI:return 8;default:throw Error("mode:"+this.mode)}else if(t<27)switch(this.mode){case l.MODE_NUMBER:return 12;case l.MODE_ALPHA_NUM:return 11;case l.MODE_8BIT_BYTE:return 16;case l.MODE_KANJI:return 10;default:throw Error("mode:"+this.mode)}else{if(!(t<41))throw Error("typeNumber:"+t);switch(this.mode){case l.MODE_NUMBER:return 14;case l.MODE_ALPHA_NUM:return 13;case l.MODE_8BIT_BYTE:return 16;case l.MODE_KANJI:return 12;default:throw Error("mode:"+this.mode)}}}}class p extends c{stringToBytes;constructor(t,e){super(l.MODE_8BIT_BYTE,t),this.stringToBytes=e}write(t){this.stringToBytes(this.getData()).forEach(e=>t.put(e,8))}getLength(){return this.stringToBytes(this.getData()).length}}class m extends c{constructor(t){super(l.MODE_ALPHA_NUM,t)}write(t){for(var e=this.getData(),r=0;r+1<e.length;)t.put(45*m.getCode(e.charAt(r))+m.getCode(e.charAt(r+1)),11),r+=2;r<e.length&&t.put(m.getCode(e.charAt(r)),6)}getLength(){return this.getData().length}static getCode(t){if("0"<=t&&t<="9")return t.charCodeAt(0)-48;if("A"<=t&&t<="Z")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 Error("illegal char :"+t)}}}class $ extends c{stringToBytes;constructor(t,e){super(l.MODE_KANJI,t),this.stringToBytes=e}write(t){for(var e=this.stringToBytes(this.getData()),r=0;r+1<e.length;){let i=(255&e[r])<<8|255&e[r+1];if(33088<=i&&i<=40956)i-=33088;else{if(!(57408<=i&&i<=60351))throw Error("illegal char at "+(r+1)+"/"+i);i-=49472}i=192*(i>>>8&255)+(255&i),t.put(i,13),r+=2}if(r<e.length)throw Error("illegal char at "+(r+1))}getLength(){return this.stringToBytes(this.getData()).length/2}}class v extends c{constructor(t){super(l.MODE_NUMBER,t)}write(t){for(var e=this.getData(),r=0;r+2<e.length;)t.put(v.strToNum(e.substring(r,r+3)),10),r+=3;r<e.length&&(e.length-r==1?t.put(v.strToNum(e.substring(r,r+1)),4):e.length-r==2&&t.put(v.strToNum(e.substring(r,r+2)),7))}getLength(){return this.getData().length}static strToNum(t){var e=0;for(let r=0;r<t.length;r+=1)e=10*e+v.chatToNum(t.charAt(r));return e}static chatToNum(t){if("0"<=t&&t<="9")return t.charCodeAt(0)-48;throw Error("illegal char :"+t)}}var w,f=w||={};f[f.PATTERN000=0]="PATTERN000",f[f.PATTERN001=1]="PATTERN001",f[f.PATTERN010=2]="PATTERN010",f[f.PATTERN011=3]="PATTERN011",f[f.PATTERN100=4]="PATTERN100",f[f.PATTERN101=5]="PATTERN101",f[f.PATTERN110=6]="PATTERN110",f[f.PATTERN111=7]="PATTERN111";class b{constructor(){throw Error("error")}static getPatternPosition(t){return b.PATTERN_POSITION_TABLE[t-1]}static PATTERN_POSITION_TABLE;static MAX_LENGTH;static getMaxLength(t,e,r){switch(r){case n.L:r=0;break;case n.M:r=1;break;case n.Q:r=2;break;case n.H:r=3;break;default:throw Error("e:"+r)}switch(e){case l.MODE_NUMBER:e=0;break;case l.MODE_ALPHA_NUM:e=1;break;case l.MODE_8BIT_BYTE:e=2;break;case l.MODE_KANJI:e=3;break;default:throw Error("m:"+e)}return b.MAX_LENGTH[t-1][r][e]}static getErrorCorrectPolynomial(t){var e=new d([1]);for(let r=0;r<t;r+=1)e=e.multiply(new d([1,u.gexp(r)]));return e}static getMaskFunc(t){switch(t){case w.PATTERN000:return(t,e)=>(t+e)%2==0;case w.PATTERN001:return t=>t%2==0;case w.PATTERN010:return(t,e)=>e%3==0;case w.PATTERN011:return(t,e)=>(t+e)%3==0;case w.PATTERN100:return(t,e)=>(~~(t/2)+~~(e/3))%2==0;case w.PATTERN101:return(t,e)=>t*e%2+t*e%3==0;case w.PATTERN110:return(t,e)=>(t*e%2+t*e%3)%2==0;case w.PATTERN111:return(t,e)=>(t*e%3+(t+e)%2)%2==0;default:throw Error("mask:"+t)}}static getLostPoint(t){for(var e=t.getModuleCount(),r=0,i=0;i<e;i+=1)for(var s=0;s<e;s+=1){var o=0;let a=t.isDark(i,s);for(let r=-1;r<=1;r+=1)if(!(i+r<0||e<=i+r))for(let n=-1;n<=1;n+=1)s+n<0||e<=s+n||(0!=r||0!=n)&&a==t.isDark(i+r,s+n)&&(o+=1);o>5&&(r+=3+o-5)}for(i=0;i<e-1;i+=1)for(s=0;s<e-1;s+=1)o=0,t.isDark(i,s)&&(o+=1),t.isDark(i+1,s)&&(o+=1),t.isDark(i,s+1)&&(o+=1),t.isDark(i+1,s+1)&&(o+=1),(0==o||4==o)&&(r+=3);for(i=0;i<e;i+=1)for(s=0;s<e-6;s+=1)t.isDark(i,s)&&!t.isDark(i,s+1)&&t.isDark(i,s+2)&&t.isDark(i,s+3)&&t.isDark(i,s+4)&&!t.isDark(i,s+5)&&t.isDark(i,s+6)&&(r+=40);for(i=0;i<e;i+=1)for(s=0;s<e-6;s+=1)t.isDark(s,i)&&!t.isDark(s+1,i)&&t.isDark(s+2,i)&&t.isDark(s+3,i)&&t.isDark(s+4,i)&&!t.isDark(s+5,i)&&t.isDark(s+6,i)&&(r+=40);for(i=0,s=0;s<e;s+=1)for(o=0;o<e;o+=1)t.isDark(o,s)&&(i+=1);return r+Math.abs(100*i/e/e-50)/5*10}static getBCHTypeInfo(t){for(var e=t<<10;b.getBCHDigit(e)-b.getBCHDigit(b.G15)>=0;)e^=b.G15<<b.getBCHDigit(e)-b.getBCHDigit(b.G15);return(t<<10|e)^b.G15_MASK}static getBCHTypeNumber(t){for(var e=t<<12;b.getBCHDigit(e)-b.getBCHDigit(b.G18)>=0;)e^=b.G18<<b.getBCHDigit(e)-b.getBCHDigit(b.G18);return t<<12|e}static G15;static G18;static G15_MASK;static getBCHDigit(t){for(var e=0;0!=t;)e+=1,t>>>=1;return e}}b.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]],b.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]]],b.G15=1335,b.G18=7973,b.G15_MASK=21522;class M{totalCount;dataCount;static RS_BLOCK_TABLE;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;var r=[];for(let i=0;i<e;i+=1){let e=t[3*i],s=t[3*i+1],o=t[3*i+2];for(let t=0;t<e;t+=1)r.push(new M(s,o))}return r}static getRsBlockTable(t,e){switch(e){case n.L:return M.RS_BLOCK_TABLE[4*(t-1)];case n.M:return M.RS_BLOCK_TABLE[4*(t-1)+1];case n.Q:return M.RS_BLOCK_TABLE[4*(t-1)+2];case n.H:return M.RS_BLOCK_TABLE[4*(t-1)+3]}throw Error("tn:"+t+"/ecl:"+e)}}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]];var y,A=Array(41).fill(0).map((t,e)=>e),E=y||={};E.L="L",E.M="M",E.Q="Q",E.H="H";var z,k=z||={};k.numeric="numeric",k.alphanumeric="alphanumeric",k.byte="byte",k.kanji="kanji",k.unicode="unicode";class D{static stringToBytesFuncs;static PAD0;static PAD1;typeNumber;errorCorrectLevel;qrDataList;modules=[];moduleCount=0;constructor(t=0,e=y.L){this.typeNumber=t,this.errorCorrectLevel=n[e],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=z.byte){if(t instanceof c)this.qrDataList.push(t);else{if("string"!=typeof t)throw Error(typeof t);switch(e){case z.numeric:this.qrDataList.push(new v(t));break;case z.alphanumeric:this.qrDataList.push(new m(t));break;case z.byte:this.qrDataList.push(new p(t,D.stringToBytesFuncs.default));break;case z.unicode:this.qrDataList.push(new p(t,D.stringToBytesFuncs.UTF8));break;case z.kanji:this.qrDataList.push(new $(t,D.stringToBytesFuncs.SJIS));break;default:throw Error("mode:"+e)}}}isDark(t,e){return null!=this.modules[t][e]&&this.modules[t][e]}getModuleCount(){return this.moduleCount}make(){if(this.typeNumber<1){let e=1;for(;e<40;e++){var t=M.getRSBlocks(e,this.errorCorrectLevel);let r=new a;if(this.qrDataList.forEach(t=>{r.put(t.getMode(),4),r.put(t.getLength(),t.getLengthInBits(e)),t.write(r)}),t=t.reduce((t,e)=>t+e.getDataCount(),0),r.getLengthInBits()<=8*t)break}this.typeNumber=e}this.makeImpl(!1,this.getBestMaskPattern())}getBestMaskPattern(){var t=0,e=0;for(let r=0;r<8;r+=1){this.makeImpl(!0,r);let i=b.getLostPoint(this);(0==r||t>i)&&(t=i,e=r)}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),this.typeNumber>=7&&this.setupTypeNumber(t),t=D.createData(this.typeNumber,this.errorCorrectLevel,this.qrDataList),this.mapData(t,e)}mapData(t,e){var r=-1,i=this.moduleCount-1,s=7,o=0;e=b.getMaskFunc(e);for(let a=this.moduleCount-1;a>0;a-=2)for(6==a&&--a;;){for(let r=0;r<2;r+=1)if(null==this.modules[i][a-r]){let n=!1;o<t.length&&(n=1==(t[o]>>>s&1)),e(i,a-r)&&(n=!n),this.modules[i][a-r]=n,-1==--s&&(o+=1,s=7)}if((i+=r)<0||this.moduleCount<=i){i-=r,r=-r;break}}}setupPositionAdjustPattern(){var t=b.getPatternPosition(this.typeNumber);t.forEach(e=>{t.forEach(t=>{if(null==this.modules[e][t])for(let r=-2;r<=2;r+=1)for(let i=-2;i<=2;i+=1)this.modules[e+r][t+i]=-2==r||2==r||-2==i||2==i||0==r&&0==i})})}setupPositionProbePattern(t,e){for(let r=-1;r<=7;r+=1)for(let i=-1;i<=7;i+=1)t+r<=-1||this.moduleCount<=t+r||e+i<=-1||this.moduleCount<=e+i||(this.modules[t+r][e+i]=0<=r&&r<=6&&(0==i||6==i)||0<=i&&i<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=i&&i<=4)}setupTimingPattern(){for(var t=8;t<this.moduleCount-8;t+=1)null==this.modules[t][6]&&(this.modules[t][6]=t%2==0);for(t=8;t<this.moduleCount-8;t+=1)null==this.modules[6][t]&&(this.modules[6][t]=t%2==0)}setupTypeNumber(t){for(var e=b.getBCHTypeNumber(this.typeNumber),r=0;r<18;r+=1)this.modules[~~(r/3)][r%3+this.moduleCount-8-3]=!t&&1==(e>>r&1);for(r=0;r<18;r+=1)this.modules[r%3+this.moduleCount-8-3][~~(r/3)]=!t&&1==(e>>r&1)}setupTypeInfo(t,e){e=b.getBCHTypeInfo(this.errorCorrectLevel<<3|e);for(var r=0;r<15;r+=1){var i=!t&&1==(e>>r&1);r<6?this.modules[r][8]=i:r<8?this.modules[r+1][8]=i:this.modules[this.moduleCount-15+r][8]=i}for(r=0;r<15;r+=1)i=!t&&1==(e>>r&1),r<8?this.modules[8][this.moduleCount-r-1]=i:r<9?this.modules[8][15-r-1+1]=i:this.modules[8][15-r-1]=i;this.modules[this.moduleCount-8][8]=!t}static createData(t,e,r){e=M.getRSBlocks(t,e);var i=new a;if(r.forEach(e=>{i.put(e.getMode(),4),i.put(e.getLength(),e.getLengthInBits(t)),e.write(i)}),r=e.reduce((t,e)=>t+e.getDataCount(),0),i.getLengthInBits()>8*r)throw Error("code length overflow. ("+i.getLengthInBits()+">"+8*r+")");for(i.getLengthInBits()+4<=8*r&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=8*r)&&(i.put(D.PAD0,8),!(i.getLengthInBits()>=8*r));)i.put(D.PAD1,8);return D.createBytes(i,e)}static createBytes(t,e){function r(t){var e=[];for(let r=0;r<t;r+=1)e.push(0);return e}for(var i=0,s=0,o=0,a=Array(e.length).map(()=>[]),n=Array(e.length).map(()=>[]),h=0;h<e.length;h+=1){var u=e[h].getDataCount(),l=e[h].getTotalCount()-u;s=Math.max(s,u),o=Math.max(o,l),a[h]=r(u);for(var g=0;g<a[h].length;g+=1)a[h][g]=255&t.getBuffer()[g+i];for(i+=u,l=b.getErrorCorrectPolynomial(l),u=new d(a[h],l.getLength()-1).mod(l),n[h]=r(l.getLength()-1),l=0;l<n[h].length;l+=1)g=l+u.getLength()-n[h].length,n[h][l]=g>=0?u.getAt(g):0}for(t=r(t=e.reduce((t,e)=>t+e.getTotalCount(),0)),i=0,h=0;h<s;h+=1)for(u=0;u<e.length;u+=1)h<a[u].length&&(t[i]=a[u][h],i+=1);for(s=0;s<o;s+=1)for(a=0;a<e.length;a+=1)s<n[a].length&&(t[i]=n[a][s],i+=1);return t}}D.stringToBytesFuncs={default(t){var e=[];for(let r=0;r<t.length;r+=1){let i=t.charCodeAt(r);e.push(255&i)}return e}},D.PAD0=236,D.PAD1=17;var x=t=>!!t&&"object"==typeof t&&!Array.isArray(t);function T(t,...e){if(!e.length)return t;var r=e.shift();return void 0!==r&&x(t)&&x(r)?(t={...t},Object.keys(r).forEach(e=>{var i=t[e],s=r[e];Array.isArray(i)&&Array.isArray(s)?t[e]=s:x(i)&&x(s)?t[e]=T({...i},s):t[e]=s}),T(t,...e)):t}var O,P=O||={};P.dot="dot",P.randomDot="random-dot",P.rounded="rounded",P.extraRounded="extra-rounded",P.verticalLine="vertical-line",P.horizontalLine="horizontal-line",P.classy="classy",P.classyRounded="classy-rounded",P.square="square",P.smallSquare="small-square",P.tinySquare="tiny-square",P.diamond="diamond",P.wave="wave",P.heart="heart",P.star="star",P.weave="weave",P.pentagon="pentagon",P.hexagon="hexagon",P.octagon="octagon",P.circuit="circuit",P.zebraHorizontal="zebra-horizontal",P.zebraVertical="zebra-vertical",P.blocksHorizontal="blocks-horizontal",P.blocksVertical="blocks-vertical",P.blobs="blobs",P.soft="soft";var C,N=C||={};N.dot="dot",N.square="square",N.heart="heart",N.extraRounded="extra-rounded",N.classy="classy",N.inpoint="inpoint",N.outpoint="outpoint",N.star="star",N.pentagon="pentagon",N.hexagon="hexagon",N.octagon="octagon",N.diamond="diamond";var L,_=L||={};_.dot="dot",_.square="square",_.extraRounded="extra-rounded",_.classy="classy",_.inpoint="inpoint",_.outpoint="outpoint",_.centerCircle="center-circle";var S,q=S||={};q.square="square",q.circle="circle";var B,R=B||={};R.center="center",R.overlay="overlay",R.background="background";var I={document:void 0,shape:S.square,width:void 0,height:void 0,size:void 0,data:"",qrOptions:{typeNumber:A[0],mode:void 0,errorCorrectionLevel:y.Q},imageOptions:{mode:B.center,imageSize:.4,crossOrigin:void 0,margin:0,fill:{color:"rgba(255,255,255,1)"}},dotsOptions:{type:O.square,color:"#000",size:10}};function H(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==B.overlay&&(t.imageOptions.margin=0),t.imageOptions.fill.gradient&&(t.imageOptions.fill.gradient=s(t.imageOptions.fill.gradient)),t.dotsOptions={...t.dotsOptions},t.dotsOptions.gradient&&(t.dotsOptions.gradient=s(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=s(t.cornersSquareOptions.gradient))),t.cornersDotOptions&&(t.cornersDotOptions={...t.cornersDotOptions},t.cornersDotOptions.gradient&&(t.cornersDotOptions.gradient=s(t.cornersDotOptions.gradient))),t.backgroundOptions&&(t.backgroundOptions={...t.backgroundOptions},t.backgroundOptions.gradient&&(t.backgroundOptions.gradient=s(t.backgroundOptions.gradient))),t.document||(t.document=document),t}var U={[y.L]:.07,[y.M]:.15,[y.Q]:.25,[y.H]:.3};var V={dot:t=>{var{size:r,x:i,y:s,document:o}=t;return(t=o.createElementNS("http://www.w3.org/2000/svg","circle")).setAttribute("cx",e(i+r/2)),t.setAttribute("cy",e(s+r/2)),t.setAttribute("r",e(r/2)),t},square:(t,{width:r=t.size,height:i=t.size}={})=>{var{x:s,y:o,size:a,document:n}=t;return(t=n.createElementNS("http://www.w3.org/2000/svg","rect")).setAttribute("x",e(s+(a-r)/2)),t.setAttribute("y",e(o+(a-i)/2)),t.setAttribute("width",e(r)),t.setAttribute("height",e(i)),t},sideRounded:(e,{height:r=e.size}={})=>{var{size:i,x:s,y:o,document:a}=e;return(e=a.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",t`M ${s} ${o+(i-r)/2} v ${r} h ${i/2} a ${r/2} ${r/2} 0 0 0 0 ${-r} z`),e},cornerRounded:e=>{var{size:r,x:i,y:s,document:o}=e;return(e=o.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",t`M ${i} ${s} v ${r} h ${r} v ${-r/2} a ${r/2} ${r/2} 0 0 0 ${-r/2} ${-r/2} z`),e},cornerExtraRounded:e=>{var{size:r,x:i,y:s,document:o}=e;return(e=o.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",t`M ${i} ${s} v ${r} h ${r} a ${r} ${r} 0 0 0 ${-r} ${-r} z`),e},classyDot:e=>{var{size:r,x:i,y:s,document:o}=e;return(e=o.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",t`M ${i} ${s} v ${r/2} a ${r/2} ${r/2} 0 0 0 ${r/2} ${r/2} h ${r/2} v ${-r/2} a ${r/2} ${r/2} 0 0 0 ${-r/2} ${-r/2} z`),e},wave:e=>{var{size:r,x:i,y:s,document:o}=e,a=5*Math.PI/180,n=65*Math.PI/180;e=r*(1-.65*Math.sin(a)),a=-r*(.95-.65*Math.cos(a));var h=-r*Math.sin(n)/2;n=r*Math.cos(n)/2;var u=o.createElementNS("http://www.w3.org/2000/svg","path");return u.setAttribute("d",t`M ${i} ${s+r} c ${.65*r} 0 ${e} ${a} ${r} ${.95*-r} c ${h} ${n} ${-r/2} ${r*(.95-1)} ${-r} ${r*(.95-1)} z`),u},heart:t=>{var{size:e,x:i,y:s,document:o}=t;return(t=o.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",r(["M",1,.31629,"c",-86e-5,.15702,-.10534,.26323,-.21876,.38123,"c",-.06736,.06834,-.18938,.17948,-.28124,.26126,"c",-.09188,-.08178,-.2139,-.19292,-.28124,-.26126,"c",-.11344,-.118,-.2179,-.22422,-.21876,-.38123,"c",-96e-5,-.27136,.33154,-.36842,.5,-.17,"c",.16844,-.19842,.50094,-.10136,.5,.17,"z"],{x:i,y:s,size:e})),t},rounded:t=>{var{size:r,x:i,y:s,document:o}=t;return(t=o.createElementNS("http://www.w3.org/2000/svg","rect")).setAttribute("x",e(i)),t.setAttribute("y",e(s)),t.setAttribute("width",e(r)),t.setAttribute("height",e(r)),t.setAttribute("rx",e(r/4)),t.setAttribute("ry",e(r/4)),t},classy:e=>{var{size:r,x:i,y:s,document:o}=e;e=r/7;var a=o.createElementNS("http://www.w3.org/2000/svg","path");return a.setAttribute("d",t`M ${i} ${s+2.5*e} v ${2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${2.5*e} h ${4.5*e} v ${-4.5*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*-e} h ${-2*e} H ${i} z`),a},inpoint:e=>{var{size:r,x:i,y:s,document:o}=e;return(e=o.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",t`M ${i} ${s+r/2} v ${r/4} a ${r/4} ${r/4} 0 0 0 ${r/4} ${r/4} h ${r/4*3} v ${-r/4*3} a ${r/4} ${r/4} 0 0 0 ${-r/4} ${-r/4} h ${-r/2} a ${r/4} ${r/4} 0 0 0 ${-r/4} ${r/4} z`),e},star:(e,{spikes:r=5,outerRadius:i=e.size/2,innerRadius:s=e.size/4}={})=>{var{size:o,x:a,y:n,document:h}=e,u=a+o/2,d=n+o/2,l=Math.PI/r;return(e=h.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",Array(2*r).fill(0).map((e,r)=>t`${0===r?"M":"L"} ${u+(e=r%2==0?i:s)*Math.sin(r*l)} ${d-e*Math.cos(r*l)}`).join(" ")),e},weave:e=>{var{size:r,x:i,y:s,document:o}=e,a=(r-(e=.6*r))/2,n=o.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d",t`M ${i+a} ${s} l ${e} 0 l 0 ${a} l ${a} 0 l 0 ${e} l ${-a} 0 l 0 ${a} l ${-e} 0 l 0 ${-a} l ${-a} 0 l 0 ${-e} l ${a} 0 z`),n},blob:(e,r)=>{var{size:i,x:s,y:o,document:a}=e;e=i/7;var n=a.createElementNS("http://www.w3.org/2000/svg","path"),h=[t`M ${s} ${o+2.5*e}`],u=2*e;return"round"==r.bl?(h.push(t`v ${u} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${2.5*e}`),u=2*e):"out"==r.bl?(h.push(t`v ${5*e+u} a ${2.5*e} ${2.5*e} 0 0 1 ${2.5*e} ${-2.5*e}`),u=2*e):(h.push(t`v ${2.5*e+u}`),u=4.5*e),"round"==r.br?(h.push(t`h ${u} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${-2.5*e}`),u=-2*e):"out"==r.br?(h.push(t`h ${5*e+u} a ${2.5*e} ${2.5*e} 0 0 1 ${-2.5*e} ${-2.5*e}`),u=-2*e):(h.push(t`h ${2.5*e+u}`),u=-4.5*e),"round"==r.tr?(h.push(t`v ${u} a ${2.5*e} ${2.5*e} 0 0 0 ${-2.5*e} ${-2.5*e}`),u=-2*e):"out"==r.tr?(h.push(t`v ${-5*e+u} a ${2.5*e} ${2.5*e} 0 0 1 ${-2.5*e} ${2.5*e}`),u=-2*e):(h.push(t`v ${-2.5*e+u}`),u=-4.5*e),"round"==r.tl?h.push(t`h ${u} a ${2.5*e} ${2.5*e} 0 0 0 ${-2.5*e} ${2.5*e}`):"out"==r.tl?h.push(t`h ${-5*e+u} a ${2.5*e} ${2.5*e} 0 0 1 ${2.5*e} ${2.5*e}`):h.push(t`h ${-2.5*e+u}`),n.setAttribute("d",h.join(" ")+" z"),n},circuit:(e,r=!1)=>{var{size:i,x:s,y:o,document:a}=e;e=.17**.5*i;var n=a.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d",t`M ${s+.4*i} ${o+.5*i-e} a ${.4*i} ${.4*i} 0 0 0 ${r?.1*i-e:-.3*i} ${r?e-.1*i:e} ${r?t`h ${-.3*i} v ${.2*i} h ${.3*i} a ${.4*i} ${.4*i} 0 0 0 ${e} ${.3*i}`:t`a ${.4*i} ${.4*i} 0 0 0 ${.4*i} ${.4*i}`} a ${.4*i} ${.4*i} 0 0 0 ${.4*i} ${-.4*i} a ${.4*i} ${.4*i} 0 0 0 ${-.3*i} ${-e} v ${-.3*i} h ${-.2*i} z`),n.setAttribute("fill-rule","nonzero"),n}},F={[C.dot]:t=>i({...t,draw:V.dot}),[C.square]:t=>i({...t,draw:V.square}),[C.heart]:t=>V.heart(t),[C.extraRounded]:t=>i({...t,draw:V.rounded}),[C.classy]:t=>i({...t,draw:V.classy}),[C.inpoint]:t=>i({...t,draw:V.inpoint}),[C.outpoint]:t=>i({...t,rotation:(t.rotation||0)+Math.PI,draw:V.inpoint}),[C.star]:t=>V.star(t),[C.pentagon]:t=>V.star(t,{spikes:2.5,outerRadius:t.size/2,innerRadius:t.size/2}),[C.hexagon]:t=>V.star(t,{spikes:3,outerRadius:t.size/2,innerRadius:t.size/2}),[C.octagon]:t=>V.star(t,{spikes:4,outerRadius:t.size*Math.cos(Math.PI/8)/2,innerRadius:t.size*Math.cos(Math.PI/8)/2}),[C.diamond]:t=>i({...t,rotation:Math.PI/4,draw:t=>V.square(t,{width:.85*t.size,height:.85*t.size})})};var X={dot:e=>{var{size:r,x:i,y:s,document:o}=e;e=r/7;var a=o.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("clip-rule","evenodd"),a.setAttribute("d",t`M ${i+r/2} ${s} a ${r/2} ${r/2} 0 1 0 0.1 0 z m 0 ${e} a ${r/2-e} ${r/2-e} 0 1 1 -0.1 0 Z`);var n=o.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("clip-rule","evenodd"),n.setAttribute("d",t`M ${i+r/2} ${s-e} a ${r/2+e} ${r/2+e} 0 1 0 0.1 0 z`),[a,n]},square:e=>{var{size:r,x:i,y:s,document:o}=e;e=r/7;var a=o.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("clip-rule","evenodd"),a.setAttribute("d",t`M ${i} ${s} v ${r} h ${r} v ${-r} z M ${i+e} ${s+e} h ${r-2*e} v ${r-2*e} h ${2*e-r} z`);var n=o.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("clip-rule","evenodd"),n.setAttribute("d",t`M ${i-e} ${s-e} h ${r+2*e} v ${r+2*e} h ${-r-2*e} z`),[a,n]},extraRounded:e=>{var{size:r,x:i,y:s,document:o}=e;e=r/7;var a=o.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("clip-rule","evenodd"),a.setAttribute("d",t`M ${i} ${s+2.5*e} v ${2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${2.5*e} h ${2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${2.5*-e} v ${-2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*-e} h ${-2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*e} z M ${i+2.5*e} ${s+e} h ${2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*e} ${1.5*e} v ${2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*-e} ${1.5*e} h ${-2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*-e} ${1.5*-e} v ${-2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*e} ${1.5*-e} z`);var n=o.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("clip-rule","evenodd"),n.setAttribute("d",t`M ${i-e} ${s+2.5*e} v ${2*e} a ${3.5*e} ${3.5*e} 0 0 0 ${3.5*e} ${3.5*e} h ${2*e} a ${3.5*e} ${3.5*e} 0 0 0 ${3.5*e} ${3.5*-e} v ${-2*e} a ${3.5*e} ${3.5*e} 0 0 0 ${3.5*-e} ${3.5*-e} h ${-2*e} a ${3.5*e} ${3.5*e} 0 0 0 ${3.5*-e} ${3.5*e} z`),[a,n]},classy:e=>{var{size:r,x:i,y:s,document:o}=e;e=r/7;var a=o.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("clip-rule","evenodd"),a.setAttribute("d",t`M ${i} ${s+2.5*e} v ${2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${2.5*e} h ${4.5*e} v ${-4.5*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*-e} h ${-2*e} H ${i} z M ${i+2.5*e} ${s+e} h ${2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*e} ${1.5*e} v ${3.5*e} h ${-3.5*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*-e} ${1.5*-e} v ${-3.5*e} z`);var n=o.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("clip-rule","evenodd"),n.setAttribute("d",t`M ${i+.5*e} ${s-e} h ${4*e} a ${3.5*e} ${3.5*e} 0 0 1 ${3.5*e} ${3.5*e} v ${5.5*e} h ${-5.5*e} a ${3.5*e} ${3.5*e} 0 0 1 ${3.5*-e} ${3.5*-e} v ${-5.5*e} z`),[a,n]},inpoint:e=>{var{size:r,x:i,y:s,document:o}=e;e=r/7;var a=o.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("clip-rule","evenodd"),a.setAttribute("d",t`M ${i} ${s+2.5*e} v ${2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${2.5*e} h ${4.5*e} v ${-4.5*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*-e} h ${-2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*e} z M ${i+2.5*e} ${s+e} h ${2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*e} ${1.5*e} v ${3.5*e} h ${-3.5*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*-e} ${1.5*-e} v ${-2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*e} ${1.5*-e} z`);var n=o.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("clip-rule","evenodd"),n.setAttribute("d",t`M ${i+.5*e} ${s-e} h ${4*e} a ${3.5*e} ${3.5*e} 0 0 1 ${3.5*e} ${3.5*e} v ${5.5*e} h ${-5.5*e} a ${3.5*e} ${3.5*e} 0 0 1 ${3.5*-e} ${3.5*-e} v ${-2*e} a ${3.5*e} ${3.5*e} 0 0 1 ${3.5*e} ${3.5*-e} z`),[a,n]},centerCircle:e=>{var{x:r,y:i,size:s,document:o}=e,a=s/2.5,n=r+s/2,h=i+s/2;e=s/7;var u=o.createElementNS("http://www.w3.org/2000/svg","path");return u.setAttribute("clip-rule","evenodd"),u.setAttribute("d",t`M ${r} ${i} h ${s} v ${s} h ${-s} z M ${n-a} ${h} a ${a} ${a} 0 1 0 ${2*a} 0 a ${a} ${a} 0 1 0 ${2*-a} 0 z`),(a=o.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("clip-rule","evenodd"),a.setAttribute("d",t`M ${r-e} ${i-e} h ${s+2*e} v ${s+2*e} h ${-s-2*e} z`),[u,a]}},j={[L.dot]:t=>X.dot(t),[L.square]:t=>X.square(t),[L.extraRounded]:t=>X.extraRounded(t),[L.classy]:t=>i({...t,draw:X.classy}),[L.inpoint]:t=>i({...t,draw:X.inpoint}),[L.outpoint]:({rotation:t,...e})=>i({...e,rotation:(t||0)+Math.PI,draw:X.inpoint}),[L.centerCircle]:t=>X.centerCircle(t)};function K({x:t,y:e,size:r,document:s,getNeighbor:o},{corner:a=V.cornerRounded,end:n=V.sideRounded}={}){var h=o?+o(-1,0):0,u=o?+o(1,0):0,d=o?+o(0,-1):0,l=h+u+d+(o=o?+o(0,1):0);return 0===l?V.dot({x:t,y:e,size:r,document:s}):l>2||h&&u||d&&o?V.square({x:t,y:e,size:r,document:s}):2===l?(n=0,h&&d?n=Math.PI/2:d&&u?n=Math.PI:u&&o&&(n=-Math.PI/2),i({x:t,y:e,size:r,rotation:n,document:s,draw:a})):(a=0,d?a=Math.PI/2:u?a=Math.PI:o&&(a=-Math.PI/2),i({x:t,y:e,size:r,rotation:a,document:s,draw:n}))}function Q({x:t,y:e,size:r,document:s,getNeighbor:o},{corner:a=V.cornerRounded}={}){var n=o?+o(-1,0):0,h=o?+o(1,0):0,u=o?+o(0,-1):0;return n+h+u+(o=o?+o(0,1):0)===0?i({x:t,y:e,size:r,rotation:Math.PI/2,document:s,draw:V.classyDot}):n||u?h||o?V.square({x:t,y:e,size:r,document:s}):i({x:t,y:e,size:r,rotation:Math.PI/2,document:s,draw:a}):i({x:t,y:e,size:r,rotation:-Math.PI/2,document:s,draw:a})}function Y({x:t,y:e,size:r,document:s,getNeighbor:o},{stripe:a=r,rotation:n=0,endpoint:h=V.sideRounded,dot:u=V.dot}={}){var d=o?+o(0,-1):0;return o=o?+o(0,1):0,d&&o?i({x:t,y:e,size:r,rotation:n,document:s,draw:()=>V.square({x:t,y:e,size:r,document:s},{width:a})}):d&&!o?(n+=Math.PI/2,i({x:t,y:e,size:r,rotation:n,document:s,draw:t=>h(t,{height:a})})):o&&!d?(n-=Math.PI/2,i({x:t,y:e,size:r,rotation:n,document:s,draw:t=>h(t,{height:a})})):i({x:t,y:e,size:r,rotation:n,document:s,draw:()=>u({x:t+(r-a)/2,y:e+(r-a)/2,size:a,document:s})})}var J={[O.dot]:t=>V.dot(t),[O.randomDot]:({size:t,x:e,y:r,getPRandom:i,...s})=>{var o=.25*(i=i||Math.random)()+.75;return V.dot({...s,size:t*o,x:e+t*i()*(1-o),y:r+t*i()*(1-o)})},[O.rounded]:t=>K(t),[O.extraRounded]:t=>K(t,{corner:V.cornerExtraRounded}),[O.verticalLine]:t=>Y(t),[O.horizontalLine]:({getNeighbor:t,...e})=>Y({...e,getNeighbor:t?(e,r)=>t(r,e):void 0},{rotation:-Math.PI/2}),[O.classy]:t=>Q(t),[O.classyRounded]:t=>Q(t,{corner:V.cornerExtraRounded}),[O.square]:t=>V.square(t),[O.smallSquare]:({x:t,y:e,size:r,document:i})=>V.square({x:t+=.15*r,y:e+=.15*r,size:r=.7*r,document:i}),[O.tinySquare]:({x:t,y:e,size:r,document:i})=>V.square({x:t+=.35*r,y:e+=.35*r,size:r=.3*r,document:i}),[O.diamond]:t=>i({...t,rotation:Math.PI/4,draw:t=>V.square(t,{width:.85*t.size,height:.85*t.size})}),[O.wave]:t=>K(t,{corner:V.cornerExtraRounded,end:V.wave}),[O.heart]:t=>V.heart(t),[O.star]:t=>V.star(t),[O.weave]:t=>V.weave(t),[O.pentagon]:t=>V.star(t,{spikes:2.5,outerRadius:t.size/2,innerRadius:t.size/2}),[O.hexagon]:t=>V.star(t,{spikes:3,outerRadius:t.size/2,innerRadius:t.size/2}),[O.octagon]:t=>V.star(t,{spikes:4,outerRadius:t.size*Math.cos(Math.PI/8)/2,innerRadius:t.size*Math.cos(Math.PI/8)/2}),[O.circuit]:({getNeighbor:t,...e})=>{var r=e.getPRandom||Math.random,s=t&&r()<2/3?+t(-1,0):0;return t=t&&r()<2/3?+t(0,-1):0,r=.8*e.size,t&&s?V.circuit(e,!0):t?V.circuit(e):s?i({...e,rotation:-Math.PI/2,draw:V.circuit}):V.dot({...e,x:e.x+.1*e.size,y:e.y+.1*e.size,size:r})},[O.zebraVertical]:t=>Y(t,{stripe:.8*t.size}),[O.zebraHorizontal]:({getNeighbor:t,...e})=>Y({...e,getNeighbor:t?(e,r)=>t(r,e):void 0},{stripe:.8*e.size,rotation:-Math.PI/2}),[O.blocksVertical]:t=>Y(t,{stripe:.8*t.size,endpoint:(e,r)=>{var i=t.size*(1-.25*(t.getPRandom||Math.random)());return V.square({...e,x:t.x-(t.size-i)/2},{...r,width:i})},dot:e=>{var r=t.getPRandom||Math.random,i=t.size*(1-.25*r());return r=t.y+(t.size-i)*r(),V.square({...e,y:r},{height:i})}}),[O.blocksHorizontal]:({getNeighbor:t,...e})=>Y({...e,getNeighbor:t?(e,r)=>t(r,e):void 0},{stripe:.8*e.size,rotation:-Math.PI/2,endpoint:(t,r)=>{var i=e.size*(1-.25*(e.getPRandom||Math.random)());return V.square({...t,x:e.x-(e.size-i)/2},{...r,width:i})},dot:t=>{var r=e.getPRandom||Math.random,i=e.size*(1-.25*r());return r=e.y+(e.size-i)*r(),V.square({...t,y:r},{height:i})}}),[O.blobs]:({getNeighbor:t,...e})=>{var r=t?.(-1,-1),i=t?.(0,-1),s=t?.(1,-1),o=t?.(1,0),a=t?.(1,1),n=t?.(0,1),h=t?.(-1,1);t=t?.(-1,0);var u={tl:"square",tr:"square",bl:"square",br:"square"};return!t&&r&&(u.tl="out"),!i&&s&&(u.tr="out"),!o&&a&&(u.br="out"),!n&&h&&(u.bl="out"),t||r||i||(u.tl="round"),i||s||o||(u.tr="round"),o||a||n||(u.br="round"),n||h||t||(u.bl="round"),V.blob(e,u)},[O.soft]:({getNeighbor:t,...e})=>{var r=t?.(-1,-1),i=t?.(0,-1),s=t?.(1,-1),o=t?.(1,0),a=t?.(1,1),n=t?.(0,1),h=t?.(-1,1);t=t?.(-1,0);var u={tl:"square",tr:"square",bl:"square",br:"square"};return!t&&r&&i&&(u.tl="out"),!i&&s&&o&&(u.tr="out"),!o&&a&&n&&(u.br="out"),!n&&h&&t&&(u.bl="out"),t||i||(u.tl="round"),i||o||(u.tr="round"),o||n||(u.br="round"),n||t||(u.bl="round"),V.blob(e,u)}};function W(t,e){var r=J[t]||J[O.square];if(!e?.length)return r;var i=function(t){return e=>{for(let r of t){let t=r.drawDot?.(e);if(t)return t}}}(e);return t=>i(t)||r(t)}var Z={toDataURL:t=>"string"==typeof t&&t.startsWith("data:")?Promise.resolve(t):new Promise((e,r)=>{if("string"==typeof t){let i=new XMLHttpRequest;i.onload=()=>{var t=new FileReader;t.onloadend=()=>{e(t.result)},t.readAsDataURL(i.response)},i.onerror=i.onabort=i.ontimeout=r,i.open("GET",t,!0),i.responseType="blob",i.send()}else{let r=new FileReader;r.onloadend=()=>{e(r.result)},r.readAsDataURL(t)}}),getSize:(t,e)=>new Promise((r,i)=>{var s=new Image;"string"===e&&(s.crossOrigin=e),s.onload=()=>{r({width:s.width,height:s.height})},s.onerror=s.onabort=i,"string"==typeof t?s.src=t:Z.toDataURL(t).then(t=>s.src=t).catch(i)})};function tt(t,e,r,i=!0){var s;return()=>{if(null==s){var o=s=0;for(let a=-3;a<4;a++)for(let n=-3;n<4;n++)o++,s|=Number(t[(e+a+t.length<<n)%t.length]?.[(r+n+t.length<<a)%t.length]===i)<<o}return o=s+=1831565813,o=Math.imul(o^o>>>15,1|o),(((o^=o+Math.imul(o^o>>>7,61|o))^o>>>14)>>>0)/4294967296}}var et=[[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]],rt=new Set(Object.values(L));var it=[[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]],st=new Set(Object.values(C));class ot{options;_element;_fakeMatrix;_dotsColor;_backgroundColor;get element(){return this._element}get dotsColor(){return this._dotsColor}get backgroundColor(){return this._backgroundColor}defs;backgroundMask;dotsMask;lightDotsMask;qr;document;imageTools;constructor(t){this.options=t,this.document=t.document,this._element=this.document.createElementNS("http://www.w3.org/2000/svg","svg");var r=e(t.size);this._element.setAttribute("width",r),this._element.setAttribute("height",r),this._element.setAttribute("viewBox",`0 0 ${r} ${r}`),this.defs=this.document.createElementNS("http://www.w3.org/2000/svg","defs"),this._element.appendChild(this.defs),this.imageTools=t.imageTools||Z}get width(){return this.options.size}get height(){return this.options.size}async drawQR(t){var e=t.getModuleCount(),r=parseInt(((e-17)/4).toFixed(0),10),i=this.options.dotsOptions.size,s={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:o,errorCorrectionPercent:a}=this.options;if(o.mode==B.background){r=(this.options.size-2*(this.options.backgroundOptions&&this.options.backgroundOptions.margin||0)*i)*o.imageSize;let{width:e,height:a}=t;a=a/e*r,e=r,a>r&&(e=e/a*r,a=r),s={hideXDots:0,hideYDots:0,width:e,height:a}}else{let n=o.imageSize*a;r=b.getPatternPosition(r),s=function({originalHeight:t,originalWidth:e,maxHiddenDots:r,maxHiddenAxisDots:i,dotSize:s,margin:o}){if(t<=0||e<=0||r<=0||s<=0||4*o**2>r)return{height:0,width:0,hideYDots:0,hideXDots:0};i&&i%2==0&&(i=Math.max(1,i-1));var a=Math.max(e,t),n=Math.min(e,t),h=0;i=(i||r)-2*o;do{let t=h+(i-h)/2,e=Math.max(1,Math.ceil(t+2*o));e%2==0&&e++;let s=Math.max(1,Math.ceil(t*n/a+2*o));s%2==0&&s++,e*s>r?i=t:h=t}while(Math.abs(h-i)>.001);return(r=Math.max(1,Math.ceil(h+2*o)))%2==0&&r++,(n=Math.max(1,Math.ceil(h*n/a+2*o)))%2==0&&n++,e>t?a=r:(a=n,n=r),r=i=(a-2*o)*s,(i=i*t/e)>(h=(n-2*o)*s)&&(i=h,r=h*e/t),{height:Math.round(i+2*o*s),width:Math.round(r+2*o*s),hideYDots:n,hideXDots:a}}({originalWidth:t.width,originalHeight:t.height,maxHiddenDots:Math.floor(n*(e*e-192-2*(e-16)-r.length**2*25)),maxHiddenAxisDots:e-14,dotSize:i,margin:o.margin})}}this.drawBackground(),this.options.imageOptions.mode!=B.overlay&&this.options.image&&s.width>0&&s.height>0&&await this.drawImage({width:s.width,height:s.height,count:e,dotSize:i}),this.drawDots((t,r)=>!(this.options.imageOptions.mode==B.center&&t>=(e-s.hideXDots)/2&&t<(e+s.hideXDots)/2&&r>=(e-s.hideYDots)/2&&r<(e+s.hideYDots)/2||t<8&&r<8||t>=e-8&&r<8||r>=e-8&&t<8)),this.options.imageOptions.mode==B.overlay&&this.options.image&&s.width>0&&s.height>0&&await this.drawImage({width:s.width,height:s.height,count:e,dotSize:i}),this.drawCorners()}drawBackground(){var t=this.options;if(this._element&&t.backgroundOptions){this._backgroundColor=this.createColor({options:t.backgroundOptions.gradient,color:t.backgroundOptions.color,additionalRotation:0,x:0,y:0,height:t.size,width:t.size,name:"background-color"});let r=this.document.createElementNS("http://www.w3.org/2000/svg","rect");this.backgroundMask=this.createMask("mask-background-color"),this.defs.appendChild(this.backgroundMask),r.setAttribute("x",e(0)),r.setAttribute("y",e(0)),r.setAttribute("width",e(t.size)),r.setAttribute("height",e(t.size)),r.setAttribute("rx",e(t.size/2*(t.backgroundOptions.round||0))),this.backgroundMask.appendChild(r)}}drawDots(t){if(!this.qr)throw Error("QR code is not defined");var e=this.options,r=this.qr.getModuleCount();if(r>e.size)throw Error("The canvas is too small");var i=this.options.dotsOptions.size,s=e.size;e.imageOptions.mode==B.background&&(s-=2*i*(e.imageOptions.margin||0));var o=Math.floor((e.size-r*i)/2),a=W(e.dotsOptions.type,e.plugins),n=a;this.dotsMask=this.createMask("mask-dot-color"),this.defs.appendChild(this.dotsMask),e.imageOptions.mode==B.background&&(this.lightDotsMask=this.createMask("mask-light-dot-color"),this.defs.appendChild(this.lightDotsMask));var h=0,u=0;h=r,e.shape===S.circle?(h=this.options.backgroundOptions&&this.options.backgroundOptions.margin||0,h=r+2*(u=Math.floor((s/i-r-2*h)/2))):e.imageOptions.mode==B.background&&(h=r+2*(u=1)),s=o-u*i,o=r+2*u,this._fakeMatrix=Array(h);var d=Math.floor(h/2),l=tt(this._fakeMatrix,0,0,!1);for(let i=0;i<h;i++){this._fakeMatrix[i]=Array(h);for(let s=0;s<h;s++)if(i>u-1&&i<h-u&&s>u-1&&s<h-u){let e=i-u,r=s-u;t&&!t(e,r)?this._fakeMatrix[i][s]=void 0:this._fakeMatrix[i][s]=!!this.qr.isDark(r,e)}else this._fakeMatrix[i][s]=e.shape===S.circle&&Math.sqrt((i-d)*(i-d)+(s-d)*(s-d))>d?void 0:i==u-1||i==h-u||s==u-1||s==h-u?(s==u-1&&(i<u+8||i>h-u-9)||s==h-u&&i<u+8||i==u-1&&(s<u+8||s>h-u-9)||i==h-u&&s<u+8)&&void 0:this.qr.isDark(Math.floor(l()*r),Math.floor(l()*r))}t=b.getPatternPosition((r-17)/4);var g=Array(h);for(let e=0;e<h;e++){g[e]=Array(h),r=t.find(t=>e-u>t-3&&e-u<t+3);for(let i=0;i<h;i++)d=t.find(t=>i-u>t-3&&i-u<t+3),g[e][i]=void 0,null!=this._fakeMatrix[e][i]&&this.lightDotsMask&&r&&d&&(r!=t[0]&&d!=t[0]||d!=t[0]&&d!=t[t.length-1]||r!=t[0]&&r!=t[t.length-1])&&(g[e][i]=this._fakeMatrix[e][i])}for(let t=0;t<h;t++)for(let r=0;r<h;r++){if(null==this._fakeMatrix[t][r])continue;this.lightDotsMask&&(a=null!=g[t][r]?n:W(O.tinySquare));let o=e.imageOptions.mode==B.background&&null!=g[t][r];this._fakeMatrix[t][r]?this.dotsMask&&this.dotsMask.appendChild(a({x:s+t*i,y:s+r*i,size:i,document:this.options.document,getNeighbor:(e,i)=>(e=t+e,i=r+i,o?!0===g[e]?.[i]:!0===this._fakeMatrix[e]?.[i]),getPRandom:tt(this._fakeMatrix,t,r)})):this.lightDotsMask&&this.lightDotsMask&&this.lightDotsMask.appendChild(a({x:s+t*i,y:s+r*i,size:i,document:this.options.document,getNeighbor:(e,i)=>(e=t+e,i=r+i,o?!1===g[e]?.[i]:!1===this._fakeMatrix[e]?.[i]),getPRandom:tt(this._fakeMatrix,t,r,!1)}))}this.lightDotsMask&&this.createColor({options:e.imageOptions.fill.gradient,color:e.imageOptions.fill.color,additionalRotation:0,x:s,y:s,height:o*i,width:o*i,name:"light-dot-color"}),this._dotsColor=this.createColor({options:e.dotsOptions?.gradient,color:e.dotsOptions.color,additionalRotation:0,x:s,y:s,height:o*i,width:o*i,name:"dot-color"})}drawCorners(){if(!this.qr)throw Error("QR code is not defined");var t=this.options;if(!this._element)throw Error("Element code is not defined");var e=this.qr.getModuleCount(),r=this.options.dotsOptions.size,i=7*r,s=3*r,o=Math.floor((t.size-e*r)/2);[[0,0,0],[1,0,Math.PI/2],[0,1,-Math.PI/2]].forEach(([a,n,h])=>{var u=o+a*r*(e-7),d=o+n*r*(e-7),l=this.dotsMask,g=this.dotsMask;(t.cornersSquareOptions?.gradient||t.cornersSquareOptions?.color)&&(l=this.createMask(`mask-corners-square-color-${a}-${n}`),this.defs.appendChild(l),g=g=l,this.createColor({options:t.cornersSquareOptions?.gradient,color:t.cornersSquareOptions?.color,additionalRotation:h,x:u,y:d,height:i,width:i,name:`corners-square-color-${a}-${n}`}));var c={x:u,y:d,size:i,document:this.options.document,rotation:h},p=t.plugins?.length?function(t){return e=>{for(let r of t){let t=r.drawCornerSquare?.(e);if(t)return t}}}(t.plugins)(c):void 0;if(p){let[t,e]=p;l&&l.appendChild(t),this.lightDotsMask&&this.lightDotsMask.appendChild(e)}else if(function(t){return!(!t||!rt.has(t))}(t.cornersSquareOptions?.type)){let[e,r]=(j[t.cornersSquareOptions.type]||j[L.square])(c);l&&l.appendChild(e),this.lightDotsMask&&this.lightDotsMask.appendChild(r)}else{c=W(t.cornersSquareOptions?.type||t.dotsOptions.type,t.plugins);for(let t=0;t<et.length;t++)for(let e=0;e<et[t].length;e++)et[t]?.[e]?l&&l.appendChild(c({x:u+t*r,y:d+e*r,size:r,document:this.options.document,getNeighbor:(r,i)=>!!et[t+r]?.[e+i],getPRandom:tt(this._fakeMatrix,u/r+t,d/r+e,!1)})):this.lightDotsMask&&!it[t]?.[e]&&this.lightDotsMask&&this.lightDotsMask.appendChild(c({x:u+t*r,y:d+e*r,size:r,document:this.options.document,getNeighbor:(r,i)=>!et[t+r]?.[e+i]&&!it[t+r]?.[e+i],getPRandom:tt(this._fakeMatrix,u/r+t,d/r+e,!1)}));if(this.lightDotsMask)for(let t=-1;t<8;t++)for(let e=-1;e<8;e++)(-1==t||7==t||-1==e||7==e)&&this.lightDotsMask&&this.lightDotsMask.appendChild(c({x:u+t*r,y:d+e*r,size:r,document:this.options.document,getNeighbor:(r,i)=>(i=e+i,(r=t+r)>=-1&&r<=7&&i>=-1&&i<=7&&(-1==r||7==r||-1==i||7==i)),getPRandom:tt(this._fakeMatrix,u/r+t,d/r+e,!1)}))}if((t.cornersDotOptions?.gradient||t.cornersDotOptions?.color)&&(g=this.createMask(`mask-corners-dot-color-${a}-${n}`),this.defs.appendChild(g),this.createColor({options:t.cornersDotOptions?.gradient,color:t.cornersDotOptions?.color,additionalRotation:h,x:u+2*r,y:d+2*r,height:s,width:s,name:`corners-dot-color-${a}-${n}`})),a={x:u+2*r,y:d+2*r,size:s,document:this.document,rotation:h},n=t.plugins?.length?function(t){return e=>{for(let r of t){let t=r.drawCornerDot?.(e);if(t)return t}}}(t.plugins)(a):void 0)g&&g.appendChild(n);else if(function(t){return!(!t||!st.has(t))}(t.cornersDotOptions?.type))u=F[t.cornersDotOptions.type]||F[C.square],g&&g.appendChild(u(a));else{a=W(t.cornersDotOptions?.type||t.dotsOptions.type,t.plugins);for(let t=0;t<it.length;t++)for(let e=0;e<it[t].length;e++)it[t]?.[e]&&g&&g.appendChild(a({x:u+t*r,y:d+e*r,size:r,document:this.options.document,getNeighbor:(r,i)=>!!it[t+r]?.[e+i],getPRandom:tt(this._fakeMatrix,u/r+t,d/r+e,!1)}))}})}async drawImage({width:t,height:r,count:i,dotSize:s}){var o=this.options,a=Math.floor((o.size-i*s)/2),n=o.imageOptions.margin*s;o.imageOptions.mode==B.background&&(n=0);var h=a+n+(i*s-t)/2;if(i=a+n+(i*s-r)/2,t-=2*n,r-=2*n,n=await this.imageTools.toDataURL(o.image||""),(o=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&&(o=n[0]).setAttribute("overflow","visible"))}o.setAttribute("x",e(h)),o.setAttribute("y",e(i)),o.setAttribute("width",`${e(t)}px`),o.setAttribute("height",`${e(r)}px`),this._element.appendChild(o)}createColor(t){var r=o({...t,dotSize:this.options.dotsOptions.size,document:this.document});if(r){var{width:i,height:s,x:a,y:n}=t;a-=this.options.dotsOptions.size,n-=this.options.dotsOptions.size,i+=2*this.options.dotsOptions.size,s+=2*this.options.dotsOptions.size;var h=this.document.createElementNS("http://www.w3.org/2000/svg","rect");return h.setAttribute("x",e(a)),h.setAttribute("y",e(n)),h.setAttribute("height",e(s)),h.setAttribute("width",e(i)),h.setAttribute("clip-path",`url(#mask-${t.name})`),h.setAttribute("fill",r.value),r.gradient&&this.defs.appendChild(r.gradient),r.opacity<1&&h.setAttribute("opacity",r.opacity.toFixed(7)),this._element.appendChild(h),r}}createMask(t){var e=this.document.createElementNS("http://www.w3.org/2000/svg","clipPath");return e.setAttribute("id",t),e.setAttribute("clipPathUnits","userSpaceOnUse"),e}}Object.assign(D.stringToBytesFuncs,{UTF8:t=>{var e=[];for(let r=0;r<t.length;r++){let i=t.charCodeAt(r);i<128?e.push(i):i<2048?e.push(192|i>>6,128|63&i):i<55296||i>=57344?e.push(224|i>>12,128|i>>6&63,128|63&i):(r++,i=65536+((1023&i)<<10|1023&t.charCodeAt(r)),e.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|63&i))}return e}});class at{options;container;qr;extension;svgDrawingPromise;qrSVG;get size(){if(this.qrSVG)return{width:this.qrSVG.width,height:this.qrSVG.height}}constructor(t){this.options=t?H(T(I,t)):I,this.update()}update(t){this.container&&(this.container.innerHTML=""),this.options=t?H(T(this.options,t)):this.options,this.options.data&&(this.options.stringToBytesFuncs&&(Object.assign(D.stringToBytesFuncs,this.options.stringToBytesFuncs),delete this.options.stringToBytesFuncs),this.qr=new D(this.options.qrOptions.typeNumber,this.options.qrOptions.errorCorrectionLevel),t=this.options.qrOptions.mode||function(t){switch(!0){case/^[0-9]*$/.test(t):return z.numeric;case/^[0-9A-Z $%*+\-./:]*$/.test(t):return z.alphanumeric;case/[^\u0000-\u00ff]/.test(t):return z.unicode;default:return z.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 Error("Extension function should be defined.");this.extension=t,this.update()}deleteExtension(){this.extension=void 0,this.update()}async serialize(){if(!this.qr)throw Error("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==B.background&&this.options.shape!=S.circle&&(t+=2),(t=Math.ceil((this.options.shape==S.circle?Math.sqrt(2):1)*t))%2==0&&--t;var e=this.options.backgroundOptions&&this.options.backgroundOptions.margin||0;this.options.imageOptions.mode==B.background&&(e+=this.options.imageOptions.margin||0);var r=Math.ceil(this.options.dotsOptions.size*(t+2*e));this.qrSVG=new ot({...this.options,width:r,height:r,size:r,errorCorrectionPercent:U[this.options.qrOptions.errorCorrectionLevel]}),this.svgDrawingPromise=this.qrSVG.drawQR(this.qr).then(()=>{this.qrSVG?.element&&(this.options.plugins?.forEach(t=>t.postProcess?.(this.qrSVG.element,{...this.options,width:r,height:r,size:r},{dots:this.qrSVG?.dotsColor,background:this.qrSVG?.backgroundColor})),this.extension?.(this.qrSVG.element,{...this.options,width:r,height:r,size:r}))})}}}var nt={width:300,height:300,margin:0};var ht,ut=ht||={};ut.Lanczos="lanczos",ut.Linear="linear";var dt={[ht.Lanczos]:(t,e)=>e>=t||e<=-t?0:0===e?1:(e*=Math.PI,t*Math.sin(e)*Math.sin(e/t)/(e*e)),[ht.Linear]:(t,e)=>(e=Math.abs(e))<=1?(1-e)*t:0};function lt(t){return"object"==typeof t?(t.baseVal.convertToSpecifiedUnits(t.baseVal.SVG_LENGTHTYPE_PX),t.baseVal.value):t}var gt,ct=gt||={};function pt(t,e){var{width:r,height:i,margin:s}=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}(T(nt,e)):nt,o=document.createElement("canvas");o.width=r,o.height=i;var a=Math.min(r,i)-2*s;return t=t.serialize().then(t=>{if(t){var e=t.match(/viewBox="([^"]+)"/i)[1],n="data:image/svg+xml;base64,"+btoa(t),h=new Image;return new Promise((t,u)=>{h.onload=()=>{var n=Math.ceil(2*a/Math.min(h.width,h.height)),[u,d,l,g]=e.split(/\s+/g).map(parseFloat).map(t=>t*n),c=(u%1+1)%1,p=(d%1+1)%1;try{var m=new OffscreenCanvas(Math.ceil(l+c+2),Math.ceil(g+p+2))}catch(t){(m=document.createElement("canvas")).width=Math.ceil(l+c+2),m.height=Math.ceil(g+p+2)}m.getContext("2d")?.drawImage(h,c+1,p+1,l,g),c=function(t,e,r=dt[ht.Lanczos]){var i=lt(t.width),s=lt(t.height);t=t.getContext("2d");var{width:o,height:a}=e,n=t.getImageData(0,0,i,s);if(e=t.createImageData(o,a),n.data.length==e.data.length)e=n;else{t=n.data,n=e.data;let y=[];var h=o/i,u=a/s;let A=3;h>.01&&u>.01&&h<1&&u<1&&(A=h<=.2||u<=.2?2:h<=.05||u<=.05?1:3),u=i-1,--s;let E=1/h,z=1/h,k=1/o,D=1/a,x=Math.min(1,h)*Math.min(1,h);h=Math.min(1,h)*Math.min(1,h);for(var d=A,l={},g=d*d*1e3,c=0;c<g;c++){var p=r(d,Math.sqrt(.001*c));l[c]=p<0?0:p}for(r=l,d=a;d--;){(l=(c=(d+.5)*z)-A)<0&&(l=0),p=g=c+A,g!=p&&(g=p+1),g>s&&(g=s),c=d*D-c,p=d*o;let e=o;for(;e--;){var m=(e+.5)*E,$=m-A;$<0&&($=0);let s=m+A;var v=s;s!=v&&(s=v+1),s>u&&(s=u);var w=e*k-m;v=m=0;for(var f=0|l;f<=g;f++)for(var b=(f+c)*(f+c)*h,M=0|$;M<=s;M++)v+=y[m++]=r[1e3*((M+w)*(M+w)*x+b)|0]||0;v=1/v,M=b=f=w=m=0;for(let e=0|l;e<=g;e++){let r=e*i;for(let e=0|$;e<=s;e++){let i=y[m++]*v,s=4*(r+e|0);f+=t[s]*i,b+=t[s+1]*i,M+=t[s+2]*i,w+=t[s+3]*i}}n[$=4*(e+p|0)]=f,n[$+1]=b,n[$+2]=M,n[$+3]=w}}}return e}(m,{width:r-2*s,height:i-2*s}),o?.getContext("2d")?.putImageData(c,s,s),t()},h.onerror=h.onabort=u,h.src=n})}}),{canvas:o,canvasDrawingPromise:t}}function mt(t,e){var r=document.createElement("a");r.download=e,r.href=t,document.body.appendChild(r),r.click(),document.body.removeChild(r)}ct.svg="svg",ct.png="png",ct.jpeg="jpeg",ct.webp="webp";var $t=Object.freeze({__proto__:null,get FileExtension(){return gt},download:async function(t,e,r){var i=gt.png,s="qr";if(e&&(e.name&&(s=e.name),e.extension&&(i=e.extension)),"svg"===i.toLowerCase())(i=await t.serialize())&&mt(i="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(i),`${s}.svg`);else if(t=pt(t,r)){var{canvas:o,canvasDrawingPromise:a}=t;await a,mt(t=o.toDataURL(`image/${i}`),`${s}.${i}`)}},downloadURI:mt,drawToCanvas:pt});export{C as CornerDotType,L as CornerSquareType,O as DotType,y as ErrorCorrectionLevel,U as ErrorCorrectionPercents,gt as FileExtension,B as ImageMode,z as Mode,at as QRCodeStyling,S as ShapeType,A as TypeNumber,$t as browserUtils};
1
+ import{svgPath as t,numToAttr as e,scalePath as r,rotateFigure as i}from"./plugin-utils.js";import{s,c as o}from"./color-dXYWdVDW.js";export{G as GradientType}from"./color-dXYWdVDW.js";class a{buffer;length;constructor(){this.buffer=[],this.length=0}getBuffer(){return this.buffer}getLengthInBits(){return this.length}toString(){var 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 r=0;r<e;r+=1)this.putBit(1==(t>>>e-r-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 n,h=n||={};h[h.L=1]="L",h[h.M=0]="M",h[h.Q=3]="Q",h[h.H=2]="H";class u{constructor(){throw Error("error")}static initialize;static EXP_TABLE;static LOG_TABLE;static glog(t){if(u.LOG_TABLE||u.initialize(),t<1)throw Error("log("+t+")");return u.LOG_TABLE[t]}static gexp(t){for(u.EXP_TABLE||u.initialize();t<0;)t+=255;for(;t>=256;)t-=255;return u.EXP_TABLE[t]}}u.initialize=()=>{u.EXP_TABLE=[],u.LOG_TABLE=[];for(var t=0;t<256;t+=1)u.EXP_TABLE.push(t<8?1<<t:u.EXP_TABLE[t-4]^u.EXP_TABLE[t-5]^u.EXP_TABLE[t-6]^u.EXP_TABLE[t-8]),u.LOG_TABLE.push(0);for(t=0;t<255;t+=1)u.LOG_TABLE[u.EXP_TABLE[t]]=t};class d{num;constructor(t,e=0){for(var r=0;r<t.length&&0==t[r];)r+=1;this.num=[];var i=t.length-r;for(let e=0;e<i;e+=1)this.num.push(t[r+e]);for(t=0;t<e;t+=1)this.num.push(0)}getAt(t){return this.num[t]}getLength(){return this.num.length}toString(){var t="";for(let e=0;e<this.getLength();e+=1)e>0&&(t+=","),t+=this.getAt(e);return t.toString()}toLogString(){var t="";for(let e=0;e<this.getLength();e+=1)e>0&&(t+=","),t+=u.glog(this.getAt(e));return t.toString()}multiply(t){for(var e=[],r=this.getLength()+t.getLength()-1,i=0;i<r;i+=1)e.push(0);for(r=0;r<this.getLength();r+=1)for(i=0;i<t.getLength();i+=1)e[r+i]^=u.gexp(u.glog(this.getAt(r))+u.glog(t.getAt(i)));return new d(e)}mod(t){if(this.getLength()-t.getLength()<0)return this;for(var e=u.glog(this.getAt(0))-u.glog(t.getAt(0)),r=[],i=0;i<this.getLength();i+=1)r.push(this.getAt(i));for(i=0;i<t.getLength();i+=1)r[i]^=u.gexp(u.glog(t.getAt(i))+e);return new d(r).mod(t)}}var l,g=l||={};g[g.MODE_NUMBER=1]="MODE_NUMBER",g[g.MODE_ALPHA_NUM=2]="MODE_ALPHA_NUM",g[g.MODE_8BIT_BYTE=4]="MODE_8BIT_BYTE",g[g.MODE_KANJI=8]="MODE_KANJI";class c{mode;data;constructor(t,e){this.mode=t,this.data=e}getMode(){return this.mode}getData(){return this.data}getLengthInBits(t){if(1<=t&&t<10)switch(this.mode){case l.MODE_NUMBER:return 10;case l.MODE_ALPHA_NUM:return 9;case l.MODE_8BIT_BYTE:case l.MODE_KANJI:return 8;default:throw Error("mode:"+this.mode)}else if(t<27)switch(this.mode){case l.MODE_NUMBER:return 12;case l.MODE_ALPHA_NUM:return 11;case l.MODE_8BIT_BYTE:return 16;case l.MODE_KANJI:return 10;default:throw Error("mode:"+this.mode)}else{if(!(t<41))throw Error("typeNumber:"+t);switch(this.mode){case l.MODE_NUMBER:return 14;case l.MODE_ALPHA_NUM:return 13;case l.MODE_8BIT_BYTE:return 16;case l.MODE_KANJI:return 12;default:throw Error("mode:"+this.mode)}}}}class p extends c{stringToBytes;constructor(t,e){super(l.MODE_8BIT_BYTE,t),this.stringToBytes=e}write(t){this.stringToBytes(this.getData()).forEach(e=>t.put(e,8))}getLength(){return this.stringToBytes(this.getData()).length}}class m extends c{constructor(t){super(l.MODE_ALPHA_NUM,t)}write(t){for(var e=this.getData(),r=0;r+1<e.length;)t.put(45*m.getCode(e.charAt(r))+m.getCode(e.charAt(r+1)),11),r+=2;r<e.length&&t.put(m.getCode(e.charAt(r)),6)}getLength(){return this.getData().length}static getCode(t){if("0"<=t&&t<="9")return t.charCodeAt(0)-48;if("A"<=t&&t<="Z")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 Error("illegal char :"+t)}}}class $ extends c{stringToBytes;constructor(t,e){super(l.MODE_KANJI,t),this.stringToBytes=e}write(t){for(var e=this.stringToBytes(this.getData()),r=0;r+1<e.length;){let i=(255&e[r])<<8|255&e[r+1];if(33088<=i&&i<=40956)i-=33088;else{if(!(57408<=i&&i<=60351))throw Error("illegal char at "+(r+1)+"/"+i);i-=49472}i=192*(i>>>8&255)+(255&i),t.put(i,13),r+=2}if(r<e.length)throw Error("illegal char at "+(r+1))}getLength(){return this.stringToBytes(this.getData()).length/2}}class v extends c{constructor(t){super(l.MODE_NUMBER,t)}write(t){for(var e=this.getData(),r=0;r+2<e.length;)t.put(v.strToNum(e.substring(r,r+3)),10),r+=3;r<e.length&&(e.length-r==1?t.put(v.strToNum(e.substring(r,r+1)),4):e.length-r==2&&t.put(v.strToNum(e.substring(r,r+2)),7))}getLength(){return this.getData().length}static strToNum(t){var e=0;for(let r=0;r<t.length;r+=1)e=10*e+v.chatToNum(t.charAt(r));return e}static chatToNum(t){if("0"<=t&&t<="9")return t.charCodeAt(0)-48;throw Error("illegal char :"+t)}}var w,f=w||={};f[f.PATTERN000=0]="PATTERN000",f[f.PATTERN001=1]="PATTERN001",f[f.PATTERN010=2]="PATTERN010",f[f.PATTERN011=3]="PATTERN011",f[f.PATTERN100=4]="PATTERN100",f[f.PATTERN101=5]="PATTERN101",f[f.PATTERN110=6]="PATTERN110",f[f.PATTERN111=7]="PATTERN111";class b{constructor(){throw Error("error")}static getPatternPosition(t){return b.PATTERN_POSITION_TABLE[t-1]}static PATTERN_POSITION_TABLE;static MAX_LENGTH;static getMaxLength(t,e,r){switch(r){case n.L:r=0;break;case n.M:r=1;break;case n.Q:r=2;break;case n.H:r=3;break;default:throw Error("e:"+r)}switch(e){case l.MODE_NUMBER:e=0;break;case l.MODE_ALPHA_NUM:e=1;break;case l.MODE_8BIT_BYTE:e=2;break;case l.MODE_KANJI:e=3;break;default:throw Error("m:"+e)}return b.MAX_LENGTH[t-1][r][e]}static getErrorCorrectPolynomial(t){var e=new d([1]);for(let r=0;r<t;r+=1)e=e.multiply(new d([1,u.gexp(r)]));return e}static getMaskFunc(t){switch(t){case w.PATTERN000:return(t,e)=>(t+e)%2==0;case w.PATTERN001:return t=>t%2==0;case w.PATTERN010:return(t,e)=>e%3==0;case w.PATTERN011:return(t,e)=>(t+e)%3==0;case w.PATTERN100:return(t,e)=>(~~(t/2)+~~(e/3))%2==0;case w.PATTERN101:return(t,e)=>t*e%2+t*e%3==0;case w.PATTERN110:return(t,e)=>(t*e%2+t*e%3)%2==0;case w.PATTERN111:return(t,e)=>(t*e%3+(t+e)%2)%2==0;default:throw Error("mask:"+t)}}static getLostPoint(t){for(var e=t.getModuleCount(),r=0,i=0;i<e;i+=1)for(var s=0;s<e;s+=1){var o=0;let a=t.isDark(i,s);for(let r=-1;r<=1;r+=1)if(!(i+r<0||e<=i+r))for(let n=-1;n<=1;n+=1)s+n<0||e<=s+n||(0!=r||0!=n)&&a==t.isDark(i+r,s+n)&&(o+=1);o>5&&(r+=3+o-5)}for(i=0;i<e-1;i+=1)for(s=0;s<e-1;s+=1)o=0,t.isDark(i,s)&&(o+=1),t.isDark(i+1,s)&&(o+=1),t.isDark(i,s+1)&&(o+=1),t.isDark(i+1,s+1)&&(o+=1),(0==o||4==o)&&(r+=3);for(i=0;i<e;i+=1)for(s=0;s<e-6;s+=1)t.isDark(i,s)&&!t.isDark(i,s+1)&&t.isDark(i,s+2)&&t.isDark(i,s+3)&&t.isDark(i,s+4)&&!t.isDark(i,s+5)&&t.isDark(i,s+6)&&(r+=40);for(i=0;i<e;i+=1)for(s=0;s<e-6;s+=1)t.isDark(s,i)&&!t.isDark(s+1,i)&&t.isDark(s+2,i)&&t.isDark(s+3,i)&&t.isDark(s+4,i)&&!t.isDark(s+5,i)&&t.isDark(s+6,i)&&(r+=40);for(i=0,s=0;s<e;s+=1)for(o=0;o<e;o+=1)t.isDark(o,s)&&(i+=1);return r+Math.abs(100*i/e/e-50)/5*10}static getBCHTypeInfo(t){for(var e=t<<10;b.getBCHDigit(e)-b.getBCHDigit(b.G15)>=0;)e^=b.G15<<b.getBCHDigit(e)-b.getBCHDigit(b.G15);return(t<<10|e)^b.G15_MASK}static getBCHTypeNumber(t){for(var e=t<<12;b.getBCHDigit(e)-b.getBCHDigit(b.G18)>=0;)e^=b.G18<<b.getBCHDigit(e)-b.getBCHDigit(b.G18);return t<<12|e}static G15;static G18;static G15_MASK;static getBCHDigit(t){for(var e=0;0!=t;)e+=1,t>>>=1;return e}}b.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]],b.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]]],b.G15=1335,b.G18=7973,b.G15_MASK=21522;class M{totalCount;dataCount;static RS_BLOCK_TABLE;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;var r=[];for(let i=0;i<e;i+=1){let e=t[3*i],s=t[3*i+1],o=t[3*i+2];for(let t=0;t<e;t+=1)r.push(new M(s,o))}return r}static getRsBlockTable(t,e){switch(e){case n.L:return M.RS_BLOCK_TABLE[4*(t-1)];case n.M:return M.RS_BLOCK_TABLE[4*(t-1)+1];case n.Q:return M.RS_BLOCK_TABLE[4*(t-1)+2];case n.H:return M.RS_BLOCK_TABLE[4*(t-1)+3]}throw Error("tn:"+t+"/ecl:"+e)}}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]];var y,A=Array(41).fill(0).map((t,e)=>e),E=y||={};E.L="L",E.M="M",E.Q="Q",E.H="H";var z,k=z||={};k.numeric="numeric",k.alphanumeric="alphanumeric",k.byte="byte",k.kanji="kanji",k.unicode="unicode";class D{static stringToBytesFuncs;static PAD0;static PAD1;typeNumber;errorCorrectLevel;qrDataList;modules=[];moduleCount=0;constructor(t=0,e=y.L){this.typeNumber=t,this.errorCorrectLevel=n[e],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=z.byte){if(t instanceof c)this.qrDataList.push(t);else{if("string"!=typeof t)throw Error(typeof t);switch(e){case z.numeric:this.qrDataList.push(new v(t));break;case z.alphanumeric:this.qrDataList.push(new m(t));break;case z.byte:this.qrDataList.push(new p(t,D.stringToBytesFuncs.default));break;case z.unicode:this.qrDataList.push(new p(t,D.stringToBytesFuncs.UTF8));break;case z.kanji:this.qrDataList.push(new $(t,D.stringToBytesFuncs.SJIS));break;default:throw Error("mode:"+e)}}}isDark(t,e){return null!=this.modules[t][e]&&this.modules[t][e]}getModuleCount(){return this.moduleCount}make(){if(this.typeNumber<1){let e=1;for(;e<40;e++){var t=M.getRSBlocks(e,this.errorCorrectLevel);let r=new a;if(this.qrDataList.forEach(t=>{r.put(t.getMode(),4),r.put(t.getLength(),t.getLengthInBits(e)),t.write(r)}),t=t.reduce((t,e)=>t+e.getDataCount(),0),r.getLengthInBits()<=8*t)break}this.typeNumber=e}this.makeImpl(!1,this.getBestMaskPattern())}getBestMaskPattern(){var t=0,e=0;for(let r=0;r<8;r+=1){this.makeImpl(!0,r);let i=b.getLostPoint(this);(0==r||t>i)&&(t=i,e=r)}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),this.typeNumber>=7&&this.setupTypeNumber(t),t=D.createData(this.typeNumber,this.errorCorrectLevel,this.qrDataList),this.mapData(t,e)}mapData(t,e){var r=-1,i=this.moduleCount-1,s=7,o=0;e=b.getMaskFunc(e);for(let a=this.moduleCount-1;a>0;a-=2)for(6==a&&--a;;){for(let r=0;r<2;r+=1)if(null==this.modules[i][a-r]){let n=!1;o<t.length&&(n=1==(t[o]>>>s&1)),e(i,a-r)&&(n=!n),this.modules[i][a-r]=n,-1==--s&&(o+=1,s=7)}if((i+=r)<0||this.moduleCount<=i){i-=r,r=-r;break}}}setupPositionAdjustPattern(){var t=b.getPatternPosition(this.typeNumber);t.forEach(e=>{t.forEach(t=>{if(null==this.modules[e][t])for(let r=-2;r<=2;r+=1)for(let i=-2;i<=2;i+=1)this.modules[e+r][t+i]=-2==r||2==r||-2==i||2==i||0==r&&0==i})})}setupPositionProbePattern(t,e){for(let r=-1;r<=7;r+=1)for(let i=-1;i<=7;i+=1)t+r<=-1||this.moduleCount<=t+r||e+i<=-1||this.moduleCount<=e+i||(this.modules[t+r][e+i]=0<=r&&r<=6&&(0==i||6==i)||0<=i&&i<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=i&&i<=4)}setupTimingPattern(){for(var t=8;t<this.moduleCount-8;t+=1)null==this.modules[t][6]&&(this.modules[t][6]=t%2==0);for(t=8;t<this.moduleCount-8;t+=1)null==this.modules[6][t]&&(this.modules[6][t]=t%2==0)}setupTypeNumber(t){for(var e=b.getBCHTypeNumber(this.typeNumber),r=0;r<18;r+=1)this.modules[~~(r/3)][r%3+this.moduleCount-8-3]=!t&&1==(e>>r&1);for(r=0;r<18;r+=1)this.modules[r%3+this.moduleCount-8-3][~~(r/3)]=!t&&1==(e>>r&1)}setupTypeInfo(t,e){e=b.getBCHTypeInfo(this.errorCorrectLevel<<3|e);for(var r=0;r<15;r+=1){var i=!t&&1==(e>>r&1);r<6?this.modules[r][8]=i:r<8?this.modules[r+1][8]=i:this.modules[this.moduleCount-15+r][8]=i}for(r=0;r<15;r+=1)i=!t&&1==(e>>r&1),r<8?this.modules[8][this.moduleCount-r-1]=i:r<9?this.modules[8][15-r-1+1]=i:this.modules[8][15-r-1]=i;this.modules[this.moduleCount-8][8]=!t}static createData(t,e,r){e=M.getRSBlocks(t,e);var i=new a;if(r.forEach(e=>{i.put(e.getMode(),4),i.put(e.getLength(),e.getLengthInBits(t)),e.write(i)}),r=e.reduce((t,e)=>t+e.getDataCount(),0),i.getLengthInBits()>8*r)throw Error("code length overflow. ("+i.getLengthInBits()+">"+8*r+")");for(i.getLengthInBits()+4<=8*r&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=8*r)&&(i.put(D.PAD0,8),!(i.getLengthInBits()>=8*r));)i.put(D.PAD1,8);return D.createBytes(i,e)}static createBytes(t,e){function r(t){var e=[];for(let r=0;r<t;r+=1)e.push(0);return e}for(var i=0,s=0,o=0,a=Array(e.length).map(()=>[]),n=Array(e.length).map(()=>[]),h=0;h<e.length;h+=1){var u=e[h].getDataCount(),l=e[h].getTotalCount()-u;s=Math.max(s,u),o=Math.max(o,l),a[h]=r(u);for(var g=0;g<a[h].length;g+=1)a[h][g]=255&t.getBuffer()[g+i];for(i+=u,l=b.getErrorCorrectPolynomial(l),u=new d(a[h],l.getLength()-1).mod(l),n[h]=r(l.getLength()-1),l=0;l<n[h].length;l+=1)g=l+u.getLength()-n[h].length,n[h][l]=g>=0?u.getAt(g):0}for(t=r(t=e.reduce((t,e)=>t+e.getTotalCount(),0)),i=0,h=0;h<s;h+=1)for(u=0;u<e.length;u+=1)h<a[u].length&&(t[i]=a[u][h],i+=1);for(s=0;s<o;s+=1)for(a=0;a<e.length;a+=1)s<n[a].length&&(t[i]=n[a][s],i+=1);return t}}D.stringToBytesFuncs={default(t){var e=[];for(let r=0;r<t.length;r+=1){let i=t.charCodeAt(r);e.push(255&i)}return e}},D.PAD0=236,D.PAD1=17;var x=t=>!!t&&"object"==typeof t&&!Array.isArray(t);function T(t,...e){if(!e.length)return t;var r=e.shift();return void 0!==r&&x(t)&&x(r)?(t={...t},Object.keys(r).forEach(e=>{var i=t[e],s=r[e];Array.isArray(i)&&Array.isArray(s)?t[e]=s:x(i)&&x(s)?t[e]=T({...i},s):t[e]=s}),T(t,...e)):t}var O,P=O||={};P.dot="dot",P.randomDot="random-dot",P.rounded="rounded",P.extraRounded="extra-rounded",P.verticalLine="vertical-line",P.horizontalLine="horizontal-line",P.classy="classy",P.classyRounded="classy-rounded",P.square="square",P.smallSquare="small-square",P.tinySquare="tiny-square",P.diamond="diamond",P.wave="wave",P.heart="heart",P.star="star",P.weave="weave",P.pentagon="pentagon",P.hexagon="hexagon",P.octagon="octagon",P.circuit="circuit",P.zebraHorizontal="zebra-horizontal",P.zebraVertical="zebra-vertical",P.blocksHorizontal="blocks-horizontal",P.blocksVertical="blocks-vertical",P.blobs="blobs",P.soft="soft";var C,N=C||={};N.dot="dot",N.square="square",N.heart="heart",N.extraRounded="extra-rounded",N.classy="classy",N.inpoint="inpoint",N.outpoint="outpoint",N.star="star",N.pentagon="pentagon",N.hexagon="hexagon",N.octagon="octagon",N.diamond="diamond";var L,_=L||={};_.dot="dot",_.square="square",_.extraRounded="extra-rounded",_.classy="classy",_.inpoint="inpoint",_.outpoint="outpoint",_.centerCircle="center-circle";var S,q=S||={};q.square="square",q.circle="circle";var B,R=B||={};R.center="center",R.overlay="overlay",R.background="background";var I={document:void 0,shape:S.square,width:void 0,height:void 0,size:void 0,data:"",qrOptions:{typeNumber:A[0],mode:void 0,errorCorrectionLevel:y.Q},imageOptions:{mode:B.center,imageSize:.4,crossOrigin:void 0,margin:0,fill:{color:"rgba(255,255,255,1)"}},dotsOptions:{type:O.square,color:"#000",size:10}};function H(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==B.overlay&&(t.imageOptions.margin=0),t.imageOptions.fill.gradient&&(t.imageOptions.fill.gradient=s(t.imageOptions.fill.gradient)),t.dotsOptions={...t.dotsOptions},t.dotsOptions.gradient&&(t.dotsOptions.gradient=s(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=s(t.cornersSquareOptions.gradient))),t.cornersDotOptions&&(t.cornersDotOptions={...t.cornersDotOptions},t.cornersDotOptions.gradient&&(t.cornersDotOptions.gradient=s(t.cornersDotOptions.gradient))),t.backgroundOptions&&(t.backgroundOptions={...t.backgroundOptions},t.backgroundOptions.gradient&&(t.backgroundOptions.gradient=s(t.backgroundOptions.gradient))),t.document||(t.document=document),t}var U={[y.L]:.07,[y.M]:.15,[y.Q]:.25,[y.H]:.3};var V={dot:t=>{var{size:r,x:i,y:s,document:o}=t;return(t=o.createElementNS("http://www.w3.org/2000/svg","circle")).setAttribute("cx",e(i+r/2)),t.setAttribute("cy",e(s+r/2)),t.setAttribute("r",e(r/2)),t},square:(t,{width:r=t.size,height:i=t.size}={})=>{var{x:s,y:o,size:a,document:n}=t;return(t=n.createElementNS("http://www.w3.org/2000/svg","rect")).setAttribute("x",e(s+(a-r)/2)),t.setAttribute("y",e(o+(a-i)/2)),t.setAttribute("width",e(r)),t.setAttribute("height",e(i)),t},sideRounded:(e,{height:r=e.size}={})=>{var{size:i,x:s,y:o,document:a}=e;return(e=a.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",t`M ${s} ${o+(i-r)/2} v ${r} h ${i/2} a ${r/2} ${r/2} 0 0 0 0 ${-r} z`),e},cornerRounded:e=>{var{size:r,x:i,y:s,document:o}=e;return(e=o.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",t`M ${i} ${s} v ${r} h ${r} v ${-r/2} a ${r/2} ${r/2} 0 0 0 ${-r/2} ${-r/2} z`),e},cornerExtraRounded:e=>{var{size:r,x:i,y:s,document:o}=e;return(e=o.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",t`M ${i} ${s} v ${r} h ${r} a ${r} ${r} 0 0 0 ${-r} ${-r} z`),e},classyDot:e=>{var{size:r,x:i,y:s,document:o}=e;return(e=o.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",t`M ${i} ${s} v ${r/2} a ${r/2} ${r/2} 0 0 0 ${r/2} ${r/2} h ${r/2} v ${-r/2} a ${r/2} ${r/2} 0 0 0 ${-r/2} ${-r/2} z`),e},wave:e=>{var{size:r,x:i,y:s,document:o}=e,a=5*Math.PI/180,n=65*Math.PI/180;e=r*(1-.65*Math.sin(a)),a=-r*(.95-.65*Math.cos(a));var h=-r*Math.sin(n)/2;n=r*Math.cos(n)/2;var u=o.createElementNS("http://www.w3.org/2000/svg","path");return u.setAttribute("d",t`M ${i} ${s+r} c ${.65*r} 0 ${e} ${a} ${r} ${.95*-r} c ${h} ${n} ${-r/2} ${r*(.95-1)} ${-r} ${r*(.95-1)} z`),u},heart:t=>{var{size:e,x:i,y:s,document:o}=t;return(t=o.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",r(["M",1,.31629,"c",-86e-5,.15702,-.10534,.26323,-.21876,.38123,"c",-.06736,.06834,-.18938,.17948,-.28124,.26126,"c",-.09188,-.08178,-.2139,-.19292,-.28124,-.26126,"c",-.11344,-.118,-.2179,-.22422,-.21876,-.38123,"c",-96e-5,-.27136,.33154,-.36842,.5,-.17,"c",.16844,-.19842,.50094,-.10136,.5,.17,"z"],{x:i,y:s,size:e})),t},rounded:t=>{var{size:r,x:i,y:s,document:o}=t;return(t=o.createElementNS("http://www.w3.org/2000/svg","rect")).setAttribute("x",e(i)),t.setAttribute("y",e(s)),t.setAttribute("width",e(r)),t.setAttribute("height",e(r)),t.setAttribute("rx",e(r/4)),t.setAttribute("ry",e(r/4)),t},classy:e=>{var{size:r,x:i,y:s,document:o}=e;e=r/7;var a=o.createElementNS("http://www.w3.org/2000/svg","path");return a.setAttribute("d",t`M ${i} ${s+2.5*e} v ${2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${2.5*e} h ${4.5*e} v ${-4.5*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*-e} h ${-2*e} H ${i} z`),a},inpoint:e=>{var{size:r,x:i,y:s,document:o}=e;return(e=o.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",t`M ${i} ${s+r/2} v ${r/4} a ${r/4} ${r/4} 0 0 0 ${r/4} ${r/4} h ${r/4*3} v ${-r/4*3} a ${r/4} ${r/4} 0 0 0 ${-r/4} ${-r/4} h ${-r/2} a ${r/4} ${r/4} 0 0 0 ${-r/4} ${r/4} z`),e},star:(e,{spikes:r=5,outerRadius:i=e.size/2,innerRadius:s=e.size/4}={})=>{var{size:o,x:a,y:n,document:h}=e,u=a+o/2,d=n+o/2,l=Math.PI/r;return(e=h.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",Array(2*r).fill(0).map((e,r)=>t`${0===r?"M":"L"} ${u+(e=r%2==0?i:s)*Math.sin(r*l)} ${d-e*Math.cos(r*l)}`).join(" ")),e},weave:e=>{var{size:r,x:i,y:s,document:o}=e,a=(r-(e=.6*r))/2,n=o.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d",t`M ${i+a} ${s} l ${e} 0 l 0 ${a} l ${a} 0 l 0 ${e} l ${-a} 0 l 0 ${a} l ${-e} 0 l 0 ${-a} l ${-a} 0 l 0 ${-e} l ${a} 0 z`),n},blob:(e,r)=>{var{size:i,x:s,y:o,document:a}=e;e=i/7;var n=a.createElementNS("http://www.w3.org/2000/svg","path"),h=[t`M ${s} ${o+2.5*e}`],u=2*e;return"round"==r.bl?(h.push(t`v ${u} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${2.5*e}`),u=2*e):"out"==r.bl?(h.push(t`v ${5*e+u} a ${2.5*e} ${2.5*e} 0 0 1 ${2.5*e} ${-2.5*e}`),u=2*e):(h.push(t`v ${2.5*e+u}`),u=4.5*e),"round"==r.br?(h.push(t`h ${u} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${-2.5*e}`),u=-2*e):"out"==r.br?(h.push(t`h ${5*e+u} a ${2.5*e} ${2.5*e} 0 0 1 ${-2.5*e} ${-2.5*e}`),u=-2*e):(h.push(t`h ${2.5*e+u}`),u=-4.5*e),"round"==r.tr?(h.push(t`v ${u} a ${2.5*e} ${2.5*e} 0 0 0 ${-2.5*e} ${-2.5*e}`),u=-2*e):"out"==r.tr?(h.push(t`v ${-5*e+u} a ${2.5*e} ${2.5*e} 0 0 1 ${-2.5*e} ${2.5*e}`),u=-2*e):(h.push(t`v ${-2.5*e+u}`),u=-4.5*e),"round"==r.tl?h.push(t`h ${u} a ${2.5*e} ${2.5*e} 0 0 0 ${-2.5*e} ${2.5*e}`):"out"==r.tl?h.push(t`h ${-5*e+u} a ${2.5*e} ${2.5*e} 0 0 1 ${2.5*e} ${2.5*e}`):h.push(t`h ${-2.5*e+u}`),n.setAttribute("d",h.join(" ")+" z"),n},circuit:(e,r=!1)=>{var{size:i,x:s,y:o,document:a}=e;e=.17**.5*i;var n=a.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d",t`M ${s+.4*i} ${o+.5*i-e} a ${.4*i} ${.4*i} 0 0 0 ${r?.1*i-e:-.3*i} ${r?e-.1*i:e} ${r?t`h ${-.3*i} v ${.2*i} h ${.3*i} a ${.4*i} ${.4*i} 0 0 0 ${e} ${.3*i}`:t`a ${.4*i} ${.4*i} 0 0 0 ${.4*i} ${.4*i}`} a ${.4*i} ${.4*i} 0 0 0 ${.4*i} ${-.4*i} a ${.4*i} ${.4*i} 0 0 0 ${-.3*i} ${-e} v ${-.3*i} h ${-.2*i} z`),n.setAttribute("fill-rule","nonzero"),n}},F={[C.dot]:t=>i({...t,draw:V.dot}),[C.square]:t=>i({...t,draw:V.square}),[C.heart]:t=>V.heart(t),[C.extraRounded]:t=>i({...t,draw:V.rounded}),[C.classy]:t=>i({...t,draw:V.classy}),[C.inpoint]:t=>i({...t,draw:V.inpoint}),[C.outpoint]:t=>i({...t,rotation:(t.rotation||0)+Math.PI,draw:V.inpoint}),[C.star]:t=>V.star(t),[C.pentagon]:t=>V.star(t,{spikes:2.5,outerRadius:t.size/2,innerRadius:t.size/2}),[C.hexagon]:t=>V.star(t,{spikes:3,outerRadius:t.size/2,innerRadius:t.size/2}),[C.octagon]:t=>V.star(t,{spikes:4,outerRadius:t.size*Math.cos(Math.PI/8)/2,innerRadius:t.size*Math.cos(Math.PI/8)/2}),[C.diamond]:t=>i({...t,rotation:Math.PI/4,draw:t=>V.square(t,{width:.85*t.size,height:.85*t.size})})};var X={dot:e=>{var{size:r,x:i,y:s,document:o}=e;e=r/7;var a=o.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("clip-rule","evenodd"),a.setAttribute("d",t`M ${i+r/2} ${s} a ${r/2} ${r/2} 0 1 0 0.1 0 z m 0 ${e} a ${r/2-e} ${r/2-e} 0 1 1 -0.1 0 Z`);var n=o.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("clip-rule","evenodd"),n.setAttribute("d",t`M ${i+r/2} ${s-e} a ${r/2+e} ${r/2+e} 0 1 0 0.1 0 z`),[a,n]},square:e=>{var{size:r,x:i,y:s,document:o}=e;e=r/7;var a=o.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("clip-rule","evenodd"),a.setAttribute("d",t`M ${i} ${s} v ${r} h ${r} v ${-r} z M ${i+e} ${s+e} h ${r-2*e} v ${r-2*e} h ${2*e-r} z`);var n=o.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("clip-rule","evenodd"),n.setAttribute("d",t`M ${i-e} ${s-e} h ${r+2*e} v ${r+2*e} h ${-r-2*e} z`),[a,n]},extraRounded:e=>{var{size:r,x:i,y:s,document:o}=e;e=r/7;var a=o.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("clip-rule","evenodd"),a.setAttribute("d",t`M ${i} ${s+2.5*e} v ${2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${2.5*e} h ${2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${2.5*-e} v ${-2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*-e} h ${-2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*e} z M ${i+2.5*e} ${s+e} h ${2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*e} ${1.5*e} v ${2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*-e} ${1.5*e} h ${-2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*-e} ${1.5*-e} v ${-2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*e} ${1.5*-e} z`);var n=o.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("clip-rule","evenodd"),n.setAttribute("d",t`M ${i-e} ${s+2.5*e} v ${2*e} a ${3.5*e} ${3.5*e} 0 0 0 ${3.5*e} ${3.5*e} h ${2*e} a ${3.5*e} ${3.5*e} 0 0 0 ${3.5*e} ${3.5*-e} v ${-2*e} a ${3.5*e} ${3.5*e} 0 0 0 ${3.5*-e} ${3.5*-e} h ${-2*e} a ${3.5*e} ${3.5*e} 0 0 0 ${3.5*-e} ${3.5*e} z`),[a,n]},classy:e=>{var{size:r,x:i,y:s,document:o}=e;e=r/7;var a=o.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("clip-rule","evenodd"),a.setAttribute("d",t`M ${i} ${s+2.5*e} v ${2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${2.5*e} h ${4.5*e} v ${-4.5*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*-e} h ${-2*e} H ${i} z M ${i+2.5*e} ${s+e} h ${2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*e} ${1.5*e} v ${3.5*e} h ${-3.5*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*-e} ${1.5*-e} v ${-3.5*e} z`);var n=o.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("clip-rule","evenodd"),n.setAttribute("d",t`M ${i+.5*e} ${s-e} h ${4*e} a ${3.5*e} ${3.5*e} 0 0 1 ${3.5*e} ${3.5*e} v ${5.5*e} h ${-5.5*e} a ${3.5*e} ${3.5*e} 0 0 1 ${3.5*-e} ${3.5*-e} v ${-5.5*e} z`),[a,n]},inpoint:e=>{var{size:r,x:i,y:s,document:o}=e;e=r/7;var a=o.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("clip-rule","evenodd"),a.setAttribute("d",t`M ${i} ${s+2.5*e} v ${2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${2.5*e} h ${4.5*e} v ${-4.5*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*-e} h ${-2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*e} z M ${i+2.5*e} ${s+e} h ${2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*e} ${1.5*e} v ${3.5*e} h ${-3.5*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*-e} ${1.5*-e} v ${-2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*e} ${1.5*-e} z`);var n=o.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("clip-rule","evenodd"),n.setAttribute("d",t`M ${i+.5*e} ${s-e} h ${4*e} a ${3.5*e} ${3.5*e} 0 0 1 ${3.5*e} ${3.5*e} v ${5.5*e} h ${-5.5*e} a ${3.5*e} ${3.5*e} 0 0 1 ${3.5*-e} ${3.5*-e} v ${-2*e} a ${3.5*e} ${3.5*e} 0 0 1 ${3.5*e} ${3.5*-e} z`),[a,n]},centerCircle:e=>{var{x:r,y:i,size:s,document:o}=e,a=s/2.5,n=r+s/2,h=i+s/2;e=s/7;var u=o.createElementNS("http://www.w3.org/2000/svg","path");return u.setAttribute("clip-rule","evenodd"),u.setAttribute("d",t`M ${r} ${i} h ${s} v ${s} h ${-s} z M ${n-a} ${h} a ${a} ${a} 0 1 0 ${2*a} 0 a ${a} ${a} 0 1 0 ${2*-a} 0 z`),(a=o.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("clip-rule","evenodd"),a.setAttribute("d",t`M ${r-e} ${i-e} h ${s+2*e} v ${s+2*e} h ${-s-2*e} z`),[u,a]}},j={[L.dot]:t=>X.dot(t),[L.square]:t=>X.square(t),[L.extraRounded]:t=>X.extraRounded(t),[L.classy]:t=>i({...t,draw:X.classy}),[L.inpoint]:t=>i({...t,draw:X.inpoint}),[L.outpoint]:({rotation:t,...e})=>i({...e,rotation:(t||0)+Math.PI,draw:X.inpoint}),[L.centerCircle]:t=>X.centerCircle(t)};function K({x:t,y:e,size:r,document:s,getNeighbor:o},{corner:a=V.cornerRounded,end:n=V.sideRounded}={}){var h=o?+o(-1,0):0,u=o?+o(1,0):0,d=o?+o(0,-1):0,l=h+u+d+(o=o?+o(0,1):0);return 0===l?V.dot({x:t,y:e,size:r,document:s}):l>2||h&&u||d&&o?V.square({x:t,y:e,size:r,document:s}):2===l?(n=0,h&&d?n=Math.PI/2:d&&u?n=Math.PI:u&&o&&(n=-Math.PI/2),i({x:t,y:e,size:r,rotation:n,document:s,draw:a})):(a=0,d?a=Math.PI/2:u?a=Math.PI:o&&(a=-Math.PI/2),i({x:t,y:e,size:r,rotation:a,document:s,draw:n}))}function Q({x:t,y:e,size:r,document:s,getNeighbor:o},{corner:a=V.cornerRounded}={}){var n=o?+o(-1,0):0,h=o?+o(1,0):0,u=o?+o(0,-1):0;return n+h+u+(o=o?+o(0,1):0)===0?i({x:t,y:e,size:r,rotation:Math.PI/2,document:s,draw:V.classyDot}):n||u?h||o?V.square({x:t,y:e,size:r,document:s}):i({x:t,y:e,size:r,rotation:Math.PI/2,document:s,draw:a}):i({x:t,y:e,size:r,rotation:-Math.PI/2,document:s,draw:a})}function Y({x:t,y:e,size:r,document:s,getNeighbor:o},{stripe:a=r,rotation:n=0,endpoint:h=V.sideRounded,dot:u=V.dot}={}){var d=o?+o(0,-1):0;return o=o?+o(0,1):0,d&&o?i({x:t,y:e,size:r,rotation:n,document:s,draw:()=>V.square({x:t,y:e,size:r,document:s},{width:a})}):d&&!o?(n+=Math.PI/2,i({x:t,y:e,size:r,rotation:n,document:s,draw:t=>h(t,{height:a})})):o&&!d?(n-=Math.PI/2,i({x:t,y:e,size:r,rotation:n,document:s,draw:t=>h(t,{height:a})})):i({x:t,y:e,size:r,rotation:n,document:s,draw:()=>u({x:t+(r-a)/2,y:e+(r-a)/2,size:a,document:s})})}var J={[O.dot]:t=>V.dot(t),[O.randomDot]:({size:t,x:e,y:r,getPRandom:i,...s})=>{var o=.25*(i=i||Math.random)()+.75;return V.dot({...s,size:t*o,x:e+t*i()*(1-o),y:r+t*i()*(1-o)})},[O.rounded]:t=>K(t),[O.extraRounded]:t=>K(t,{corner:V.cornerExtraRounded}),[O.verticalLine]:t=>Y(t),[O.horizontalLine]:({getNeighbor:t,...e})=>Y({...e,getNeighbor:t?(e,r)=>t(r,e):void 0},{rotation:-Math.PI/2}),[O.classy]:t=>Q(t),[O.classyRounded]:t=>Q(t,{corner:V.cornerExtraRounded}),[O.square]:t=>V.square(t),[O.smallSquare]:({x:t,y:e,size:r,document:i})=>V.square({x:t+=.15*r,y:e+=.15*r,size:r=.7*r,document:i}),[O.tinySquare]:({x:t,y:e,size:r,document:i})=>V.square({x:t+=.35*r,y:e+=.35*r,size:r=.3*r,document:i}),[O.diamond]:t=>i({...t,rotation:Math.PI/4,draw:t=>V.square(t,{width:.85*t.size,height:.85*t.size})}),[O.wave]:t=>K(t,{corner:V.cornerExtraRounded,end:V.wave}),[O.heart]:t=>V.heart(t),[O.star]:t=>V.star(t),[O.weave]:t=>V.weave(t),[O.pentagon]:t=>V.star(t,{spikes:2.5,outerRadius:t.size/2,innerRadius:t.size/2}),[O.hexagon]:t=>V.star(t,{spikes:3,outerRadius:t.size/2,innerRadius:t.size/2}),[O.octagon]:t=>V.star(t,{spikes:4,outerRadius:t.size*Math.cos(Math.PI/8)/2,innerRadius:t.size*Math.cos(Math.PI/8)/2}),[O.circuit]:({getNeighbor:t,...e})=>{var r=e.getPRandom||Math.random,s=t&&r()<2/3?+t(-1,0):0;return t=t&&r()<2/3?+t(0,-1):0,r=.8*e.size,t&&s?V.circuit(e,!0):t?V.circuit(e):s?i({...e,rotation:-Math.PI/2,draw:V.circuit}):V.dot({...e,x:e.x+.1*e.size,y:e.y+.1*e.size,size:r})},[O.zebraVertical]:t=>Y(t,{stripe:.8*t.size}),[O.zebraHorizontal]:({getNeighbor:t,...e})=>Y({...e,getNeighbor:t?(e,r)=>t(r,e):void 0},{stripe:.8*e.size,rotation:-Math.PI/2}),[O.blocksVertical]:t=>Y(t,{stripe:.8*t.size,endpoint:(e,r)=>{var i=t.size*(1-.25*(t.getPRandom||Math.random)());return V.square({...e,x:t.x-(t.size-i)/2},{...r,width:i})},dot:e=>{var r=t.getPRandom||Math.random,i=t.size*(1-.25*r());return r=t.y+(t.size-i)*r(),V.square({...e,y:r},{height:i})}}),[O.blocksHorizontal]:({getNeighbor:t,...e})=>Y({...e,getNeighbor:t?(e,r)=>t(r,e):void 0},{stripe:.8*e.size,rotation:-Math.PI/2,endpoint:(t,r)=>{var i=e.size*(1-.25*(e.getPRandom||Math.random)());return V.square({...t,x:e.x-(e.size-i)/2},{...r,width:i})},dot:t=>{var r=e.getPRandom||Math.random,i=e.size*(1-.25*r());return r=e.y+(e.size-i)*r(),V.square({...t,y:r},{height:i})}}),[O.blobs]:({getNeighbor:t,...e})=>{var r=t?.(-1,-1),i=t?.(0,-1),s=t?.(1,-1),o=t?.(1,0),a=t?.(1,1),n=t?.(0,1),h=t?.(-1,1);t=t?.(-1,0);var u={tl:"square",tr:"square",bl:"square",br:"square"};return!t&&r&&(u.tl="out"),!i&&s&&(u.tr="out"),!o&&a&&(u.br="out"),!n&&h&&(u.bl="out"),t||r||i||(u.tl="round"),i||s||o||(u.tr="round"),o||a||n||(u.br="round"),n||h||t||(u.bl="round"),V.blob(e,u)},[O.soft]:({getNeighbor:t,...e})=>{var r=t?.(-1,-1),i=t?.(0,-1),s=t?.(1,-1),o=t?.(1,0),a=t?.(1,1),n=t?.(0,1),h=t?.(-1,1);t=t?.(-1,0);var u={tl:"square",tr:"square",bl:"square",br:"square"};return!t&&r&&i&&(u.tl="out"),!i&&s&&o&&(u.tr="out"),!o&&a&&n&&(u.br="out"),!n&&h&&t&&(u.bl="out"),t||i||(u.tl="round"),i||o||(u.tr="round"),o||n||(u.br="round"),n||t||(u.bl="round"),V.blob(e,u)}};function W(t,e){var r=J[t]||J[O.square];if(!e?.length)return r;var i=function(t){return e=>{for(let r of t){let t=r.drawDot?.(e);if(t)return t}}}(e);return t=>i(t)||r(t)}var Z={toDataURL:t=>"string"==typeof t&&t.startsWith("data:")?Promise.resolve(t):new Promise((e,r)=>{if("string"==typeof t){let i=new XMLHttpRequest;i.onload=()=>{var t=new FileReader;t.onloadend=()=>{e(t.result)},t.readAsDataURL(i.response)},i.onerror=i.onabort=i.ontimeout=r,i.open("GET",t,!0),i.responseType="blob",i.send()}else{let r=new FileReader;r.onloadend=()=>{e(r.result)},r.readAsDataURL(t)}}),getSize:(t,e)=>new Promise((r,i)=>{var s=new Image;"string"===e&&(s.crossOrigin=e),s.onload=()=>{r({width:s.width,height:s.height})},s.onerror=s.onabort=i,"string"==typeof t?s.src=t:Z.toDataURL(t).then(t=>s.src=t).catch(i)})};function tt(t,e,r,i=!0){var s;return()=>{if(null==s){var o=s=0;for(let a=-3;a<4;a++)for(let n=-3;n<4;n++)o++,s|=Number(t[(e+a+t.length<<n)%t.length]?.[(r+n+t.length<<a)%t.length]===i)<<o}return o=s+=1831565813,o=Math.imul(o^o>>>15,1|o),(((o^=o+Math.imul(o^o>>>7,61|o))^o>>>14)>>>0)/4294967296}}var et=[[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]],rt=new Set(Object.values(L));var it=[[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]],st=new Set(Object.values(C));class ot{options;_element;_fakeMatrix;_dotsColor;_backgroundColor;get element(){return this._element}get dotsColor(){return this._dotsColor}get backgroundColor(){return this._backgroundColor}defs;backgroundMask;dotsMask;lightDotsMask;qr;document;imageTools;constructor(t){this.options=t,this.document=t.document,this._element=this.document.createElementNS("http://www.w3.org/2000/svg","svg");var r=e(t.size);this._element.setAttribute("width",r),this._element.setAttribute("height",r),this._element.setAttribute("viewBox",`0 0 ${r} ${r}`),this.defs=this.document.createElementNS("http://www.w3.org/2000/svg","defs"),this._element.appendChild(this.defs),this.imageTools=t.imageTools||Z}get width(){return this.options.size}get height(){return this.options.size}async drawQR(t){var e=t.getModuleCount(),r=parseInt(((e-17)/4).toFixed(0),10),i=this.options.dotsOptions.size,s={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:o,errorCorrectionPercent:a}=this.options;if(o.mode==B.background){r=(this.options.size-2*(this.options.backgroundOptions&&this.options.backgroundOptions.margin||0)*i)*o.imageSize;let{width:e,height:a}=t;a=a/e*r,e=r,a>r&&(e=e/a*r,a=r),s={hideXDots:0,hideYDots:0,width:e,height:a}}else{let n=o.imageSize*a;r=b.getPatternPosition(r),s=function({originalHeight:t,originalWidth:e,maxHiddenDots:r,maxHiddenAxisDots:i,dotSize:s,margin:o}){if(t<=0||e<=0||r<=0||s<=0||4*o**2>r)return{height:0,width:0,hideYDots:0,hideXDots:0};i&&i%2==0&&(i=Math.max(1,i-1));var a=Math.max(e,t),n=Math.min(e,t),h=0;i=(i||r)-2*o;do{let t=h+(i-h)/2,e=Math.max(1,Math.ceil(t+2*o));e%2==0&&e++;let s=Math.max(1,Math.ceil(t*n/a+2*o));s%2==0&&s++,e*s>r?i=t:h=t}while(Math.abs(h-i)>.001);return(r=Math.max(1,Math.ceil(h+2*o)))%2==0&&r++,(n=Math.max(1,Math.ceil(h*n/a+2*o)))%2==0&&n++,e>t?a=r:(a=n,n=r),r=i=(a-2*o)*s,(i=i*t/e)>(h=(n-2*o)*s)&&(i=h,r=h*e/t),{height:Math.round(i+2*o*s),width:Math.round(r+2*o*s),hideYDots:n,hideXDots:a}}({originalWidth:t.width,originalHeight:t.height,maxHiddenDots:Math.floor(n*(e*e-192-2*(e-16)-r.length**2*25)),maxHiddenAxisDots:e-14,dotSize:i,margin:o.margin})}}this.drawBackground(),this.options.imageOptions.mode!=B.overlay&&this.options.image&&s.width>0&&s.height>0&&await this.drawImage({width:s.width,height:s.height,count:e,dotSize:i}),this.drawDots((t,r)=>!(this.options.imageOptions.mode==B.center&&t>=(e-s.hideXDots)/2&&t<(e+s.hideXDots)/2&&r>=(e-s.hideYDots)/2&&r<(e+s.hideYDots)/2||t<8&&r<8||t>=e-8&&r<8||r>=e-8&&t<8)),this.options.imageOptions.mode==B.overlay&&this.options.image&&s.width>0&&s.height>0&&await this.drawImage({width:s.width,height:s.height,count:e,dotSize:i}),this.drawCorners()}drawBackground(){var t=this.options;if(this._element&&t.backgroundOptions){this._backgroundColor=this.createColor({options:t.backgroundOptions.gradient,color:t.backgroundOptions.color,additionalRotation:0,x:0,y:0,height:t.size,width:t.size,name:"background-color"});let r=this.document.createElementNS("http://www.w3.org/2000/svg","rect");this.backgroundMask=this.createMask("mask-background-color"),this.defs.appendChild(this.backgroundMask),r.setAttribute("x",e(0)),r.setAttribute("y",e(0)),r.setAttribute("width",e(t.size)),r.setAttribute("height",e(t.size)),r.setAttribute("rx",e(t.size/2*(t.backgroundOptions.round||0))),this.backgroundMask.appendChild(r)}}drawDots(t){if(!this.qr)throw Error("QR code is not defined");var e=this.options,r=this.qr.getModuleCount();if(r>e.size)throw Error("The canvas is too small");var i=this.options.dotsOptions.size,s=e.size;e.imageOptions.mode==B.background&&(s-=2*i*(e.imageOptions.margin||0));var o=Math.floor((e.size-r*i)/2),a=W(e.dotsOptions.type,e.plugins),n=a;this.dotsMask=this.createMask("mask-dot-color"),this.defs.appendChild(this.dotsMask),e.imageOptions.mode==B.background&&(this.lightDotsMask=this.createMask("mask-light-dot-color"),this.defs.appendChild(this.lightDotsMask));var h=0,u=0;h=r,e.shape===S.circle?(h=this.options.backgroundOptions&&this.options.backgroundOptions.margin||0,h=r+2*(u=Math.floor((s/i-r-2*h)/2))):e.imageOptions.mode==B.background&&(h=r+2*(u=1)),s=o-u*i,o=r+2*u,this._fakeMatrix=Array(h);var d=Math.floor(h/2),l=tt(this._fakeMatrix,0,0,!1);for(let i=0;i<h;i++){this._fakeMatrix[i]=Array(h);for(let s=0;s<h;s++)if(i>u-1&&i<h-u&&s>u-1&&s<h-u){let e=i-u,r=s-u;t&&!t(e,r)?this._fakeMatrix[i][s]=void 0:this._fakeMatrix[i][s]=!!this.qr.isDark(r,e)}else this._fakeMatrix[i][s]=e.shape===S.circle&&Math.sqrt((i-d)*(i-d)+(s-d)*(s-d))>d?void 0:i==u-1||i==h-u||s==u-1||s==h-u?(s==u-1&&(i<u+8||i>h-u-9)||s==h-u&&i<u+8||i==u-1&&(s<u+8||s>h-u-9)||i==h-u&&s<u+8)&&void 0:this.qr.isDark(Math.floor(l()*r),Math.floor(l()*r))}t=b.getPatternPosition((r-17)/4);var g=Array(h);for(let e=0;e<h;e++){g[e]=Array(h),r=t.find(t=>e-u>t-3&&e-u<t+3);for(let i=0;i<h;i++)d=t.find(t=>i-u>t-3&&i-u<t+3),g[e][i]=void 0,null!=this._fakeMatrix[e][i]&&this.lightDotsMask&&r&&d&&(r!=t[0]&&d!=t[0]||d!=t[0]&&d!=t[t.length-1]||r!=t[0]&&r!=t[t.length-1])&&(g[e][i]=this._fakeMatrix[e][i])}for(let t=0;t<h;t++)for(let r=0;r<h;r++){if(null==this._fakeMatrix[t][r])continue;this.lightDotsMask&&(a=null!=g[t][r]?n:W(O.tinySquare));let o=e.imageOptions.mode==B.background&&null!=g[t][r];this._fakeMatrix[t][r]?this.dotsMask&&this.dotsMask.appendChild(a({x:s+t*i,y:s+r*i,size:i,document:this.options.document,getNeighbor:(e,i)=>(e=t+e,i=r+i,o?!0===g[e]?.[i]:!0===this._fakeMatrix[e]?.[i]),getPRandom:tt(this._fakeMatrix,t,r)})):this.lightDotsMask&&this.lightDotsMask&&this.lightDotsMask.appendChild(a({x:s+t*i,y:s+r*i,size:i,document:this.options.document,getNeighbor:(e,i)=>(e=t+e,i=r+i,o?!1===g[e]?.[i]:!1===this._fakeMatrix[e]?.[i]),getPRandom:tt(this._fakeMatrix,t,r,!1)}))}this.lightDotsMask&&this.createColor({options:e.imageOptions.fill.gradient,color:e.imageOptions.fill.color,additionalRotation:0,x:s,y:s,height:o*i,width:o*i,name:"light-dot-color"}),this._dotsColor=this.createColor({options:e.dotsOptions?.gradient,color:e.dotsOptions.color,additionalRotation:0,x:s,y:s,height:o*i,width:o*i,name:"dot-color"})}drawCorners(){if(!this.qr)throw Error("QR code is not defined");var t=this.options;if(!this._element)throw Error("Element code is not defined");var e=this.qr.getModuleCount(),r=this.options.dotsOptions.size,i=7*r,s=3*r,o=Math.floor((t.size-e*r)/2);[[0,0,0],[1,0,Math.PI/2],[0,1,-Math.PI/2]].forEach(([a,n,h])=>{var u=o+a*r*(e-7),d=o+n*r*(e-7),l=this.dotsMask,g=this.dotsMask;(t.cornersSquareOptions?.gradient||t.cornersSquareOptions?.color)&&(l=this.createMask(`mask-corners-square-color-${a}-${n}`),this.defs.appendChild(l),g=g=l,this.createColor({options:t.cornersSquareOptions?.gradient,color:t.cornersSquareOptions?.color,additionalRotation:h,x:u,y:d,height:i,width:i,name:`corners-square-color-${a}-${n}`}));var c={x:u,y:d,size:i,document:this.options.document,rotation:h},p=t.plugins?.length?function(t){return e=>{for(let r of t){let t=r.drawCornerSquare?.(e);if(t)return t}}}(t.plugins)(c):void 0;if(p){let[t,e]=p;l&&l.appendChild(t),this.lightDotsMask&&this.lightDotsMask.appendChild(e)}else if(function(t){return!(!t||!rt.has(t))}(t.cornersSquareOptions?.type)){let[e,r]=(j[t.cornersSquareOptions.type]||j[L.square])(c);l&&l.appendChild(e),this.lightDotsMask&&this.lightDotsMask.appendChild(r)}else{c=W(t.cornersSquareOptions?.type||t.dotsOptions.type,t.plugins);for(let t=0;t<et.length;t++)for(let e=0;e<et[t].length;e++)et[t]?.[e]?l&&l.appendChild(c({x:u+t*r,y:d+e*r,size:r,document:this.options.document,getNeighbor:(r,i)=>!!et[t+r]?.[e+i],getPRandom:tt(this._fakeMatrix,u/r+t,d/r+e,!1)})):this.lightDotsMask&&!it[t]?.[e]&&this.lightDotsMask&&this.lightDotsMask.appendChild(c({x:u+t*r,y:d+e*r,size:r,document:this.options.document,getNeighbor:(r,i)=>!et[t+r]?.[e+i]&&!it[t+r]?.[e+i],getPRandom:tt(this._fakeMatrix,u/r+t,d/r+e,!1)}));if(this.lightDotsMask)for(let t=-1;t<8;t++)for(let e=-1;e<8;e++)(-1==t||7==t||-1==e||7==e)&&this.lightDotsMask&&this.lightDotsMask.appendChild(c({x:u+t*r,y:d+e*r,size:r,document:this.options.document,getNeighbor:(r,i)=>(i=e+i,(r=t+r)>=-1&&r<=7&&i>=-1&&i<=7&&(-1==r||7==r||-1==i||7==i)),getPRandom:tt(this._fakeMatrix,u/r+t,d/r+e,!1)}))}if((t.cornersDotOptions?.gradient||t.cornersDotOptions?.color)&&(g=this.createMask(`mask-corners-dot-color-${a}-${n}`),this.defs.appendChild(g),this.createColor({options:t.cornersDotOptions?.gradient,color:t.cornersDotOptions?.color,additionalRotation:h,x:u+2*r,y:d+2*r,height:s,width:s,name:`corners-dot-color-${a}-${n}`})),a={x:u+2*r,y:d+2*r,size:s,document:this.document,rotation:h},n=t.plugins?.length?function(t){return e=>{for(let r of t){let t=r.drawCornerDot?.(e);if(t)return t}}}(t.plugins)(a):void 0)g&&g.appendChild(n);else if(function(t){return!(!t||!st.has(t))}(t.cornersDotOptions?.type))u=F[t.cornersDotOptions.type]||F[C.square],g&&g.appendChild(u(a));else{a=W(t.cornersDotOptions?.type||t.dotsOptions.type,t.plugins);for(let t=0;t<it.length;t++)for(let e=0;e<it[t].length;e++)it[t]?.[e]&&g&&g.appendChild(a({x:u+t*r,y:d+e*r,size:r,document:this.options.document,getNeighbor:(r,i)=>!!it[t+r]?.[e+i],getPRandom:tt(this._fakeMatrix,u/r+t,d/r+e,!1)}))}})}async drawImage({width:t,height:r,count:i,dotSize:s}){var o=this.options,a=Math.floor((o.size-i*s)/2),n=o.imageOptions.margin*s;o.imageOptions.mode==B.background&&(n=0);var h=a+n+(i*s-t)/2;if(i=a+n+(i*s-r)/2,t-=2*n,r-=2*n,n=await this.imageTools.toDataURL(o.image||""),(o=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&&(o=n[0]).setAttribute("overflow","visible"))}o.setAttribute("x",e(h)),o.setAttribute("y",e(i)),o.setAttribute("width",`${e(t)}px`),o.setAttribute("height",`${e(r)}px`),this._element.appendChild(o)}createColor(t){var{width:r,height:i,x:s,y:a}=t;s-=this.options.dotsOptions.size,a-=this.options.dotsOptions.size,r+=2*this.options.dotsOptions.size,i+=2*this.options.dotsOptions.size;var n=this.document.createElementNS("http://www.w3.org/2000/svg","rect");return n.setAttribute("x",e(s)),n.setAttribute("y",e(a)),n.setAttribute("height",e(i)),n.setAttribute("width",e(r)),n.setAttribute("clip-path",`url(#mask-${t.name})`),(t=o({...t,dotSize:this.options.dotsOptions.size,document:this.document}))&&(n.setAttribute("fill",t.value),t.gradient&&this.defs.appendChild(t.gradient),t.opacity<1&&n.setAttribute("opacity",t.opacity.toFixed(7))),this._element.appendChild(n),t}createMask(t){var e=this.document.createElementNS("http://www.w3.org/2000/svg","clipPath");return e.setAttribute("id",t),e.setAttribute("clipPathUnits","userSpaceOnUse"),e}}Object.assign(D.stringToBytesFuncs,{UTF8:t=>{var e=[];for(let r=0;r<t.length;r++){let i=t.charCodeAt(r);i<128?e.push(i):i<2048?e.push(192|i>>6,128|63&i):i<55296||i>=57344?e.push(224|i>>12,128|i>>6&63,128|63&i):(r++,i=65536+((1023&i)<<10|1023&t.charCodeAt(r)),e.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|63&i))}return e}});class at{options;container;qr;extension;svgDrawingPromise;qrSVG;get size(){if(this.qrSVG)return{width:this.qrSVG.width,height:this.qrSVG.height}}constructor(t){this.options=t?H(T(I,t)):I,this.update()}update(t){this.container&&(this.container.innerHTML=""),this.options=t?H(T(this.options,t)):this.options,this.options.data&&(this.options.stringToBytesFuncs&&(Object.assign(D.stringToBytesFuncs,this.options.stringToBytesFuncs),delete this.options.stringToBytesFuncs),this.qr=new D(this.options.qrOptions.typeNumber,this.options.qrOptions.errorCorrectionLevel),t=this.options.qrOptions.mode||function(t){switch(!0){case/^[0-9]*$/.test(t):return z.numeric;case/^[0-9A-Z $%*+\-./:]*$/.test(t):return z.alphanumeric;case/[^\u0000-\u00ff]/.test(t):return z.unicode;default:return z.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 Error("Extension function should be defined.");this.extension=t,this.update()}deleteExtension(){this.extension=void 0,this.update()}async serialize(){if(!this.qr)throw Error("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==B.background&&this.options.shape!=S.circle&&(t+=2),(t=Math.ceil((this.options.shape==S.circle?Math.sqrt(2):1)*t))%2==0&&--t;var e=this.options.backgroundOptions&&this.options.backgroundOptions.margin||0;this.options.imageOptions.mode==B.background&&(e+=this.options.imageOptions.margin||0);var r=Math.ceil(this.options.dotsOptions.size*(t+2*e));this.qrSVG=new ot({...this.options,width:r,height:r,size:r,errorCorrectionPercent:U[this.options.qrOptions.errorCorrectionLevel]}),this.svgDrawingPromise=this.qrSVG.drawQR(this.qr).then(()=>{this.qrSVG?.element&&(this.options.plugins?.forEach(t=>t.postProcess?.(this.qrSVG.element,{...this.options,width:r,height:r,size:r},{dots:this.qrSVG?.dotsColor,background:this.qrSVG?.backgroundColor})),this.extension?.(this.qrSVG.element,{...this.options,width:r,height:r,size:r}))})}}}var nt={width:300,height:300,margin:0};var ht,ut=ht||={};ut.Lanczos="lanczos",ut.Linear="linear";var dt={[ht.Lanczos]:(t,e)=>e>=t||e<=-t?0:0===e?1:(e*=Math.PI,t*Math.sin(e)*Math.sin(e/t)/(e*e)),[ht.Linear]:(t,e)=>(e=Math.abs(e))<=1?(1-e)*t:0};function lt(t){return"object"==typeof t?(t.baseVal.convertToSpecifiedUnits(t.baseVal.SVG_LENGTHTYPE_PX),t.baseVal.value):t}var gt,ct=gt||={};function pt(t,e){var{width:r,height:i,margin:s}=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}(T(nt,e)):nt,o=document.createElement("canvas");o.width=r,o.height=i;var a=Math.min(r,i)-2*s;return t=t.serialize().then(t=>{if(t){var e=t.match(/viewBox="([^"]+)"/i)[1],n="data:image/svg+xml;base64,"+btoa(t),h=new Image;return new Promise((t,u)=>{h.onload=()=>{var n=Math.ceil(2*a/Math.min(h.width,h.height)),[u,d,l,g]=e.split(/\s+/g).map(parseFloat).map(t=>t*n),c=(u%1+1)%1,p=(d%1+1)%1;try{var m=new OffscreenCanvas(Math.ceil(l+c+2),Math.ceil(g+p+2))}catch(t){(m=document.createElement("canvas")).width=Math.ceil(l+c+2),m.height=Math.ceil(g+p+2)}m.getContext("2d")?.drawImage(h,c+1,p+1,l,g),c=function(t,e,r=dt[ht.Lanczos]){var i=lt(t.width),s=lt(t.height);t=t.getContext("2d");var{width:o,height:a}=e,n=t.getImageData(0,0,i,s);if(e=t.createImageData(o,a),n.data.length==e.data.length)e=n;else{t=n.data,n=e.data;let y=[];var h=o/i,u=a/s;let A=3;h>.01&&u>.01&&h<1&&u<1&&(A=h<=.2||u<=.2?2:h<=.05||u<=.05?1:3),u=i-1,--s;let E=1/h,z=1/h,k=1/o,D=1/a,x=Math.min(1,h)*Math.min(1,h);h=Math.min(1,h)*Math.min(1,h);for(var d=A,l={},g=d*d*1e3,c=0;c<g;c++){var p=r(d,Math.sqrt(.001*c));l[c]=p<0?0:p}for(r=l,d=a;d--;){(l=(c=(d+.5)*z)-A)<0&&(l=0),p=g=c+A,g!=p&&(g=p+1),g>s&&(g=s),c=d*D-c,p=d*o;let e=o;for(;e--;){var m=(e+.5)*E,$=m-A;$<0&&($=0);let s=m+A;var v=s;s!=v&&(s=v+1),s>u&&(s=u);var w=e*k-m;v=m=0;for(var f=0|l;f<=g;f++)for(var b=(f+c)*(f+c)*h,M=0|$;M<=s;M++)v+=y[m++]=r[1e3*((M+w)*(M+w)*x+b)|0]||0;v=1/v,M=b=f=w=m=0;for(let e=0|l;e<=g;e++){let r=e*i;for(let e=0|$;e<=s;e++){let i=y[m++]*v,s=4*(r+e|0);f+=t[s]*i,b+=t[s+1]*i,M+=t[s+2]*i,w+=t[s+3]*i}}n[$=4*(e+p|0)]=f,n[$+1]=b,n[$+2]=M,n[$+3]=w}}}return e}(m,{width:r-2*s,height:i-2*s}),o?.getContext("2d")?.putImageData(c,s,s),t()},h.onerror=h.onabort=u,h.src=n})}}),{canvas:o,canvasDrawingPromise:t}}function mt(t,e){var r=document.createElement("a");r.download=e,r.href=t,document.body.appendChild(r),r.click(),document.body.removeChild(r)}ct.svg="svg",ct.png="png",ct.jpeg="jpeg",ct.webp="webp";var $t=Object.freeze({__proto__:null,get FileExtension(){return gt},download:async function(t,e,r){var i=gt.png,s="qr";if(e&&(e.name&&(s=e.name),e.extension&&(i=e.extension)),"svg"===i.toLowerCase())(i=await t.serialize())&&mt(i="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(i),`${s}.svg`);else if(t=pt(t,r)){var{canvas:o,canvasDrawingPromise:a}=t;await a,mt(t=o.toDataURL(`image/${i}`),`${s}.${i}`)}},downloadURI:mt,drawToCanvas:pt});export{C as CornerDotType,L as CornerSquareType,O as DotType,y as ErrorCorrectionLevel,U as ErrorCorrectionPercents,gt as FileExtension,B as ImageMode,z as Mode,at as QRCodeStyling,S as ShapeType,A as TypeNumber,$t as browserUtils};
2
2
  //# sourceMappingURL=qr-code-styling.js.map